def __init__(self,**kwargs):
        """

        :param $ref: a reference to a schema item
        :param ref: alias for $ref
        :param summary: a summary object
        :param description: a description
        :param get:
        :param put:
        :param post:
        :param delete:
        :param options:
        :param head:
        :param patch:
        :param trace:
        :param servers:
        :param parameters:
        """
        ensure_allowed(kwargs,path_kwargs)
        if 'ref' in kwargs:
            if '$ref' not in kwargs:
                kwargs['$ref'] = kwargs.pop('ref')
            else:
                raise TypeError("You can supply ref or $ref but not both!")

            OASReferenceObject.pending_refs.append(kwargs['$ref'])
        else:
            if 'parameters' in kwargs:
                kwargs['parameters'] = [ensure_class(val, OASParameterObject) for val in kwargs['parameters']]
            for method in ['get','put','post','patch','delete','options','head']:
                if method in kwargs:
                    kwargs[method] = ensure_class(kwargs[method],OASOperationObject)

        self._data = {}
        self._data.update(kwargs)
    def __init__(self,responses,description=DEFAULT_IGNORE,
                 summary=DEFAULT_IGNORE, tags=DEFAULT_IGNORE,
                 externalDocs=DEFAULT_IGNORE, operationId=DEFAULT_IGNORE,
                 parameters=DEFAULT_IGNORE, requestBody=DEFAULT_IGNORE,
                 callbacks=DEFAULT_IGNORE, deprecated=DEFAULT_IGNORE,
                 security=DEFAULT_IGNORE, servers=DEFAULT_IGNORE
):
        """

        :param tags:
        :param summary:
        :param description:
        :param externalDocs:
        :param operationId:
        :param parameters:
        :param requestBody:
        :param responses:
        :param callbacks:
        :param deprecated:
        :param security:
        :param servers:
        """
        if parameters is not DEFAULT_IGNORE:
            parameters = [ensure_class(p,OASParameterObject) for p in parameters]
        responses = TypedMapFactory(OASResponseObject)(responses)
        self._data = {}
        self.update(locals())
    def __init__(self,
                 name,
                 _in,
                 _type=None,
                 description=None,
                 deprecated=False,
                 required=True,
                 **kwargs):
        if _type:
            kwargs.setdefault('schema', {})['type'] = _type

        for key, val in list(kwargs.items()):
            if key not in parameter_kwargs and key in schema_kwargs:
                kwargs.setdefault('schema', {})[key] = kwargs.pop(key)

        ensure_allowed(kwargs, parameter_kwargs)
        if 'schema' in kwargs:
            kwargs['schema'] = ensure_class(kwargs['schema'], OASSchemaObject)
        self.update({
            'description': description,
            'name': name,
            'deprecated': deprecated,
            'required': required,
            'in': _in
        })
        self.update(kwargs)
        if self._data.get('style', None):
            err_msg = "Unknown Style: {violating_keys} expected one of {allowed_values}"
            ensure_allowed({self._data['style']: 1}, style_values, err_msg)
