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

tsp-openapi3: support path-level parameters #4708

Merged
merged 5 commits into from
Oct 14, 2024

Conversation

chrisradek
Copy link
Member

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:

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

@chrisradek chrisradek changed the title Tsp openapi3 common params tsp-openapi3: support path-level parameters Oct 11, 2024
@azure-sdk
Copy link
Collaborator

All changed packages have been documented.

  • @typespec/openapi3
Show changes

@typespec/openapi3 - fix ✏️

Updates tsp-openapi3 to include path-level parameters in generated typespec operations.

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 📚 Next docs

@chrisradek chrisradek added this pull request to the merge queue Oct 14, 2024
Merged via the queue into microsoft:main with commit 6c6f311 Oct 14, 2024
22 checks passed
@chrisradek chrisradek deleted the tsp-openapi3-common-params branch October 14, 2024 18:32
swatkatz pushed a commit to swatkatz/typespec that referenced this pull request 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 <Christopher.Radek@microsoft.com>
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 this pull request may close these issues.

[Bug]: tsp-openapi3: common parameters not imported
3 participants