OpenAPITools / OpenAPITools/openapi-diff

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

Open
#528 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Breaking/Non-Breaking classification
Dominant language
Java
Stars
1.1k
Forks
190
PR merge metrics
No merged PRs in 30d

Description

  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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the report with old.yml and new.yml using the stated openapi-diff Docker command, comparing the OpenAPI 3.1.0 results with the 3.0.3 behavior. Trace the request-body schema type comparison and add regression coverage for string/object and string/integer changes; done means these changes are reported as incompatible.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.