How to use the apispec.ext.marshmallow.common 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 tribe29 / checkmk / cmk / gui / plugins / openapi / plugins.py View on Github external
def schema2jsonschema(self, schema):
        if self.openapi_version.major < 3 or not is_value_typed_dict(schema):
            return super(ValueTypedDictOpenAPIConverter, self).schema2jsonschema(schema)

        schema_type = schema.value_type
        schema_instance = common.resolve_schema_instance(schema_type)
        schema_key = common.make_schema_key(schema_instance)
        if schema_key not in self.refs:
            component_name = self.schema_name_resolver(schema_type)
            self.spec.components.schema(component_name, schema=schema_instance)

        ref_dict = self.get_ref_dict(schema_instance)

        return {
            u'type': u'object',
            u'additionalProperties': ref_dict,
        }
github maximdanilchenko / aiohttp-apispec / aiohttp_apispec / aiohttp_apispec.py View on Github external
def resolver(schema):
    schema_instance = common.resolve_schema_instance(schema)
    prefix = "Partial-" if schema_instance.partial else ""
    schema_cls = common.resolve_schema_cls(schema)
    name = prefix + schema_cls.__name__
    if name.endswith("Schema"):
        return name[:-6] or name
    return name
github tribe29 / checkmk / cmk / gui / plugins / openapi / plugins.py View on Github external
def dump(self, obj, many=None, update_fields=True, **kwargs):
        schema = common.resolve_schema_instance(self.value_type)
        result = {}
        for entry in obj:
            part = schema.dump(entry).data
            result[part[self.key_name]] = part
            if not self.keep_key:
                del part[self.key_name]
        return MarshalResult(result, [])
github tribe29 / checkmk / cmk / gui / plugins / openapi / plugins.py View on Github external
def schema2jsonschema(self, schema):
        if self.openapi_version.major < 3 or not is_value_typed_dict(schema):
            return super(ValueTypedDictOpenAPIConverter, self).schema2jsonschema(schema)

        schema_type = schema.value_type
        schema_instance = common.resolve_schema_instance(schema_type)
        schema_key = common.make_schema_key(schema_instance)
        if schema_key not in self.refs:
            component_name = self.schema_name_resolver(schema_type)
            self.spec.components.schema(component_name, schema=schema_instance)

        ref_dict = self.get_ref_dict(schema_instance)

        return {
            u'type': u'object',
            u'additionalProperties': ref_dict,
        }