Skip to content

"schema not type of Schema" error validating object containing a string array #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jwfrankl opened this issue Feb 5, 2021 · 1 comment · Fixed by #286
Closed

"schema not type of Schema" error validating object containing a string array #285

jwfrankl opened this issue Feb 5, 2021 · 1 comment · Fixed by #286
Labels
area/unmarshalling Indicates an issue on unmarshalling area. kind/bug/confirmed

Comments

@jwfrankl
Copy link

jwfrankl commented Feb 5, 2021

I am unable to validate a response that contains an object with a property of a string array. I believe the spec is valid, it validates on the Swagger Editor.

JSON being validated
{"myarray": ["val1", "val2"]}

OpenApi Spec
{ "openapi": "3.0.0", "info": { "description": "Test validator against an array of strings", "title": "Array of strings schema", "version": "1.0" }, "servers": [{ "url": "http://localhost/unitTest" } ], "paths": { "/stringarray": { "get": { "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "allOf": [{ "$ref": "#/components/schemas/stringarrayobject" } ] } } } } } } } }, "components": { "schemas": { "stringarrayobject": { "type": "object", "properties": { "myarray": { "allOf": [{ "$ref": "#/components/schemas/stringarray" } ] } } }, "stringarray": { "type": "array", "items": { "allOf": [{ "maxLength": 255, "type": "string", "description": "Mock content filter" } ] } } } } }

Stack Trace
File "/home/franklij/.pyenv/versions/3.7.0/lib/python3.7/site-packages/openapi_core/validation/response/validators.py", line 33, in validate
data, data_errors = self._get_data(response, operation_response)
File "/home/franklij/.pyenv/versions/3.7.0/lib/python3.7/site-packages/openapi_core/validation/response/validators.py", line 93, in _get_data
data = self._unmarshal(media_type, casted)
File "/home/franklij/.pyenv/versions/3.7.0/lib/python3.7/site-packages/openapi_core/validation/response/validators.py", line 115, in _unmarshal
param_or_media_type, value, context=UnmarshalContext.RESPONSE,
File "/home/franklij/.pyenv/versions/3.7.0/lib/python3.7/site-packages/openapi_core/validation/validators.py", line 53, in _unmarshal
return unmarshaller(value)
File "/home/franklij/.pyenv/versions/3.7.0/lib/python3.7/site-packages/openapi_core/unmarshalling/schemas/unmarshallers.py", line 264, in call
return unmarshaller(value)
File "/home/franklij/.pyenv/versions/3.7.0/lib/python3.7/site-packages/openapi_core/unmarshalling/schemas/unmarshallers.py", line 49, in call
return self.unmarshal(value)
File "/home/franklij/.pyenv/versions/3.7.0/lib/python3.7/site-packages/openapi_core/unmarshalling/schemas/unmarshallers.py", line 169, in unmarshal
return self._unmarshal_object(value)
File "/home/franklij/.pyenv/versions/3.7.0/lib/python3.7/site-packages/openapi_core/unmarshalling/schemas/unmarshallers.py", line 190, in _unmarshal_object
properties = self._unmarshal_properties(value)
File "/home/franklij/.pyenv/versions/3.7.0/lib/python3.7/site-packages/openapi_core/unmarshalling/schemas/unmarshallers.py", line 234, in _unmarshal_properties
prop)(prop_value)
File "/home/franklij/.pyenv/versions/3.7.0/lib/python3.7/site-packages/openapi_core/unmarshalling/schemas/unmarshallers.py", line 264, in call
return unmarshaller(value)
File "/home/franklij/.pyenv/versions/3.7.0/lib/python3.7/site-packages/openapi_core/unmarshalling/schemas/unmarshallers.py", line 148, in call
return list(map(self.items_unmarshaller, value))
File "/home/franklij/.pyenv/versions/3.7.0/lib/python3.7/site-packages/openapi_core/unmarshalling/schemas/unmarshallers.py", line 143, in items_unmarshaller
return self.unmarshallers_factory.create(self.schema.items)
File "/home/franklij/.pyenv/versions/3.7.0/lib/python3.7/site-packages/openapi_core/unmarshalling/schemas/factories.py", line 48, in create
raise TypeError("schema not type of Schema")

@p1c2u p1c2u added area/unmarshalling Indicates an issue on unmarshalling area. kind/bug/confirmed labels Feb 8, 2021
@p1c2u
Copy link
Collaborator

p1c2u commented Feb 8, 2021

@jwfrankl thanks for the report. Spec and schema are valid for sure.
it's an issue with determining type for unmarshaller. Schema type is defined inside allOf schema (stringarray schema) which is not considered in unmarshalling process

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/unmarshalling Indicates an issue on unmarshalling area. kind/bug/confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants