Open SimplicityGuy opened 8 years ago
There is a test case test_swagger_ref_count_04
that I believe is erroneous. There is nothing in the Swagger spec that disallows nested definitions or definitions that refer back onto themselves.
Another reference: https://github.com/swagger-api/swagger-codegen/issues/728
I don't think developers are paying any more attention. You can get around this by first using json-refs (install from npm) to first resolve all refs, and then generate from the resulting json
I believe I have a fix for both this issue and #57. I need to do some more testing on it as it changes a fundamental portion of the parser.
Well, scratch that. That local fix passed unit tests, but failed when running the tool. I'm going to try to address #57 and #62 with looking at #63.
On my own installation I edited parser.py at least to give some debugging information on the source of the circular reference to fix it. Giving a more meaningful error message helped me overcome this problem. Up for a pull request?
I just wanted to add that the solution presented by Nicklas Møller Jepsen, solved the issues for me. I was working with scaffold entities (EF) with circular references and had the problem with freezing Swagger UI. I think Nicklas solution is really neat.
I got a similar problem
/employee/findById:
get:
tags:
- "employee"
summary: "Finds enployee by id"
operationId: "findById"
produces:
- "application/json"
parameters:
- name: "id"
in: "query"
description: "Employee id"
required: true
type: "string"
responses:
200:
description: "successful operation"
schema:
$ref: "#/definitions/Employee"
400:
description: "Invalid status value"
definitions:
Employee:
type: "object"
properties:
id:
type: "integer"
format: "int64"
petId:
type: "integer"
format: "int64"
quantity:
type: "integer"
format: "int32"
shipDate:
type: "string"
format: "date-time"
status:
type: "string"
description: "Order Status"
enum:
- "placed"
- "approved"
- "delivered"
complete:
type: "boolean"
default: false
xml:
name: "Order"
this $ref not avivalid
Other codegen tools support circular references. See https://github.com/swagger-api/swagger-codegen/issues/728.
I this this issue with the following yml:
Exception: