From d87b60ade76c7e23288f23759da1f64ebc7b62a9 Mon Sep 17 00:00:00 2001 From: Artur Maciag Date: Wed, 30 May 2018 09:41:34 +0100 Subject: [PATCH] Schema format accepts any value --- openapi_core/schema/schemas/models.py | 4 ++-- tests/integration/data/v3.0/petstore.yaml | 1 + tests/integration/test_petstore.py | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/openapi_core/schema/schemas/models.py b/openapi_core/schema/schemas/models.py index d9f1c66..624839c 100644 --- a/openapi_core/schema/schemas/models.py +++ b/openapi_core/schema/schemas/models.py @@ -6,7 +6,7 @@ import warnings from six import iteritems from openapi_core.extensions.models.factories import ModelFactory -from openapi_core.schema.schemas.enums import SchemaType, SchemaFormat +from openapi_core.schema.schemas.enums import SchemaType from openapi_core.schema.schemas.exceptions import ( InvalidSchemaValue, UndefinedSchemaProperty, MissingSchemaProperty, OpenAPISchemaError, NoOneOfSchema, MultipleOneOfSchema, @@ -33,7 +33,7 @@ class Schema(object): self.model = model self.properties = properties and dict(properties) or {} self.items = items - self.format = SchemaFormat(schema_format) + self.format = schema_format self.required = required or [] self.default = default self.nullable = nullable diff --git a/tests/integration/data/v3.0/petstore.yaml b/tests/integration/data/v3.0/petstore.yaml index 7afd071..d788ebb 100644 --- a/tests/integration/data/v3.0/petstore.yaml +++ b/tests/integration/data/v3.0/petstore.yaml @@ -259,6 +259,7 @@ components: properties: name: type: string + format: custom TagList: type: array items: diff --git a/tests/integration/test_petstore.py b/tests/integration/test_petstore.py index e9bd86a..b3ed51d 100644 --- a/tests/integration/test_petstore.py +++ b/tests/integration/test_petstore.py @@ -136,7 +136,7 @@ class TestPetstore(object): assert type(parameter.schema) == Schema assert parameter.schema.type.value ==\ schema_spec['type'] - assert parameter.schema.format.value ==\ + assert parameter.schema.format ==\ schema_spec.get('format') assert parameter.schema.required == schema_spec.get( 'required', []) @@ -171,7 +171,7 @@ class TestPetstore(object): assert type(media_type.schema) == Schema assert media_type.schema.type.value ==\ schema_spec['type'] - assert media_type.schema.format.value ==\ + assert media_type.schema.format ==\ schema_spec.get('format') assert media_type.schema.required == schema_spec.get( 'required', False) @@ -690,7 +690,7 @@ class TestPetstore(object): assert parameters == {} assert body is None - data_json = [] + data_json = ['cats', 'birds'] data = json.dumps(data_json) response = MockResponse(data)