-
-
Notifications
You must be signed in to change notification settings - Fork 136
Closed
Labels
Description
An API definition with recursive models causes a RecursionError when calling create_spec. The definition file does validate though (checked using openapi_spec_validator).
Here is a small working example:
openapi: "3.0.0"
info:
title: "Test API"
version: "1.0.0"
paths:
/help:
get:
summary: "Gets general information about the service"
responses:
default:
description: "Unexpected error"
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
Error:
type: object
properties:
message:
type: string
suberror:
$ref: '#/components/schemas/Error'
yields the following
self.openapi_spec = create_spec(yaml.load(open(openapi_path)))
File "/opt/conda/lib/python3.6/site-packages/openapi_core/shortcuts.py", line 16, in create_spec
return spec_factory.create(spec_dict, spec_url=spec_url)
File "/opt/conda/lib/python3.6/site-packages/openapi_core/specs.py", line 88, in create
components = self.components_factory.create(components_spec)
File "/opt/conda/lib/python3.6/site-packages/openapi_core/components.py", line 37, in create
schemas=list(schemas), responses=responses, parameters=parameters,
File "/opt/conda/lib/python3.6/site-packages/openapi_core/schemas.py", line 245, in generate
schema, _ = self.schemas_registry.get_or_create(schema_spec)
File "/opt/conda/lib/python3.6/site-packages/openapi_core/schemas.py", line 232, in get_or_create
return self.create(schema_deref), True
File "/opt/conda/lib/python3.6/site-packages/openapi_core/schemas.py", line 207, in create
deprecated=deprecated, all_of=all_of,
File "/opt/conda/lib/python3.6/site-packages/openapi_core/schemas.py", line 43, in __init__
self.properties = properties and dict(properties) or {}
...
File "/opt/conda/lib/python3.6/site-packages/openapi_core/schemas.py", line 207, in create
deprecated=deprecated, all_of=all_of,
File "/opt/conda/lib/python3.6/site-packages/openapi_core/schemas.py", line 43, in __init__
self.properties = properties and dict(properties) or {}
File "/opt/conda/lib/python3.6/site-packages/openapi_core/schemas.py", line 164, in generate
schema = self._create_schema(schema_spec)
File "/opt/conda/lib/python3.6/site-packages/openapi_core/schemas.py", line 168, in _create_schema
return SchemaFactory(self.dereferencer).create(schema_spec)
File "/opt/conda/lib/python3.6/site-packages/openapi_core/schemas.py", line 207, in create
deprecated=deprecated, all_of=all_of,
File "/opt/conda/lib/python3.6/site-packages/openapi_core/schemas.py", line 41, in __init__
self.type = schema_type and SchemaType(schema_type)
RecursionError: maximum recursion depth exceeded while calling a Python object