Skip to content

feat(openapi3): Add @list decorator when x-ms-list extension is true#9609

Merged
baywet merged 5 commits intomainfrom
copilot/add-list-decorator-support
Feb 6, 2026
Merged

feat(openapi3): Add @list decorator when x-ms-list extension is true#9609
baywet merged 5 commits intomainfrom
copilot/add-list-decorator-support

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

OpenAPI specs using x-ms-list: true to mark list operations weren't generating the corresponding @list decorator in TypeSpec output.

Changes

  • Modified getExtensions() in decorators.ts to detect x-ms-list: true and emit both @list and @extension("x-ms-list", true) decorators
  • Added test suite covering true/false/absent scenarios for the extension

Example

Input OpenAPI:

paths:
  /widgets:
    get:
      x-ms-list: true
      operationId: Widgets_list
      responses:
        '200':
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Widget'

Generated TypeSpec (before):

@extension("x-ms-list", true)
@route("/widgets")
@get
op Widgets_list(): Widget[];

Generated TypeSpec (after):

@list
@extension("x-ms-list", true)
@route("/widgets")
@get
op Widgets_list(): Widget[];

The @list decorator marks the operation as paginated, while the @extension preserves roundtrip compatibility.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.astro.build
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/typespec/typespec/website/node_modules/.bin/../astro/astro.js build node eams�� ebsite/src/content/docs/docs/libraries/openapi/reference node (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Add support for adding list decorator to operations when detecting the corresponding extension</issue_title>
<issue_description>### Clear and concise description of the problem

Related https://github.com/microsoft/openai-openapi-pr/issues/568

Based on the following OpenAPI description, we should get the following TypeSpec definition imported

openapi: 3.0.0
info:
  title: Widget Service
  version: 0.0.0
tags:
  - name: Widgets
paths:
  /widgets:
    get:
      # this is the extension that matters
      x-ms-list: true
      operationId: Widgets_list
      description: List widgets
      parameters: []
      responses:
        '200':
          description: The request has succeeded.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Widget'
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      tags:
        - Widgets
    post:
      operationId: Widgets_create
      description: Create a widget
      parameters: []
      responses:
        '200':
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Widget'
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      tags:
        - Widgets
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Widget'
  /widgets/{id}:
    get:
      operationId: Widgets_read
      description: Read widgets
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            readOnly: true
      responses:
        '200':
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Widget'
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      tags:
        - Widgets
    patch:
      operationId: Widgets_update
      description: Update a widget
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            readOnly: true
      responses:
        '200':
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Widget'
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      tags:
        - Widgets
      requestBody:
        required: true
        content:
          application/merge-patch+json:
            schema:
              $ref: '#/components/schemas/WidgetMergePatchUpdate'
    delete:
      operationId: Widgets_delete
      description: Delete a widget
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            readOnly: true
      responses:
        '204':
          description: 'There is no content to send for this request, but the headers may be useful. '
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      tags:
        - Widgets
  /widgets/{id}/analyze:
    post:
      operationId: Widgets_analyze
      description: Analyze a widget
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            readOnly: true
      responses:
        '200':
          description: The request has succeeded.
          content:
            text/plain:
              schema:
                type: string
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      tags:
        - Widgets
components:
  schemas:
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
    Widget:
      type: object
      required:
        - id
        - weight
        - color
      properties:
        id:
          type: string
      ...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes microsoft/typespec#9608

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.

Add @list decorator to operations when x-ms-list: true is detected in OpenAPI specs.
The implementation also preserves the extension decorator for roundtrip compatibility.

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service bot added emitter:openapi3 Issues for @typespec/openapi3 emitter openapi3:converter Issues for @typespec/openapi3 openapi to typespec converter labels Feb 6, 2026
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for list decorator in operations feat(openapi3): Add @list decorator when x-ms-list extension is true Feb 6, 2026
Copilot AI requested a review from baywet February 6, 2026 17:27
@baywet baywet marked this pull request as ready for review February 6, 2026 18:25
@baywet baywet enabled auto-merge February 6, 2026 18:25
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 6, 2026

Open in StackBlitz

npm i https://pkg.pr.new/microsoft/typespec/@typespec/openapi@9609
npm i https://pkg.pr.new/microsoft/typespec/@typespec/openapi3@9609

commit: 5e6c6f1

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

All changed packages have been documented.

  • @typespec/openapi3
Show changes

@typespec/openapi3 - feature ✏️

importer - Add support for x-ms-list extension to add @list decorator to operations

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@baywet baywet added this pull request to the merge queue Feb 6, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 6, 2026
@baywet baywet added this pull request to the merge queue Feb 6, 2026
Merged via the queue into main with commit 763a52d Feb 6, 2026
29 checks passed
@baywet baywet deleted the copilot/add-list-decorator-support branch February 6, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:openapi3 Issues for @typespec/openapi3 emitter openapi3:converter Issues for @typespec/openapi3 openapi to typespec converter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for adding list decorator to operations when detecting the corresponding extension

4 participants