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

Ignore parameter name changes #202

Closed
EpicWink opened this issue Mar 23, 2023 · 3 comments · Fixed by #211
Closed

Ignore parameter name changes #202

EpicWink opened this issue Mar 23, 2023 · 3 comments · Fixed by #211

Comments

@EpicWink
Copy link

EpicWink commented Mar 23, 2023

Problem

I have the same (in theory) API spec generated from two different sources, which have different names for the URL path parameters. This causes oasdiff to consider those endpoints to be both new and deleted, even though the API is not any different.

Proposal

Treat URL path parameter names as opaque, and equivalent between the base and revision specs (if the parameters have the same schema, eg the same (lack of) reg-ex).

Alternatives

I currently manually update the OpenAPI spec to have matching path parameters, but this is prone to error.

@reuvenharrison
Copy link
Collaborator

Hi @EpicWink ,
Would you be able to provide two specs and a cmd-line that I can use to replicate the issue?
Thanks,
Reuven

@EpicWink
Copy link
Author

@reuvenharrison here:

a.openapi.yml
openapi: 3.0.0

info:
  title: My API
  version: '0.1'

paths:
  /books/{bookId}:
    parameters:
      - in: path
        name: bookId
        description: book ID
        required: true

        schema:
          title: ID
          type: string

    get:
      summary: get book details
      description: get details for a book

      responses:
        '200':
          description: successfully retrieved book details

          content:
            application/json:
              schema:
                title: book details
                type: object

                required:
                  - author
                  - title

                properties:
                  author:
                    title: book author name
                    type: string

                  title:
                    title: book title
                    type: string
b.openapi.yml
openapi: 3.0.0

info:
  title: My API
  version: '0.1'

paths:
  /books/{id}:
    parameters:
      - in: path
        name: id
        description: book ID
        required: true

        schema:
          title: ID
          type: string

    get:
      summary: get book details
      description: get details for a book

      responses:
        '200':
          description: successfully retrieved book details

          content:
            application/json:
              schema:
                title: book details
                type: object

                required:
                  - author
                  - title

                properties:
                  author:
                    title: book author name
                    type: string

                  title:
                    title: book title
                    type: string

Text

docker run -v $(pwd):/wd -w /wd --rm -i tufin/oasdiff:latest -format text -base a.openapi.yml -revision b.openapi.yml
### New Endpoints: 1
--------------------
GET /books/{id}  

### Deleted Endpoints: 1
------------------------
GET /books/{bookId}  

### Modified Endpoints: None
----------------------------

YAML

docker run -v $(pwd):/wd -w /wd --rm -i tufin/oasdiff:latest -format yaml -base a.openapi.yml -revision b.openapi.yml
paths:
    added:
        - /books/{id}
    deleted:
        - /books/{bookId}
endpoints:
    added:
        - method: GET
          path: /books/{id}
    deleted:
        - method: GET
          path: /books/{bookId}

@reuvenharrison reuvenharrison linked a pull request Mar 31, 2023 that will close this issue
@reuvenharrison
Copy link
Collaborator

See #212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants