Skip to content

Commit 6fa8ca9

Browse files
olexandr-klymenkotrezorg
authored andcommitted
Turn off online swagger validation by default [#36](#36) by introducing a new string argument for **setup_swagger** function **swagger_validator_url** with default value **''**. Documentation is updated.
1 parent 3549baf commit 6fa8ca9

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

aiohttp_swagger/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def setup_swagger(app: web.Application,
4040
swagger_from_file: str = None,
4141
swagger_url: str = "/api/doc",
4242
api_base_url: str = "/",
43+
swagger_validator_url: str = "",
4344
description: str = "Swagger API definition",
4445
api_version: str = "1.0.0",
4546
title: str = "Swagger API",
@@ -95,6 +96,7 @@ def setup_swagger(app: web.Application,
9596
format(api_base_url.lstrip('/'), _swagger_def_url))
9697
.replace("##STATIC_PATH##", '/{}{}'.
9798
format(api_base_url.lstrip('/'), statics_path))
99+
.replace("##SWAGGER_VALIDATOR_URL##", swagger_validator_url)
98100
)
99101

100102

aiohttp_swagger/swagger_ui/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
}
5151
window.swaggerUi = new SwaggerUi({
5252
url: url,
53+
validatorUrl: "##SWAGGER_VALIDATOR_URL##" || null,
5354
dom_id: "swagger-ui-container",
5455
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
5556
onComplete: function(swaggerApi, swaggerUi){

doc/source/customizing.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,17 @@ In this case `api_base_url` argument of `setup_swagger` function should be the s
195195
196196
app.add_subapp(prefix='/sub_app_prefix', subapp=sub_app)
197197
198-
web.run_app(app, host="127.0.0.1")
198+
web.run_app(app, host="127.0.0.1")
199+
200+
Swagger content validation
201+
+++++++++++++++++++++++++++
202+
203+
:samp:`aiohttp-swagger` allows to perform online swagger validation. By default this feature is turned off `(swagger_validator_url='')`:
204+
205+
206+
.. code-block:: python
207+
208+
setup_swagger(app,
209+
api_base_url='/sub_app_prefix',
210+
swagger_validator_url='//online.swagger.io/validator'
211+
)

0 commit comments

Comments
 (0)