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

[2.1.0-beta.6 and oas-3.1.0] Request body property data type change is detected as compatible or no_change #528

Open
nagarro-aditya opened this issue Jun 2, 2023 · 1 comment

Comments

@nagarro-aditya
Copy link

nagarro-aditya commented Jun 2, 2023

  1. string to object (actual: compatible, expected: incompatible)
  2. string to integer/integer to string (actual: no_change, expected: incompatible)

Case 1:
old.yml

openapi: 3.1.0
info:
  title: Demo API
  version: v1
paths:
  /endpoint:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - requiredProp
                - requiredToRemoveProp
                - dataTypeChangedRequiredProp
                - requiredToOptionalProp
              properties:
                requiredProp:
                  type: string
                optionalProp:
                  type: string
                optionalToRemoveProp:
                  type: string
                requiredToRemoveProp:
                  type: string
                dataTypeChangedRequiredProp:
                  type: string
                dataTypeChangedOptionalProp:
                  type: string
                optionalToRequiredProp:
                  type: string
                requiredToOptionalProp:
                  type: string
      responses:
        default:
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    format: int64
                    example: 201

new.yml

openapi: 3.1.0
info:
  title: Demo API
  version: v1
paths:
  /endpoint:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - requiredProp
                - requiredToRemoveProp
                - dataTypeChangedRequiredProp
                - requiredToOptionalProp
              properties:
                requiredProp:
                  type: string
                optionalProp:
                  type: string
                optionalToRemoveProp:
                  type: string
                requiredToRemoveProp:
                  type: string
                dataTypeChangedRequiredProp:
                  type: object
                  properties:
                    id:
                      type: string
                dataTypeChangedOptionalProp:
                  type: string
                optionalToRequiredProp:
                  type: string
                requiredToOptionalProp:
                  type: string
      responses:
        default:
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    format: int64
                    example: 201

Case 2:
old.yml

openapi: 3.1.0
info:
  title: Demo API
  version: v1
paths:
  /endpoint:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - requiredProp
                - requiredToRemoveProp
                - dataTypeChangedRequiredProp
                - requiredToOptionalProp
              properties:
                requiredProp:
                  type: string
                optionalProp:
                  type: string
                optionalToRemoveProp:
                  type: string
                requiredToRemoveProp:
                  type: string
                dataTypeChangedRequiredProp:
                  type: integer
                dataTypeChangedOptionalProp:
                  type: string
                optionalToRequiredProp:
                  type: string
                requiredToOptionalProp:
                  type: string
      responses:
        default:
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    format: int64
                    example: 201

new.yml

openapi: 3.1.0
info:
  title: Demo API
  version: v1
paths:
  /endpoint:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - requiredProp
                - requiredToRemoveProp
                - dataTypeChangedRequiredProp
                - requiredToOptionalProp
              properties:
                requiredProp:
                  type: string
                optionalProp:
                  type: string
                optionalToRemoveProp:
                  type: string
                requiredToRemoveProp:
                  type: string
                dataTypeChangedRequiredProp:
                  type: string
                dataTypeChangedOptionalProp:
                  type: string
                optionalToRequiredProp:
                  type: string
                requiredToOptionalProp:
                  type: string
      responses:
        default:
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    format: int64
                    example: 201

Examples are having data-type change only for required property but tested the same for optional property giving same output
Command used: docker run --rm -t -v $(pwd):/specs openapitools/openapi-diff:2.1.0-beta.6 /specs/old.yml /specs/new.yml --state

EDIT: The same changes are considered as incompatible with openapi: 3.0.3 and below

@rsittikun
Copy link

I also have same problem with openapi: 3.1.0

  • if remove field in object type can detect change
  • if remove field in array type can't detect change

both be able to detect change with openapi: 3.0.3

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

2 participants