openapi3-parser icon indicating copy to clipboard operation
openapi3-parser copied to clipboard

[BUG]: recursive schema definition not work

Open thaichat04 opened this issue 1 year ago • 15 comments

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]

thaichat04 avatar Nov 04 '24 11:11 thaichat04