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, 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)
def __init__(self, contentType=DEFAULT_IGNORE, headers=DEFAULT_IGNORE, style=DEFAULT_IGNORE, explode=DEFAULT_IGNORE, allowReserved=DEFAULT_IGNORE): """ Represents OAS3.0 [Encoding Object]() :param contentType: "application/json" or "application/octet-stream" or "text/plain", etc :param headers: a map of headers, that will be returned with this encoding :param style: defines how this specific encoding will be serialized :param explode: should arrays/objects generate seperate params for each entry? :param allowReserved: allow reserved characters """ self.update(locals()) if not self._data: print("Warning ... no values found for encoding") updates = {} if self._data.get('headers', None): updates['headers'] = TypedMapFactory(OASHeaderObject)( self._data['headers']) if self._data.get('style', None) is not None: ensure_allowed({self._data['style']: 1}, style_values) self.update(updates)
def __init__(self, name, _in, _type, description=DEFAULT_IGNORE, **kwargs): ensure_allowed(kwargs, security_kwargs) self.update({ 'name': name, 'in': _in, 'type': _type, 'description': description }) self.update(kwargs)
def __init__(self, description="", deprecated=False, required=True, _type=None, **kwargs): ensure_allowed(kwargs, header_kwargs) self._data = {} self._data.update(kwargs) if description: self._data['description'] = description if deprecated: self._data['deprecated'] = True if required: self._data['required'] = True if _type: self._data.setdefault('schema', {})['type'] = type
def __init__(self, _type, description=DEFAULT_IGNORE, **kwargs): """ allowed_params: 'title','multipleOf','maximum','minimum','exclusiveMaximum','exclusiveMinimum','maxLength','minLength', 'pattern','maxItems','minItems','uniqueItems', 'maxProperties','minProperties','required','enum', 'type','allOf','oneOf','anyOf','not','items','properties','additionalProperties','description', 'format','default','nullable','discriminator','readOnly','writeOnly','xml','externalDocs','example', 'depreciated' :param title: :param multipleOf: :param maximum: :param minimum: :param exclusiveMaximum: :param exclusiveMinimum: :param maxLength: :param minLength: :param pattern: :param maxItems: :param minItems: :param uniqueItems: :param maxProperties: :param minProperties: :param required: :param enum: :param type: :param allOf: :param oneOf: :param anyOf: :param items: :param properties: :param additionalProperties: :param description: :param format: :param default: :param nullable: :param discriminator: :param readOnly: :param writeOnly: :param xml: :param externalDocs: :param example: :param depreciated: """ ensure_allowed(kwargs, schema_kwargs) self.update(kwargs) d = {'type': _type} ensure_allowed( dict.fromkeys(d.values(), 1), allowed_aos_base_types, "Unknown Base OAS Type ERROR: {violating_keys} EXPECTED ONE OF {allowed_values}" ) if description is not DEFAULT_IGNORE: d['description'] = description self.update(d) _type = self._data.get('type', '') if _type.lower() == "object": if not self._data.get('properties', None): print("Warning: Type object, without properties attribute!") # raise TypeError("Cannot assign `object` type to schema, without a `properties` as well") self._data['properties'] = TypedMapFactory(OASSchemaObject)( self._data.get('properties', {})) if _type.lower() == "array": if not self._data.get('items', None): raise TypeError( "Cannot assign `array` type to schema, without an `items` key as well" ) self._data['items'] = OASSchemaObject(**self._data['items']) self.update({"example": guess_example_from_schema(self._data)})