How to use the apispec.ext.marshmallow.swagger.schema2parameters function in apispec

To help you get started, we’ve selected a few apispec examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marshmallow-code / apispec / tests / test_ext_marshmallow.py View on Github external
def test_schema_global_state_untouched_2parameters(self):
        assert RunSchema._declared_fields['sample']._Nested__schema is None
        data = swagger.schema2parameters(RunSchema)
        json.dumps(data)
        assert RunSchema._declared_fields['sample']._Nested__schema is None
github plainas / flask-swagger-types / flaskswaggertypes.py View on Github external
def _endpoint_schemas2swagger_parameters(self, endpoint_schemas):
        parameters = []
        if 'path' in endpoint_schemas:
            parameters += schema2parameters(endpoint_schemas['path'], default_in="path")

        if 'query' in endpoint_schemas:
            parameters += schema2parameters(endpoint_schemas['query'], default_in="query") 

        if 'header' in endpoint_schemas:
            parameters += schema2parameters(endpoint_schemas['header'], default_in="header")

        if 'body' in endpoint_schemas:            
            parameters += [{
                'in' : 'body',
                'name': 'body',
                'required': True,
                'schema' : {'$ref': "#/definitions/" + endpoint_schemas['body'].__name__ }
            }]

        return parameters
github plainas / flask-swagger-types / flaskswaggertypes.py View on Github external
def _generate_swagger_definitions_tree(self):
        definitions = {}
        for schema in self.swagger_definition_schemas:
            definitions[schema.__name__] = schema2parameters(schema)[0]['schema']
        return definitions
github frol / flask-restplus-server-example / flask_restplus_patched / swagger.py View on Github external
def parameters_for(self, doc):
        schema = doc['params']

        if not schema:
            return []
        if isinstance(schema, list):
            return schema
        if isinstance(schema, dict) and all(isinstance(field, dict) for field in schema.values()):
            return list(schema.values())

        if 'in' in schema.context and 'json' in schema.context['in']:
            default_location = 'body'
        else:
            default_location = 'query'
        return schema2parameters(schema, default_in=default_location, required=True)
github plainas / flask-swagger-types / flaskswaggertypes.py View on Github external
def _endpoint_schemas2swagger_parameters(self, endpoint_schemas):
        parameters = []
        if 'path' in endpoint_schemas:
            parameters += schema2parameters(endpoint_schemas['path'], default_in="path")

        if 'query' in endpoint_schemas:
            parameters += schema2parameters(endpoint_schemas['query'], default_in="query") 

        if 'header' in endpoint_schemas:
            parameters += schema2parameters(endpoint_schemas['header'], default_in="header")

        if 'body' in endpoint_schemas:            
            parameters += [{
                'in' : 'body',
                'name': 'body',
                'required': True,
                'schema' : {'$ref': "#/definitions/" + endpoint_schemas['body'].__name__ }
            }]

        return parameters
github joeyorlando / flask-restplus-marshmallow / flask_restplus_marshmallow / swagger.py View on Github external
def parameters_for(self, doc):
        schema = doc['params']

        if not schema:
            return []
        if isinstance(schema, list):
            return schema
        if isinstance(schema, dict) and all(isinstance(field, dict) for field in schema.values()):
            return list(schema.values())

        if 'in' in schema.context and 'json' in schema.context['in']:
            default_location = 'body'
        else:
            default_location = 'query'
        return schema2parameters(schema, default_in=default_location, required=True)