Skip to content

Commit

Permalink
more doc support for openapi generation (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcruse3 authored May 22, 2024
1 parent 3ef82c2 commit 06b25fe
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pytest-html = "*"
pytest-cov = "*"

[scripts]
generate = "python -m acai_aws.apigateway generate-openapi --base=acai_aws/example --handlers=tests/mocks/apigateway/openapi/**/*.py --output=tests/outputs --format=json,yml --delete"
test = "python -m unittest discover"
coverage = "coverage run --source acai_aws/ -m pytest tests/acai_aws --cov=acai_aws --junitxml ./coverage/reports/xunit.xml --cov-report xml:./coverage/reports/coverage.xml --html=./coverage/reports/index.html --self-contained-html --cov-report html:./coverage -p no:warnings -o log_cli=true"
lint = "pylint acai_aws --recursive=y --load-plugins pylint_quotes --fail-under 10 --output-format=text:coverage/lint/report.txt,json:coverage/lint/report.json,parseable,colorized"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ DRY, configurable, declarative node library for working with Amazon Web Service
## Features
* Highly configurable apigateway internal router
* Openapi schema adherence for all event types
* Generate OpenAPI docs from code base
* Extensible and customizable middleware for validation and other tasks
* DRY coding interfaces without the need of boilerplate
* Ease-of-use with the [serverless framework](https://www.serverless.com/)
Expand Down
9 changes: 9 additions & 0 deletions acai_aws/apigateway/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@


def generate_openapi():
print('STARTED')
print('generating openapi docs...')
print('validating arguments received...')
inputs = InputArguments()
validator = InputValidator()
scanner = HandlerScanner(inputs.handlers)
Expand All @@ -18,16 +21,22 @@ def generate_openapi():
writer = OpenAPIFileWriter()

validator.validate_arguments(inputs)
print('arguments validated...')
file_paths = scanner.get_handler_file_paths()
print(f'scanning handlers: {inputs.handlers}...')
modules = importer.get_modules_from_file_paths(file_paths, scanner.handlers_base, inputs.base)
print('importing handler endpoint modules...')

for module in modules:
generator.add_path_and_method(module)

if inputs.delete:
print('deleting paths and methods not found in code base')
generator.delete_unused_paths()

print(f'writing openapi doc to requested directory: {inputs.output}')
writer.write_openapi(generator.doc, inputs.output, inputs.formats)
print('COMPLETED')


if __name__ == '__main__': # pragma: no cover
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'jsonref',
'jsonschema',
'icecream',
'pydantic',
'pyyaml',
'simplejson',
'xmltodict'
Expand Down

0 comments on commit 06b25fe

Please sign in to comment.