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

Unexpected assertion error with `satisfiesContract()` when impl contains definitions but not design api-doc #28

Closed atsu85 closed 6 years ago

atsu85 commented 6 years ago

Expected behavior

When design api-doc only includes operations of implementation that don't reference any definitions, then

SwaggerAssertions.assertThat(implApiDoc)
                .satisfiesContract(designApiDoc);

shouldn't fail...

Actual behaviour

...but actually currently the test fails with an error having output similar to following:

org.assertj.core.api.SoftAssertionError: 
The following 1 assertions failed:
1) [Checking Definitions] 
Expecting null or empty but was:<{"Category"=io.swagger.models.ModelImpl@511f606d, "Order"=io.swagger.models.ModelImpl@cc70a63c, "Pet"=io.swagger.models.ModelImpl@ca5dccf1, "Tag"=io.swagger.models.ModelImpl@511f606d, "User"=io.swagger.models.ModelImpl@f085099e}>
at ConsumerDrivenValidator.validateDefinitions(ConsumerDrivenValidator.java:100)
atsu85 commented 6 years ago

I created another tiny PR that fixes this issue