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

2x same param name in components.parameters triggers diff for identical base and revision #352

Closed
raphaelhuefner opened this issue Aug 1, 2023 · 1 comment · Fixed by #354
Labels
bug Something isn't working

Comments

@raphaelhuefner
Copy link
Contributor

raphaelhuefner commented Aug 1, 2023

Describe the bug

2 parameter definitions in the components.parameters section with the same parameter name, but with differing schema and description trigger diff output for both, oasdiff summary and oasdiff diff, especially when base and revision are identical.

To Reproduce

Note that the attached oasdiff_bug_different_component_same_parameter.zip contains the example minimal OAS file for the following steps.

Steps to reproduce the behavior:

  • use oasdiff version 1.7.1 (I've seen it with 1.7.0 as well, but didn't try any other versions.)
  • (extract from ZIP file or) create a file oasdiff_bug_different_component_same_parameter.yaml with the following content:
openapi: 3.0.3

components:
  parameters:
    differentComponentName_A:
      name: sameParamName
      in: query
      required: false
      schema:
        type: string
        enum:
          - option_1
          - option_2
        default: option_1
      description: Let's mention both options, option_1 and option_2.
    differentComponentName_B:
      name: sameParamName
      in: query
      required: false
      schema:
        type: string
        enum:
          - option_1
        default: option_1
      description: Let's mention the only option, option_1.
  • run oasdiff summary oasdiff_bug_different_component_same_parameter.yaml oasdiff_bug_different_component_same_parameter.yaml (Note that base and revision are the very same file!)
  • receive
diff: true
details:
    parameters:
        modified: 1
  • run oasdiff diff oasdiff_bug_different_component_same_parameter.yaml oasdiff_bug_different_component_same_parameter.yaml (Note that base and revision are the very same file!)
  • receive
components:
    parameters:
        modified:
            query:
                sameParamName:
                    description:
                        from: Let's mention both options, option_1 and option_2.
                        to: Let's mention the only option, option_1.
                    schema:
                        enum:
                            deleted:
                                - option_2

(Sometimes the diff is shown in reverse, i.e. as added enum option.)

Expected behavior

  • For oasdiff summary I would expect to see
diff: false

as output.

  • For oasdiff diff I would expect an empty output.

Desktop:

  • OS: macOS (AFAICT irrelevant)

Additional context

  • I checked https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#components-object and did not find any rule which prohibits multiple, differing, parameter definitions for the same parameter name.
  • I can understand how one could argue that such a constellation might be less than ideal. OTOH I ask to also understand the other side, where the same parameter name has a different meaning (and hence a different declaration) in different contexts.
  • I don't think it is oasdiff's role to enforce any rules about parameter naming, that would be a linter's job.
@raphaelhuefner raphaelhuefner added the bug Something isn't working label Aug 1, 2023
@reuvenharrison
Copy link
Collaborator

Replicated. Fix in progress.

@reuvenharrison reuvenharrison linked a pull request Aug 2, 2023 that will close this issue
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