def __init__(
     self,
     version="1.0.0",
     title="My API",
     description="",
     query_string_converter_registry=None,
     request_body_converter_registry=None,
     headers_converter_registry=None,
     response_converter_registry=None,
     tags=None,
     servers=None,
     default_response_schema=Error(),
     authenticator_converter_registry=None,
 ):
     super(SwaggerV3Generator, self).__init__(
         openapi_major_version=3,
         version=version,
         title=title,
         description=description,
         default_response_schema=default_response_schema,
         query_string_converter_registry=query_string_converter_registry,
         request_body_converter_registry=request_body_converter_registry,
         headers_converter_registry=headers_converter_registry,
         response_converter_registry=response_converter_registry,
         authenticator_converter_registry=authenticator_converter_registry,
     )
     self.tags = tags
     self.servers = servers
     self._ref_base = "#/components/schemas"
 def __init__(
     self,
     host="swag.com",
     schemes=(),
     consumes=("application/json",),
     produces=("application/json",),
     version="1.0.0",
     title="My API",
     description="",
     query_string_converter_registry=None,
     request_body_converter_registry=None,
     headers_converter_registry=None,
     response_converter_registry=None,
     tags=None,
     default_response_schema=Error(),
 ):
     super(SwaggerV2Generator, self).__init__(
         openapi_major_version=2,
         version=version,
         title=title,
         description=description,
         default_response_schema=default_response_schema,
         query_string_converter_registry=query_string_converter_registry,
         request_body_converter_registry=request_body_converter_registry,
         headers_converter_registry=headers_converter_registry,
         response_converter_registry=response_converter_registry,
     )
     self.host = host
     self.schemes = schemes
     self.consumes = consumes
     self.produces = produces
     self.tags = tags
     self._ref_base = "#/definitions"
Esempio n. 3
0
    def __init__(
            self,
            host='swag.com',
            schemes=('http',),
            consumes=('application/json',),
            produces=('application/vnd.plangrid+json',),
            version='1.0.0',
            title='My API',
            description='',
            query_string_converter_registry=None,
            request_body_converter_registry=None,
            headers_converter_registry=None,
            response_converter_registry=None,

            # TODO Still trying to figure out how to get this from the registry
            # Flask error handling doesn't mesh well with Swagger responses,
            # and I'm trying to avoid building our own layer on top of Flask's
            # error handlers.
            default_response_schema=Error()
    ):
        self.host = host
        self.schemes = schemes
        self.consumes = consumes
        self.produces = produces
        self.title = title
        self.description = description
        self.version = version

        self._query_string_converter = (
            query_string_converter_registry
            or global_query_string_converter_registry
        ).convert
        self._request_body_converter = (
            request_body_converter_registry
            or global_request_body_converter_registry
        ).convert
        self._headers_converter = (
            headers_converter_registry
            or global_headers_converter_registry
        ).convert
        self._response_converter = (
            response_converter_registry
            or global_response_converter_registry
        ).convert

        self.flask_converters_to_swagger_types = {
            'uuid': sw.string,
            'uuid_string': sw.string,
            'string': sw.string,
            'int': sw.integer,
            'float': sw.number
        }

        self.authenticator_converters = {
            HeaderApiKeyAuthenticator: _convert_header_api_key_authenticator
        }

        self.default_response_schema = default_response_schema
Esempio n. 4
0
    def __init__(
        self,
        host="swag.com",
        schemes=(),
        consumes=("application/json",),
        produces=("application/json",),
        version="1.0.0",
        title="My API",
        description="",
        query_string_converter_registry=None,
        request_body_converter_registry=None,
        headers_converter_registry=None,
        response_converter_registry=None,
        tags=None,
        # TODO Still trying to figure out how to get this from the registry
        # Flask error handling doesn't mesh well with Swagger responses,
        # and I'm trying to avoid building our own layer on top of Flask's
        # error handlers.
        default_response_schema=Error(),
    ):
        self.host = host
        self.schemes = schemes
        self.consumes = consumes
        self.produces = produces
        self.title = title
        self.description = description
        self.version = version
        self.tags = tags

        self._query_string_converter = (
            query_string_converter_registry or global_query_string_converter_registry
        ).convert
        self._request_body_converter = (
            request_body_converter_registry or global_request_body_converter_registry
        ).convert
        self._headers_converter = (
            headers_converter_registry or global_headers_converter_registry
        ).convert
        self._response_converter = (
            response_converter_registry or global_response_converter_registry
        ).convert

        self.flask_converters_to_swagger_types = {
            "uuid": sw.string,
            "uuid_string": sw.string,
            "string": sw.string,
            "path": sw.string,
            "int": sw.integer,
            "float": sw.number,
        }

        self.authenticator_converters = {
            HeaderApiKeyAuthenticator: _convert_header_api_key_authenticator
        }

        self.default_response_schema = default_response_schema
Esempio n. 5
0
    def __init__(
        self,
        openapi_major_version,
        version="1.0.0",
        title="My API",
        description="",
        query_string_converter_registry=None,
        request_body_converter_registry=None,
        headers_converter_registry=None,
        response_converter_registry=None,
        default_response_schema=Error(),
        authenticator_converter_registry=None,
        include_hidden=False,
    ):
        self.include_hidden = include_hidden
        self.title = title
        self.version = version
        self.description = description
        self._query_string_converter = self._create_converter(
            query_string_converter_registry,
            global_query_string_converter_registry,
            openapi_major_version,
        )
        self._request_body_converter = self._create_converter(
            request_body_converter_registry,
            global_request_body_converter_registry,
            openapi_major_version,
        )
        self._headers_converter = self._create_converter(
            headers_converter_registry,
            global_headers_converter_registry,
            openapi_major_version,
        )
        self._response_converter = self._create_converter(
            response_converter_registry,
            global_response_converter_registry,
            openapi_major_version,
        )

        self.flask_converters_to_swagger_types = {
            "uuid": sw.string,
            "uuid_string": sw.string,
            "string": sw.string,
            "path": sw.string,
            "int": sw.integer,
            "float": sw.number,
        }

        self.authenticator_converter = self._create_authenticator_converter(
            authenticator_converter_registry,
            global_authenticator_converter_registry,
            openapi_major_version,
        )

        self.default_response_schema = default_response_schema