Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
LazyDict, OrderedLazyDict,
)
except ImportError:
from py_meta_utils import OptionalClass as BaseOpenAPIConverter
from py_meta_utils import OptionalClass as LazyDict
from py_meta_utils import OptionalClass as OrderedLazyDict
try:
from marshmallow.compat import iteritems
from marshmallow.utils import is_collection
except ImportError:
from py_meta_utils import OptionalClass as iteritems
from py_meta_utils import OptionalClass as is_collection
class OpenAPIConverter(BaseOpenAPIConverter):
def fields2jsonschema(self, fields, schema=None, use_refs=True, dump=True, name=None):
"""Return the JSON Schema Object for a given marshmallow
:class:`Schema `. Schema may optionally provide the ``title`` and
``description`` class Meta options.
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#schemaObject
Example: ::
class UserSchema(Schema):
_id = fields.Int()
email = fields.Email(description='email address of the user')
name = fields.Str()
class Meta:
title = 'User'
try:
from apispec.ext.marshmallow.openapi import OpenAPIConverter
openapi = OpenAPIConverter(openapi_version='2.0')
fields2jsonschema = openapi.fields2jsonschema
field2property = openapi.field2property
except ImportError:
from apispec.ext.marshmallow.swagger import fields2jsonschema, field2property
import flask_marshmallow
from werkzeug import cached_property
from flask_restplus.model import Model as OriginalModel
class SchemaMixin(object):
def __deepcopy__(self, memo):
# XXX: Flask-RESTplus makes unnecessary data copying, while
# marshmallow.Schema doesn't support deepcopyng.
# coding: utf-8
import inspect
from flask.views import MethodView
import flasgger
try:
from marshmallow import Schema, fields
from apispec.ext.marshmallow import openapi
from apispec import APISpec as BaseAPISpec
openapi_converter = openapi.OpenAPIConverter(
openapi_version='2.0',
schema_name_resolver=None,
spec=None
)
schema2jsonschema = openapi_converter.schema2jsonschema
schema2parameters = openapi_converter.schema2parameters
except ImportError:
Schema = None
fields = None
schema2jsonschema = lambda schema: {} # noqa
schema2parameters = lambda schema: [] # noqa
BaseAPISpec = object
class APISpec(BaseAPISpec):
"""
import collections
import uuid
import marshmallow
from apispec.ext.marshmallow.openapi import OpenAPIConverter
from marshmallow import fields, ValidationError
from marshmallow.base import FieldABC
from channelstream.server_state import get_state
converter = OpenAPIConverter("2.0.0", schema_name_resolver=lambda: None, spec=None)
MSG_EDITABLE_KEYS = ("uuid", "timestamp", "user", "message", "edited")
try:
base_types = (unicode, basestring)
except NameError:
base_types = (str,)
def gen_uuid():
return uuid.uuid4()
def validate_connection_id(conn_id):
try:
from apispec.ext.marshmallow.openapi import OpenAPIConverter
openapi = OpenAPIConverter(openapi_version='2.0')
schema2parameters = openapi.schema2parameters
except ImportError:
from apispec.ext.marshmallow.swagger import schema2parameters
from flask_restplus.swagger import Swagger as OriginalSwagger
class Swagger(OriginalSwagger):
def parameters_for(self, doc):
schema = doc['params']
if not schema:
return []
if isinstance(schema, list):
return schema