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

All differences are detected only when info.version is equal for compared documents #24

Open
tjuchniewicz opened this issue Mar 8, 2017 · 0 comments

Comments

@tjuchniewicz
Copy link

I use following swagger spec:

{
  "swagger" : "2.0",
  "info" : {
    "version" : "1.0.10",
    "title" : "dummy-service"
  },
  "basePath" : "/",
  "tags" : [ {
    "name" : "multipart-support-service"
  }, {
    "name" : "protocol"
  }, {
    "name" : "protocol-v2"
  } ],
  "paths" : {
    "/protocol/version-2/message-changed" : {
      "post" : {
        "tags" : [ "protocol-v2" ],
        "summary" : "Receive operation for protocol service version 2",
        "description" : "This operation is also very important",
        "operationId" : "IProtocolServiceV2_receive_POST",
        "consumes" : [ "application/json" ],
        "produces" : [ "application/json" ],
        "parameters" : [ {
          "in" : "body",
          "name" : "msg",
          "description" : "message to process as Message object",
          "required" : true,
          "schema" : {
            "$ref" : "#/definitions/Message"
          }
        }, {
          "name" : "User-agent",
          "in" : "header",
          "description" : "User-Agent header parameter",
          "required" : true,
          "type" : "string"
        } ],
        "responses" : {
          "200" : {
            "description" : "successful operation",
            "schema" : {
              "$ref" : "#/definitions/Message"
            }
          },
          "400" : {
            "description" : "Invalid arguments passed"
          },
          "404" : {
            "description" : "Something was not found"
          }
        }
      }
    }
  },
  "definitions" : {
    "Message" : {
      "type" : "object",
      "required" : [ "message", "protocol-type" ],
      "properties" : {
        "message" : {
          "type" : "object",
          "description" : "message to process",
          "additionalProperties" : {
            "type" : "object"
          }
        },
        "protocol-type" : {
          "type" : "string",
          "example" : "OLD",
          "description" : "type of protocol",
          "enum" : [ "OLD", "NEW" ]
        }
      },
      "description" : "message type"
    }
  }
}

then I change /protocol/version-2/message to /protocol/version-2/message-changed to create new file and run following command:
target\node\node.exe target\node_modules\swagger-diff\bin\swagger-diff.js swagger-previous.json target/classes/docs/restapi/swagger-new.json

When versions are the same for both files (1.0.10) the result is as expected:

Errors (2)
delete-path                   /protocol/version-2/message - Deleted
add-path                      /protocol/version-2/message-changed - Added
Warnings (0)

When versions are 1.0.10 (previous) and 1.0.11 (new) the result is:

Errors (1)
delete-path                   /protocol/version-2/message - Deleted
Warnings (1)
add-path                      /protocol/version-2/message-changed - Added

For 1.0.10 and 1.0.11-SNAPSHOT the result is:

Errors (0)
Warnings (0)
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