Skip to content

"swagger diff" does not work with spec that has a recursive definition #2774

@tka

Description

@tka

Problem statement

When Swagger doc has a recursive definition, the swagger diff command seem to enter an infinite loop.

Swagger specification

{
  "swagger": "2.0",
  "info": {
    "description": "",
    "version": "1.0.0",
    "title": "test"
  },
  "host": "test.example.com",
  "basePath": "/",
  "schemes": [
    "https"
  ],
  "paths": {
    "/categories": {
      "get": {
        "tags": [
          "categories"
        ],
        "summary": "get all categories",
        "description": "",
        "produces": [
          "application/xml",
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "successful operation",
            "schema": {
              "$ref": "#/definitions/Category"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "Category": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer",
          "format": "int64"
        },
        "name": {
          "type": "string"
        },
        "subCategories": {
          "$ref": "#/definitions/Category"
        }
      },
      "xml": {
        "name": "Category"
      }
    }
  }

}

Steps to reproduce

  1. save the spec above to old.json
  2. save the spec above to new.json
  3. run command swagger old.json new.json

expect the result is no change, but the command never completed

Environment

swagger version: v0.29.0
go version: 1.18.1
OS: Arch Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdiffRelates to the swagger diff command

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions