Skip to content

Commit

Permalink
Merge pull request #73 from Alexei-Kornienko/alex/definitions
Browse files Browse the repository at this point in the history
Add possibility to provide data definitions
  • Loading branch information
cr0hn authored Jul 22, 2019
2 parents 664b45e + d5f8fb9 commit 298d513
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions aiohttp_swagger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def setup_swagger(app: web.Application,
swagger_home_decor: FunctionType = None,
swagger_def_decor: FunctionType = None,
swagger_info: dict = None,
definitions: dict = None,
security_definitions: dict = None):
_swagger_url = ("/{}".format(swagger_url)
if not swagger_url.startswith("/")
Expand All @@ -62,6 +63,7 @@ def setup_swagger(app: web.Application,
swagger_info = generate_doc_from_each_end_point(
app, api_base_url=api_base_url, description=description,
api_version=api_version, title=title, contact=contact,
definitions=definitions,
security_definitions=security_definitions,
)
else:
Expand Down
2 changes: 2 additions & 0 deletions aiohttp_swagger/helpers/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def generate_doc_from_each_end_point(
api_version: str = "1.0.0",
title: str = "Swagger API",
contact: str = "",
definitions: dict = None,
security_definitions: dict = None):
# Clean description
_start_desc = 0
Expand Down Expand Up @@ -98,6 +99,7 @@ def nesteddict2yaml(d, indent=10, result=""):
title=title,
contact=contact,
base_path=api_base_url,
definitions=definitions,
security_definitions=security_definitions)
)

Expand Down
4 changes: 4 additions & 0 deletions aiohttp_swagger/templates/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ basePath: {{ base_path }}
schemes:
- http
- https
{% if definitions %}
definitions:
{{ definitions|nesteddict2yaml }}
{% endif %}
{% if security_definitions %}
securityDefinitions:
{{ security_definitions|nesteddict2yaml }}
Expand Down

0 comments on commit 298d513

Please sign in to comment.