Skip to content

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

@tjuchniewicz

Description

@tjuchniewicz

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions