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

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

Closed
renke0 opened this issue Apr 6, 2024 · 2 comments · Fixed by #531
Closed

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

renke0 opened this issue Apr 6, 2024 · 2 comments · Fixed by #531
Labels
bug Something isn't working

Comments

@renke0
Copy link

renke0 commented Apr 6, 2024

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
  1. 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
  1. Spec 2: openapi-new.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

  • macOS Sonoma 14.1

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
@renke0 renke0 added the bug Something isn't working label Apr 6, 2024
@reuvenharrison reuvenharrison linked a pull request Apr 24, 2024 that will close this issue
@reuvenharrison
Copy link
Collaborator

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
Copy link
Author

renke0 commented May 21, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants