Tufin / oasdiff

OpenAPI Diff and Breaking Changes
https://www.oasdiff.com
Apache License 2.0
689 stars 59 forks source link

Changelog does not log adding a new optional request body #517

Closed renke0 closed 4 months ago

renke0 commented 5 months ago

Describe the bug

When using the cli to create a changelog, adding an optional request body is ignored. They are detected by diff and summary though.

To Reproduce

Steps to reproduce the behavior:

  1. Run command:
    oasdiff changelog openapi.yaml openapi-new.yaml
  2. Spec 1: openapi.yaml
    
    openapi: 3.0.0
    info:
    title: Test API
    version: 1.0.0
    paths:
    /ducks:
    post:
      responses:
        '200':
          description: A duck
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Duck'
    components:
    schemas:
    Duck:
      type: object
      properties:
        name:
          type: string
        age:
          type: integer
3. Spec 2: `openapi-new.yaml`
```yaml
openapi: 3.0.0
info:
  title: Test API
  version: 1.0.0
paths:
  /ducks:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Duck'
      responses:
        '200':
          description: A duck
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Duck'
components:
  schemas:
    Duck:
      type: object
      properties:
        name:
          type: string
        age:
          type: integer
  1. Output: Nothing is output

Expected behavior

I expected the addition of the new request body in the path to be logged with a info level, as shown below.

1 changes: 0 error, 0 warning, 1 info
info   [request-body-added] at openapi-new.yaml      
        in API POST /ducks
                request body added

Desktop

Additional context

The changes are detected by diff and summary

> oasdiff diff openapi.yaml openapi-new.yaml
paths:
    modified:
        /ducks:
            operations:
                modified:
                    POST:
                        requestBody:
                            added: true
endpoints:
    modified:
        ?   method: POST
            path: /ducks
        :   requestBody:
                added: true
> oasdiff summary openapi.yaml openapi-new.yaml
diff: true
details:
    endpoints:
        modified: 1
    paths:
        modified: 1
reuvenharrison commented 4 months ago

While I'm fixing this, I'd also like to add a check for removing a request body.

Can you please provide your feedback:

  1. Do you think that it should be INFO, WARN or ERR?
  2. Do you think this depends on the removed body being optional or required?
renke0 commented 3 months ago

Sorry by the late response. I agree with your implementation, it should be INFO if the body is optional and ERR if it is required.