Swagger router¶
Classes¶
SwaggerRouter¶
New in version 0.1.
-
class
aiohttp_apiset.swagger.router.
SwaggerRouter
(path: str = None, *, search_dirs=None, swagger_ui='/apidoc/', version_ui=2, route_factory=<function route_factory>, encoding=None, default_validate=True, file_loader=None, spec_url=None)[source]¶ SwaggerRouter is designed to load swagger specifications
Parameters: - path – path to specification
- search_dirs – directory for search files of specification
- swagger_ui – if True then swagger-ui will be available at the url basePath/apidoc/index.html
- encoding – default encoding of specification, if None apply UTF-8
- route_factory – factory for select route class and create route
- default_validate – if True and not specify in method then standart route_factory selected SwaggerValidationRoute
-
add_route
(method, path, handler, *, name=None, expect_handler=None, swagger_data=None, validate=None)[source]¶ Returns route
Parameters: - method – as well as in aiohttp
- path – as well as in aiohttp
- handler – as well as in aiohttp and also must be str mymodule.handler
- name – as well as in aiohttp
- expect_handler – as well as in aiohttp
- swagger_data – data http://swagger.io/specification/#operationObject
- validate – bool param for validate in SwaggerValidationRoute
- build – bool param for build extractor and validator
Returns: route for handler
SwaggerRoute¶
-
class
aiohttp_apiset.swagger.route.
SwaggerRoute
(method, handler, resource, *, expect_handler=None, location=None, swagger_data=None)[source]¶ Parameters: - method – as well as in aiohttp
- handler – as well as in aiohttp
- resource – as well as in aiohttp
- expect_handler – as well as in aiohttp
- location – SubLocation instance
- swagger_data – data
-
build_swagger_data
(loader)[source]¶ Prepare data when schema loaded
Parameters: swagger_schema – loaded schema
-
errors_factory
¶ alias of
aiohttp_apiset.exceptions.ValidationError