Commit d81cd453 authored by Goran Pavlovic's avatar Goran Pavlovic
Browse files

Merge branch 'master' of https://github.com/olexandr-klymenko/aiohttp-swagger...

Merge branch 'master' of https://github.com/olexandr-klymenko/aiohttp-swagger into olexandr-klymenko-master
parents ea2dd2eb 5a4d109e
......@@ -40,6 +40,7 @@ def setup_swagger(app: web.Application,
swagger_from_file: str = None,
swagger_url: str = "/api/doc",
api_base_url: str = "/",
swagger_validator_url: str = "",
description: str = "Swagger API definition",
api_version: str = "1.0.0",
title: str = "Swagger API",
......@@ -99,6 +100,7 @@ def setup_swagger(app: web.Application,
format(api_base_url.rstrip('/'), _swagger_def_url))
.replace("##STATIC_PATH##", '{}{}'.
format(api_base_url.rstrip('/'), statics_path))
.replace("##SWAGGER_VALIDATOR_URL##", swagger_validator_url)
)
......
......@@ -50,6 +50,7 @@
}
window.swaggerUi = new SwaggerUi({
url: url,
validatorUrl: "##SWAGGER_VALIDATOR_URL##" || null,
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
onComplete: function(swaggerApi, swaggerUi){
......
......@@ -255,4 +255,17 @@ In this case `api_base_url` argument of `setup_swagger` function should be the s
app.add_subapp(prefix='/sub_app_prefix', subapp=sub_app)
web.run_app(app, host="127.0.0.1")
\ No newline at end of file
web.run_app(app, host="127.0.0.1")
Swagger validation
+++++++++++++++++++
:samp:`aiohttp-swagger` allows to perform online swagger validation. By default this feature is turned off `(swagger_validator_url='')`:
.. code-block:: python
setup_swagger(app,
api_base_url='/sub_app_prefix',
swagger_validator_url='//online.swagger.io/validator'
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment