Skip to content

[BUG]: recursive schema definition not work #91

@thaichat04

Description

@thaichat04

Describe the bug
A schema with recursive definition raised error

To Reproduce
Steps to reproduce the behavior:

  1. Using sample schema as follow with recursive structure, allowed by spec:
    "definitions": { "models.Equipment": { "title": "Equipment", "type": "object", "properties": { "Features": { "type": "array", "items": { "$ref": "#/definitions/models.Feature" } }, "Id": { "type": "integer", "format": "int64" }, "IdType": { "type": "string" }, "Name": { "type": "string" }, "Price": { "type": "integer", "format": "int32" } } }, "models.Feature": { "title": "Feature", "type": "object", "properties": { "Equipments": { "type": "array", "items": { "$ref": "#/definitions/models.Equipment" } }, "Id": { "type": "integer", "format": "int64" }, "IdFeature": { "$ref": "#/definitions/models.Feature" }, "Name": { "type": "string" } } } }

Expected behavior
Schema must be accepted, but there's error:
openapi_parser.errors.ParserError: OpenAPI file parsing error: Recursion reached limit of 1 trying to resolve "file:///Users/nguyenh/Downloads/recursive_schema.json#/definitions/models.Feature"! file:///Users/nguyenh/Downloads/recursive_schema.json#/definitions/models.Feature file:///Users/nguyenh/Downloads/recursive_schema.json#/definitions/models.Equipment file:///Users/nguyenh/Downloads/recursive_schema.json#/definitions/models.Feature

System details (please complete the following information):

  • OS: [e.g. Windows 11, macOS 12.4, etc]
  • OpenAPI / Swagger version [e.g. OpenAPI 2]
  • Python version [e.g. 12]

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghelp wantedExtra attention is neededinvalidThis doesn't seem right

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions