Skip to content

Commit

Permalink
Merge pull request #2 from AppThreat/feature/openapi_conversion
Browse files Browse the repository at this point in the history
Feature/openapi conversion
  • Loading branch information
prabhu authored Jan 16, 2024
2 parents 964024e + 0720c18 commit f54e391
Show file tree
Hide file tree
Showing 21 changed files with 88,670 additions and 2 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
on: [push, pull_request]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.12"
- uses: pre-commit/[email protected]
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
Expand Down
35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: mixed-line-ending
- id: trailing-whitespace
types: [ python ]
- id: end-of-file-fixer
types: [ python ]
- id: check-docstring-first
types: [ python ]
# - id: double-quote-string-fixer
# types: [ python ]

# - repo: https://github.com/psf/black
# rev: 23.11.0
# hooks:
# - id: black

- repo: https://github.com/pycqa/pylint
rev: v3.0.2
hooks:
- id: pylint
exclude: 'cli|test'
args: []

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
exclude: 'cli|test'
args: [--statistics]

ci:
autofix_prs: false
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include atom_tools/atom_data/openapi_slices_schemas.json
87 changes: 86 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,87 @@
# atom-tools
Collection of tools for use with [appthreat/atom](https://github.com/appthreat/atom).
Collection of tools for use with slices generated by [AppThreat/atom](https://github.com/appthreat/atom).

## Install atom

This program does not generate slices; its purpose is to manipulate slices
generated by atom. The current documentation for atom is housed in the
[AppThreat/atom](https://github.com/AppThreat/atom?tab=readme-ov-file) GitHub
repository.

Atom can easily be installed from a
[native image](https://github.com/AppThreat/atom#atom-native-image) or via npm
`npm install @appthreat/atom`.

## Atom-tools installation

`pip install atom-tools`

## CLI Usage

Atom-tools uses py-poetry/cleo to construct its command-line interface and
therefore uses the same sorts of conventions as the package management utility
poetry.

To access the commands help menu, enter `atom-tools list` for a list of
available commands.

Individual command options can be accessed with `atom help ` and the command
name (e.g. `atom help convert`).
```
Atom Tools (version 0.1.0)
Usage:
command [options] [arguments]
Options:
-h, --help Display help for the given command. When no command is given display help for the list command.
-q, --quiet Do not output any message.
-V, --version Display this application version.
--ansi Force ANSI output.
--no-ansi Disable ANSI output.
-n, --no-interaction Do not ask any interactive question.
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
Available commands:
convert Convert an atom slice to a different format
help Displays help for a command.
list Lists commands.
```

## Features
### Convert
The convert command can be used to output an atom slice in a different format.
The current capabilities are limited to processing usages in order to generate
endpoints for an openapi 3.x paths object. Future iterations will populate the
path item objects with more details based on atom slices.

```
Description:
Convert an atom slice to a different format
Usage:
convert [options]
Options:
-f, --format=FORMAT Destination format [default: "openapi3.1.0"]
-u, --usages-slice=USAGES-SLICE Usages slice file
-t, --type=TYPE Origin type of source on which the atom slice was generated. [default: "java"]
-o, --output-file=OUTPUT-FILE Output file [default: "openapi_from_slice.json"]
-h, --help Display help for the given command. When no command is given display help for the list command.
-q, --quiet Do not output any message.
-V, --version Display this application version.
--ansi Force ANSI output.
--no-ansi Disable ANSI output.
-n, --no-interaction Do not ask any interactive question.
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
Help:
The convert command converts an atom slice to a different format.
Currently supports outputting an OpenAPI 3.x document based on a usages
slice.
```

**Example**
>`atom-tools convert -u usages.slices.json -f openapi3.1.0 -o openapi_usages.json -t java`
Note: Supported languages include the following: jar, java, javascript, python, typescript
4 changes: 4 additions & 0 deletions atom_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""
A cli, classes and functions for converting an atom slice to a different format
"""
__version__ = '0.1.0'
Empty file.
Loading

0 comments on commit f54e391

Please sign in to comment.