class ItemPutRequest: id = doc.Integer() # Ignored in favor of URL brand = doc.String() name = doc.String(required=True) item_size = doc.Float(required=True) unit = doc.String(required=True) count = doc.Float(required=True) serving = doc.Float() category = doc.String() subcategory = doc.String() expiration_date = doc.Date() purchase_date = doc.Date() created_at = doc.DateTime() deleted_at = doc.DateTime() inventory_id = doc.Integer(required=True)
class ItemPostRequest: brand = doc.String() name = doc.String(required=True) item_size = doc.Float(required=True) unit = doc.String(required=True) count = doc.Float(required=True) category = doc.String() subcategory = doc.String() expiration_date = doc.Date()
class ExposureDetectionSummary: """ Documentation class for the exposure_detection_summaries' entries. """ date = doc.Date(required=True) matched_key_count = doc.Integer(required=True) days_since_last_exposure = doc.Integer(required=True) attenuation_durations = doc.List(int, required=True) maximum_risk_score = doc.Integer(required=True) exposure_info = doc.List(ExposureInfo, required=True)
class ExposureInfo: """ Documentation class for the exposure info's entries. """ date = doc.Date(required=True) duration = doc.Integer(required=True) attenuation_value = doc.Integer(required=True) attenuation_durations = doc.List(int, required=True) transmission_risk_level = doc.Integer(required=True) total_risk_score = doc.Integer(required=True)
class Video: id = doc.Integer() description_path = doc.String() ext = doc.String() poster_path = doc.String() source_id = doc.String() title = doc.String() upload_date = doc.Date() video_path = doc.String() name = doc.String() caption_path = doc.String() idempotency = doc.String() info_json_path = doc.String() channel_id = doc.Integer()
class ExampleModel: """ Example domain object documentation that is used in swagger definition """ field_a = doc.Float(description="field a description") field_b = doc.Integer(description="field b description") field_c = doc.Date(description="field c description") field_d = doc.Boolean(description="field d description") field_e = doc.String(description="field e description") def _validation_schema(self): return { 'field_a': {'type': 'float', 'required': True, 'empty': False}, 'field_b': {'type': 'int', 'required': True, 'empty': False}, 'field_c': {'type': 'str', 'required': True, 'empty': False}, 'field_d': {'type': 'bool', 'required': True, 'empty': False}, 'field_e': {'type': 'str', 'required': True, 'empty': False}, }
def test_date_field(app): field = doc.Date() assert field.serialize() == {"type": "string", "format": "date"} @app.get("/") @doc.consumes(field, location="body", required=True) def test(request): return text("test") _, response = app.test_client.get("/swagger/swagger.json") assert response.status == 200 assert response.content_type == "application/json" swagger_json = response.json path = swagger_json["paths"]["/"]["get"] assert path["parameters"][0] == { "required": True, "in": "body", "name": None, "type": "string", "format": "date", }
(doc.Field(), {}), (int, {"type": "integer", "format": "int64"}), (doc.Integer, {"type": "integer", "format": "int64"}), (doc.Integer(), {"type": "integer", "format": "int64"}), (float, {"type": "number", "format": "double"}), (doc.Float, {"type": "number", "format": "double"}), (doc.Float(), {"type": "number", "format": "double"}), (str, {"type": "string"}), (doc.String, {"type": "string"}), (doc.String(), {"type": "string"}), (bool, {"type": "boolean"}), (doc.Boolean, {"type": "boolean"}), (doc.Boolean(), {"type": "boolean"}), (date, {"type": "string", "format": "date"}), (doc.Date, {"type": "string", "format": "date"}), (doc.Date(), {"type": "string", "format": "date"}), (datetime, {"type": "string", "format": "date-time"}), (doc.DateTime, {"type": "string", "format": "date-time"}), (doc.DateTime(), {"type": "string", "format": "date-time"}), (TestSchema, {"$ref": "#/definitions/TestSchema"}), (dict, {"type": "object", "properties": {}}), ({"foo": "bar"}, {"type": "object", "properties": {"foo": {}}}), (list, {"type": "array", "items": []}), (["foo", "bar"], {"type": "array", "items": {"description": ["foo", "bar"]}}), ], ) def test_serialize_schema(schema, expected_schema): serialized_schema = doc.serialize_schema(schema) assert serialized_schema == expected_schema
class consumes: title = doc.String("lock title for public") description = doc.String("description only for admin") lock_until = doc.Date("YYYY-MM-DD") no_update = doc.Boolean("Should do switch_update(dev only)")
class consumes: unlock_date = doc.Date( "Set unlock date. if not provided will unlock immediately")
class GetResponseEntry: id = doc.Integer("The id of the entry.") uri = doc.String("Uri of the web ID of the entry") lblod_id = doc.String("Uri of the lblod id of this entry.") date_created = doc.Date( "The date on which the entry was added to the database.")
}), (doc.Boolean, { "type": "boolean" }), (doc.Boolean(), { "type": "boolean" }), (date, { "type": "string", "format": "date" }), (doc.Date, { "type": "string", "format": "date" }), (doc.Date(), { "type": "string", "format": "date" }), (datetime, { "type": "string", "format": "date-time" }), (doc.DateTime, { "type": "string", "format": "date-time" }), (doc.DateTime(), { "type": "string", "format": "date-time" }),