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

Handle circular references #2831

Closed
zmay2030 opened this issue Sep 8, 2022 · 0 comments
Closed

Handle circular references #2831

zmay2030 opened this issue Sep 8, 2022 · 0 comments

Comments

@zmay2030
Copy link
Contributor

zmay2030 commented Sep 8, 2022

Problem statement

When you have a circular reference, the swagger DIFF command goes into an infinite loop. I think this is something to be supported because below is perfectly valid in Go

type A1 struct {
 id int
 name string
 a1 *A1
}

Steps to reproduce

spec_1.json

{
  "swagger": "2.0",
  "info": {
    "title": "Swagger Fixture",
    "version": "1.0"
  },
  "paths": {
    "/a/": {
      "get": {
        "parameters": [
          {
            "name": "",
            "in": "body",
            "schema": { "$ref": "#/definitions/A1" }
          }
        ],
        "responses": {
          "200": {
            "description": "200 response",
            "schema": {
              "type": "array",
              "items": { "$ref": "#/definitions/A1" }
            }
          }
        }
      }
    }
  },
  "definitions": {
    "A1": {
      "type": "object",
      "properties": {
        "id": { "type": "integer" },
        "name": { "type": "string" },
        "a1":{ "$ref": "#/definitions/A1" }
      }
    }
  }
}

spec_2.json
You can just use the same one above

Then Run swagger diff spec_1.json spec_2.json. It will never stop.

Environment

swagger version: 2.0
go version: 1.18
OS: Mac Monterey

zmay2030 pushed a commit to zmay2030/go-swagger that referenced this issue Sep 8, 2022
casualjim pushed a commit to zmay2030/go-swagger that referenced this issue Sep 9, 2022
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