Skip to content

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

@nagarro-aditya

Description

@nagarro-aditya
  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

Activity

rsittikun

rsittikun commented on Aug 25, 2023

@rsittikun

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

added and removed on Jan 30, 2025
added this to the 2.2.0 milestone on Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @DrSatyr@rsittikun@nagarro-aditya

        Issue actions

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