Skip to content

feat(openapi3): add @pageIndex decorator support for x-ms-list-page-index extension#9611

Merged
baywet merged 4 commits intomainfrom
copilot/add-page-index-decorator
Feb 6, 2026
Merged

feat(openapi3): add @pageIndex decorator support for x-ms-list-page-index extension#9611
baywet merged 4 commits intomainfrom
copilot/add-page-index-decorator

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

The OpenAPI3 importer now recognizes the x-ms-list-page-index extension on parameters and generates the corresponding @pageIndex decorator in TypeSpec output.

Changes

  • Importer enhancement: Modified getParameterDecorators() to detect x-ms-list-page-index: true and emit @pageIndex decorator
  • Test coverage: Added 4 test cases verifying decorator emission for true/false/missing extension values

Example

OpenAPI input:

parameters:
  - name: idx
    in: query
    required: true
    schema:
      type: integer
      format: int32
    x-ms-list-page-index: true

Generated TypeSpec:

@extension("x-ms-list-page-index", true)
@pageIndex
@query
idx: int32

The extension decorator is preserved for round-trip fidelity while the semantic @pageIndex decorator enables proper paging behavior in downstream emitters.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add support for adding the pageIndex decorator based on the relevant openapi 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:
      operationId: Widgets_list
      description: List widgets
      parameters:
        - name: idx
          in: query
          required: true
          schema:
            type: integer
            format: int32
          #this is the extension that matters
          x-ms-list-page-index: true
          explode: false
      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:
        ...

</details>



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

- Fixes microsoft/typespec#9610

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

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

…ension

- Add support for x-ms-list-page-index OpenAPI extension
- When x-ms-list-page-index is true, add @pageindex decorator to parameter
- Add comprehensive tests for the feature
- Tests verify decorator is added correctly and not added when false or missing

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 pageIndex decorator from OpenAPI extension feat(openapi3): add @pageIndex decorator support for x-ms-list-page-index extension Feb 6, 2026
Copilot AI requested a review from baywet February 6, 2026 17:31
@baywet baywet marked this pull request as ready for review February 6, 2026 17:45
@baywet baywet enabled auto-merge February 6, 2026 17:45
@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@9611
npm i https://pkg.pr.new/microsoft/typespec/@typespec/openapi3@9611

commit: 29576cc

Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
@baywet baywet requested a review from timotheeguerin February 6, 2026 17:57
@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-page-index extension to add @pageIndex decorator

@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
Merged via the queue into main with commit c219ec5 Feb 6, 2026
24 checks passed
@baywet baywet deleted the copilot/add-page-index-decorator branch February 6, 2026 18:50
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 the pageIndex decorator based on the relevant openapi extension

4 participants