Skip to content

feat(openapi3): add @pageItems decorator when x-ms-list-page-items extension is present#9615

Merged
baywet merged 6 commits intomainfrom
copilot/add-openapi-pageitems-support
Feb 6, 2026
Merged

feat(openapi3): add @pageItems decorator when x-ms-list-page-items extension is present#9615
baywet merged 6 commits intomainfrom
copilot/add-openapi-pageitems-support

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

The OpenAPI importer wasn't generating the @pageItems decorator for array properties annotated with x-ms-list-page-items: true.

Changes

  • Modified getDecoratorsForSchema to detect x-ms-list-page-items: true and add @pageItems decorator
  • Both @extension and @pageItems decorators are now applied when the extension is present
  • Added test coverage for true/false/absent cases

Example

Input OpenAPI:

WidgetList:
  type: object
  properties:
    value:
      type: array
      items:
        $ref: '#/components/schemas/Widget'
      x-ms-list-page-items: true

Generated TypeSpec:

model WidgetList {
  @extension("x-ms-list-page-items", true) @pageItems value: Widget[];
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Add support for importing the pageItems 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: []
      responses:
        '200':
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WidgetList'
        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
          readOnly: true
        weight:
          type: integer
          format: int32
        color:
          type: strin...

</details>



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

- Fixes microsoft/typespec#9614

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

✨ Let Copilot coding agent [set things up for you](https://github.com/microsoft/typespec/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

- Add @pageItems decorator when x-ms-list-page-items is true
- Both @extension and @pageItems decorators are applied to the property
- Add comprehensive unit tests for the feature

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 importing pageItems decorator from OpenAPI feat(openapi3): add @pageItems decorator when x-ms-list-page-items extension is present Feb 6, 2026
Copilot AI requested a review from baywet February 6, 2026 17:40
@baywet baywet marked this pull request as ready for review February 6, 2026 18:23
@baywet baywet enabled auto-merge February 6, 2026 18:23
@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@9615
npm i https://pkg.pr.new/microsoft/typespec/@typespec/openapi3@9615

commit: 513ee13

@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-items extension to @pageItems 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
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Feb 6, 2026
@baywet baywet requested a review from timotheeguerin February 6, 2026 19:35
@baywet baywet enabled auto-merge February 6, 2026 19:35
@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 a conflict with the base branch Feb 6, 2026
@baywet baywet requested a review from timotheeguerin February 6, 2026 20:38
@baywet baywet enabled auto-merge February 6, 2026 20:38
@baywet baywet added this pull request to the merge queue Feb 6, 2026
Merged via the queue into main with commit 5e73d5b Feb 6, 2026
24 checks passed
@baywet baywet deleted the copilot/add-openapi-pageitems-support branch February 6, 2026 21:31
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 importing the pageItems decorator based on the relevant OpenAPI extension

4 participants