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

[Bug]: tsp-openapi3: common parameters not imported #4455

Closed
4 tasks done
Arithmomaniac opened this issue Sep 16, 2024 · 0 comments · Fixed by #4708
Closed
4 tasks done

[Bug]: tsp-openapi3: common parameters not imported #4455

Arithmomaniac opened this issue Sep 16, 2024 · 0 comments · Fixed by #4708
Assignees
Labels
bug Something isn't working openapi3:converter Issues for @typespec/openapi3 openapi to typespec converter triaged:core

Comments

@Arithmomaniac
Copy link

Arithmomaniac commented Sep 16, 2024

Describe the bug

Operation parameters defined as "common parameters" for a given path, instead of being copied to each individual path, are not imported at all.

detected as part of the "TypeSpec for Sefaria" hack.

Reproduction

See this gist that describes the same API with and without using common parameters: https://gist.github.com/Arithmomaniac/150cf23eb89141c92d3663cd49d080b1

Import result without using common parameters: Playground

Import result when using common parameters: Playground (won't even compile)

Checklist

@Arithmomaniac Arithmomaniac added the bug Something isn't working label Sep 16, 2024
@markcowl markcowl added the openapi3:converter Issues for @typespec/openapi3 openapi to typespec converter label Sep 16, 2024
@markcowl markcowl added this to the [2024] November milestone Sep 16, 2024
@chrisradek chrisradek self-assigned this Oct 10, 2024
github-merge-queue bot pushed a commit that referenced this issue Oct 14, 2024
Fixes #4455 

Previously, the parameters defined as a child of a `path` were ignored.
Now they are added to the operations defined in each of the path's
methods.

The spec states that duplicates are not allowed in the final
operation-level parameter list, and the more specific (operation level)
replaces the less specific (path level) if there is a collision. A
combination of the location and name uniquely identify a parameter for
these purposes.

Example:
```yml
openapi: 3.0.0
info:
  title: (title)
  version: 0.0.0
tags: []
paths:
  /widgets/{id}:
    get:
      operationId: Widgets_read
      responses:
        "200":
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Widget"
    delete:
      operationId: Widgets_delete
      responses:
        "204":
          description: "There is no content to send for this request, but the headers may be useful. "
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
components:
  schemas:
    Widget:
      type: object
      required:
        - id
      properties:
        id:
          type: string

```

---------

Co-authored-by: Christopher Radek <[email protected]>
swatkatz pushed a commit to swatkatz/typespec that referenced this issue Nov 5, 2024
Fixes microsoft#4455 

Previously, the parameters defined as a child of a `path` were ignored.
Now they are added to the operations defined in each of the path's
methods.

The spec states that duplicates are not allowed in the final
operation-level parameter list, and the more specific (operation level)
replaces the less specific (path level) if there is a collision. A
combination of the location and name uniquely identify a parameter for
these purposes.

Example:
```yml
openapi: 3.0.0
info:
  title: (title)
  version: 0.0.0
tags: []
paths:
  /widgets/{id}:
    get:
      operationId: Widgets_read
      responses:
        "200":
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Widget"
    delete:
      operationId: Widgets_delete
      responses:
        "204":
          description: "There is no content to send for this request, but the headers may be useful. "
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
components:
  schemas:
    Widget:
      type: object
      required:
        - id
      properties:
        id:
          type: string

```

---------

Co-authored-by: Christopher Radek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working openapi3:converter Issues for @typespec/openapi3 openapi to typespec converter triaged:core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants