Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested self reference to a definition, results in circular dependency error #117

Open
abatilo opened this issue Aug 17, 2018 · 0 comments
Open

Comments

@abatilo
Copy link

abatilo commented Aug 17, 2018

The YAML in question

  Person:
    required:
      - name
      - children
    properties:
      name:
        type: string
      children:
        type: array
        items:
          $ref: '#/definitions/Person'

I believe my issue is similar to #62

Trying to generate code from a model definition such as above will result in the following error:

ValueError: $ref circular references found!

Full yaml:

swagger: '2.0'
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT
host: petstore.swagger.io
basePath: "/v1"
schemes:
- http
consumes:
- application/json
produces:
- application/json
paths:
  "/persons":
    get:
      summary: List all persons
      operationId: listPersons
      tags:
      - persons
      responses:
        '200':
          description: An paged array of persons
          schema:
            "$ref": "#/definitions/Person"
        default:
          description: unexpected error
          schema:
            "$ref": "#/definitions/Error"
    post:
      summary: Add a person
      operationId: addPerson
      tags:
      - persons
      parameters:
      - in: body
        name: body
        required: true
        schema:
          "$ref": "#/definitions/Person"
      responses:
        '201':
          description: person was created
          schema:
            "$ref": "#/definitions/Person"
        default:
          description: unexpected error
          schema:
            "$ref": "#/definitions/Error"
definitions:
  Person:
    required:
    - name
    - children
    properties:
      name:
        type: string
      children:
        type: array
        items:
          "$ref": "#/definitions/Person"
  Error:
    required:
    - code
    - message
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string

However, if I run the same yaml through swagger-codegen, valid Python code is generated.

This was referenced Aug 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant