RobWin / assertj-swagger

A Swagger assertj test library which compares a contract-first Swagger YAML/JSON file with a code-first Swagger JSON
Apache License 2.0
171 stars 44 forks source link

Different parameter description should not cause ConsumerDrivenValidator to fail #40

Open alansegar opened 6 years ago

alansegar commented 6 years ago

From v0.7.0 a change in behaviour was introduced by PR https://github.com/RobWin/assertj-swagger/pull/25 which fixes issue #24 . Prior to v0.7.0 a difference between the description on a parameter would not cause a failure. This change isn't an essential part of the fix for issue #24 and I don't believe it was intentional.

    "parameters": [
                    {
                        "in": "path",
                        "name": "petId",
                        "description": "ID of pet that needs to be fetched",
                        "required": true,
                        "type": "integer",
                        "format": "int64"
                    }
                ]
                "parameters": [
                    {
                        "in": "path",
                        "name": "petId",
                        "description": "Deliberately different description text",
                        "required": true,
                        "type": "integer",
                        "format": "int64"
                    }
                ]

The use of contains and equals in v0.7.0 caused all attributes to be compared rather than just name. According to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameterObject

A unique parameter is defined by a combination of a name and location.

so I've used name and location (in) rather than just name. This fixes #24 without any side effects. I've created a PR https://github.com/RobWin/assertj-swagger/pull/39 for the fix. I used the v0.6.0 code as a base for this fix https://github.com/RobWin/assertj-swagger/blob/v0.6.0/src/main/java/io/github/robwin/swagger/test/ConsumerDrivenValidator.java#L240

That made me notice that https://github.com/RobWin/assertj-swagger/blob/master/src/main/java/io/github/robwin/swagger/test/ConsumerDrivenValidator.java#L305 doesn't validate some other attributes on path parameters . I think it makes sense to ignore differences in description text, but it may make sense to validate some of the others e.g. format, required , etc