Circular reference is considered an errorSee original GitHub issue
When you have a yaml model that reference itself, the
validate function consider it an error, which is not. It is completely supported by tools like swagger-editor and swagger-codegen.
I’m using the latest release on npm (1.0.1).
To reproduce, use the petstore and add this in the definition part:
MenuItemDescription: type: string description: "List of all menu item descriptions" enum: - Choice1 - Choice2 - Choice3 MenuItem: type: object description: "Item in a menu" required: - description - childMenuItems properties: description: $ref: "#/definitions/MenuItemDescription" childMenuItems: type: array items: $ref: "#/definitions/MenuItem"
The error is as follow:
Swagger schema validation failed. Expected type object but found type string at #/definitions/$ref JSON_OBJECT_VALIDATION_FAILED
- Created 5 years ago
- Comments:15 (3 by maintainers)
Top GitHub Comments
It seems there isn’t solution but better error description, at least for
swagger-cli bundle -r:
Circular $ref pointer found at /Users/name/go/src/github.com/repo/docs/myModel.yaml#/properties/elements/items
myModel: properties: elements: items: $ref: "./myModel.yaml" type: array x-go-name: Elements
swagger-cli validate gives
swagger.yaml is valid
Hello, I have found this thread today when I was searching for exactly this problem. I am getting exactly the same results as @eugene-rockspoon metioned. Funny fact I can validate my openApi.yaml spec locally (without error), but we are using it in gitlab CI and it fails. The version of swagger-cli is exactly the same in both enviroments (4.0.4). So this problem is still actual and I think it has to be resolved.