Example #4
0
 def __init__(self,info,paths,servers=None,components=None,security=None,tags=None,externalDocs=None):
     data = {
         "openapi": "3.0.0",
         "info": ensure_class(info,OASInfoObject),
         "paths": TypedMapFactory(OASPathItemObject)(paths)
     }
     if tags:
         data['tags'] = TypedListFactory(OASTagDefinitionObject)(tags)
     if servers:
         data['servers'] = [ensure_class(server,OASServerObject) for server in servers]
     if components:
         data['components'] = ensure_class(components,)
     if self.security:
         data['security'] = self.security.to_dict()
     if self.externalDocs:
         data['externalDocs'] = self.externalDocs.toDict()
     self._data = data
 def __init__(self,
              schemas=DEFAULT_IGNORE,
              responses=DEFAULT_IGNORE,
              parameters=DEFAULT_IGNORE,
              examples=DEFAULT_IGNORE,
              requestBodies=DEFAULT_IGNORE,
              headers=DEFAULT_IGNORE,
              securitySchemes=DEFAULT_IGNORE,
              links=DEFAULT_IGNORE,
              callbacks=DEFAULT_IGNORE):
     """
     >>> OASComponentsSection(schemas="ASD")
     :param schemas:
     :param responses:
     :param parameters:
     :param examples:
     :param requestBodies:
     :param headers:
     :param securitySchemes:
     :param links:
     :param callbacks:
     """
     self._data = {}
     q = {k: v for k, v in locals().items() if k not in ('self', 'cls')}
     self.update(q)
     if schemas:
         self._data['schemas'] = {
             k: ensure_class(v, OASSchemaObject)
             for k, v in schemas.items()
         }
     if responses:
         self._data['responses'] = {
             k: ensure_class(v, OASResponseObject)
             for k, v in responses.items()
         }
     if parameters:
         self._data['parameters'] = {
             k: ensure_class(v, OASParameterObject)
             for k, v in parameters.items()
         }
     if examples:
         self._data['examples'] = {
             k: ensure_class(v, OASExampleObject)
             for k, v in examples.items()
         }
     if requestBodies:
         self._data['requestBodies'] = {
             k: ensure_class(v, OASRequestBodyObject)
             for k, v in requestBodies.items()
         }
     if headers:
         self._data['headers'] = {
             k: ensure_class(v, OASHeaderObject)
             for k, v in headers.items()
         }
     if securitySchemes:
         self._data['securitySchemes'] = {
             k: ensure_class(v, )
             for k, v in securitySchemes.items()
         }
    def __init__(self, description, content=None, headers=None, links=None):
        links = links or {}
        headers = headers or {}

        if not isinstance(content, dict) or set(
                content.keys()).intersection(mediaType_kwargs):
            content = {"*": ensure_class(content, OASMediaTypeObject)}
        elif isinstance(content, dict):
            for key in content:
                content[key] = ensure_class(content[key], OASMediaTypeObject)
        self._data = {
            'description': description,
            'links': {
                key: ensure_class(lnk, OASLinkObject)
                for key, lnk in links.items()
            },
            'content': content,
            'headers': {
                key: ensure_class(hdr, OASHeaderObject)
                for key, hdr in headers.items()
            },
        }
    def __init__(self,
                 schema=DEFAULT_IGNORE,
                 example=DEFAULT_IGNORE,
                 examples=DEFAULT_IGNORE,
                 encoding=DEFAULT_IGNORE):
        """

        :param schema:
        :param example: an example of this media type, it should be in the correct format
        :param examples:
        :param encoding:
        """
        self.update(locals())
        if self._data.get('examples'):
            self._data['examples'] = TypedMapFactory(
                UnionTypeFactory(OASExampleObject, OASReferenceObject,
                                 str))(examples)
        if self._data.get('encoding'):
            self._data['encoding'] = ensure_class(encoding, OASEncodingObject)
    def __init__(self,
                 operationRef=None,
                 operationId=None,
                 parameters=None,
                 requestBody=None,
                 description=None,
                 server=None):
        """
        represents OAS3.0 [Link Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#link-object)

        must include one of operationRef, or operationId

        :param operationRef: a relative or absolute reference to an OAS operation(exclusive to operationID)
        :param operationId: an *existing*, resolveable OAS operation (exclusive to operationRef)
        :param parameters: a dict of key,value maping to pass to the specified operation
        :type parameters: Dict[str,str]
        :param requestBody: a literal string or {expression} to use as the request body
        :param description: a description of this link
        :param server: a server object to be used by the target operation
        """
        if operationRef and operationId:
            raise TypeError(
                "You MUST not include BOTH operationRef and operationId! only one of the TWI"
            )
        if not operationRef and not operationId:
            raise TypeError(
                "You MUST include EITHER operationRef OR operationId!(...but not both!)"
            )
        self._data = {}
        if operationRef:
            self._data['operationRef'] = operationRef
        if operationId:
            self._data['operationId'] = operationId
        if parameters:
            self._data['parameters'] = parameters
        if requestBody:
            self._data['requestBody'] = requestBody
        if description:
            self._data['description'] = description
        if server:
            self._data['server'] = ensure_class(server, OASServerObject)
 def ensure_operation(p):
     return ensure_class(p,OASOperationObject)
Example #10
0
 def __init__(self,name,description=None,externalDocs=None):
     self._data = {'name':name}
     if description:
         self._data['description'] = description
     if externalDocs:
         self._data['externalDocs'] = ensure_class(externalDocs,OASExternalDocumentationObject)