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

Rule 1034: AddedRequiredProperty does not support requests with oneOf syntax. #60

Open
kristofferpagels opened this issue Feb 4, 2025 · 0 comments

Comments

@kristofferpagels
Copy link

Hi,

We have an api generated by NSwag and it is using oneOf to define requests, but that doesn't seem to be recognized by openapi-comparator.

Example:

"requestBody": {
          "x-name": "request",
          "content": {
            "application/json": {
              "schema": {
                "nullable": false,
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/TicketPostRequest"
                  }
                ]
              }
            }
          }

vs without oneOf (manually created)

"requestBody": {
          "x-name": "request",
          "content": {
            "application/json": {
              "schema": {
                 "$ref": "#/components/schemas/TicketPostRequest"
              }
            }
          },
          "required": true,
          "x-position": 1
        }

I have attached four json documents

When comparing old3.json and new3.json (which is using oneOf and have introduced a required property in a request object) we get the following rule difference for 1034:

Rule Error JsonPath
1034 The new version has new required property 'testNullableProperty' that was not found in the old version. #/components/schemas/TicketPostRequest

If we change to directly referencing the schema (i.e. not using oneOf) and compare old3a.json with new31.json we get a different and more precise rule difference:

Rule Error JsonPath
1034 The new version has new required property 'testNullableProperty' that was not found in the old version. #/paths/~1api~1public~1form/post/requestBody/content/application~1json/schema

Would it be possible to get support for oneOf syntax as this is what NSwag generates?

Regards
/Kristoffer

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