Skip to content

Rule 1034: AddedRequiredProperty is not raised consistently but depends on order of the paths in the spec #59

Closed
@kristofferpagels

Description

@kristofferpagels

Hi,

We are using the openapi-comparator NuGet to test for breaking changes in our api and its doing a fine job at that. But we have seen a case we don't understand, and have spent some time investigating it.

The problem occurs if we introduce a required property on an object used in a response.

I have attached four json files

We get the following difference for rule 1034 when comparing the two first json documents (old2.json and new2.json) with the following paths

  1. /api/v1/public/productContent
  2. /api/public/form
Rule Error JsonPath
1034 The new version has new required property 'testNotNullableProperty' that was not found in the old version. #/paths/~1api~1public~1productContent/get/responses/200/content/application~1json/schema

This is as expected as a new required property has been added to the response object. However if we change the order of the paths (see old2a.json and new2a.json). I.e. we change the order of the paths:

  1. /api/public/form
  2. /api/v1/public/productContent

Now we still get the same difference, but we also get a second one from the schema comparison

Rule Error JsonPath
1034 The new version has new required property 'testNotNullableProperty' that was not found in the old version. #/paths/~1api~1public~1productContent/get/responses/200/content/application~1json/schema
1034 The new version has new required property 'testNotNullableProperty' that was not found in the old version. #/components/schemas/ContentModel

I would assume that this second rule difference is wrong as we already have it for the response object, but at least the rule differences should not depend on the order of the paths.

/Regards
Kristoffer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions