diff --git a/README.md b/README.md index cd2bbd1..74209c4 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,12 @@ Only support Python3. api_doc(app, config_url='https://petstore.swagger.io/v2/swagger.json', url_prefix='/api/doc', title='API doc') ``` + Setting addtional [SwaggerUI configuration parameters](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/) (simple values only, functions and variables are not supported) + + ```python + api_doc(app, config_path='/config/test.yaml', title='API doc', doc_config={ "validationUrl": None }) + ``` + And suport config file editor ```python diff --git a/setup.py b/setup.py index c99339b..de02cb6 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ def load_requirements(): if __name__ == '__main__': setup( name='swagger-ui-py', - version='0.3.0', + version='0.4.0-dev', description=DESCRIPTION, long_description=readme(), long_description_content_type='text/markdown', diff --git a/swagger_ui/core.py b/swagger_ui/core.py index 001b976..cc89a24 100644 --- a/swagger_ui/core.py +++ b/swagger_ui/core.py @@ -13,7 +13,8 @@ class Interface(object): def __init__(self, app, app_type=None, config_path=None, config_url=None, - url_prefix='/api/doc', title='API doc', editor=False): + url_prefix='/api/doc', title='API doc', editor=False, + doc_config=None): self._app = app self._title = title @@ -21,6 +22,7 @@ def __init__(self, app, app_type=None, config_path=None, config_url=None, self._config_url = config_url self._config_path = config_path self._editor = editor + self._doc_config = doc_config assert self._config_url or self._config_path, 'config_url or config_path is required!' @@ -41,7 +43,10 @@ def static_dir(self): @property def doc_html(self): return self._env.get_template('doc.html').render( - url_prefix=self._url_prefix, title=self._title, config_url=self._uri('/swagger.json') + url_prefix=self._url_prefix, + title=self._title, + config_url=self._uri('/swagger.json'), + doc_config_json=json.dumps(self._doc_config) ) @property diff --git a/swagger_ui/templates/doc.html b/swagger_ui/templates/doc.html index 87cc1f6..50ec284 100644 --- a/swagger_ui/templates/doc.html +++ b/swagger_ui/templates/doc.html @@ -4,7 +4,7 @@ {{ title }} - +