Skip to content

feat(openapi3): Add paging link decorator import from x-ms-list-*-link extensions#9627

Merged
baywet merged 4 commits intomainfrom
copilot/add-import-support-prevlink-decorator
Feb 6, 2026
Merged

feat(openapi3): Add paging link decorator import from x-ms-list-*-link extensions#9627
baywet merged 4 commits intomainfrom
copilot/add-import-support-prevlink-decorator

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

The OpenAPI3 importer was not generating TypeSpec paging link decorators (@prevLink, @nextLink, @firstLink, @lastLink) when encountering the corresponding x-ms-list-*-link extensions.

Changes

  • Added getPagingLinkDecorators() in decorators.ts to map x-ms-list-*-link extensions to their TypeSpec paging decorators
    • Only emits decorator when extension value is true
    • Supports all four link types: prev, next, first, last
  • Test coverage for all four decorator types and value validation

Example

Given OpenAPI schema:

WidgetList:
  properties:
    prevLink:
      type: string
      x-ms-list-prev-link: true

Now generates:

model WidgetList {
  @extension("x-ms-list-prev-link", true) @prevLink prevLink: string;
}

The importer emits both the @extension decorator (preserving the original extension) and the semantic @prevLink decorator (enabling TypeSpec's paging analysis).

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 sh s/.b�� e/petstore --war--llmstxt node _modules/pnpm/dist/node-gyp-bin/node import @typespecnode --production reams/reference sh nts/�� tsc -p tsconfig.build.json dotnet /node_modules/.bin/sh --no-emit Release ents/reference sh (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 importing the prevLink 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
        - colo...

</details>



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

- Fixes microsoft/typespec#9622

<!-- 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 @prevLink, @nextlink, @firstlink, @lastlink decorators when corresponding x-ms-list-*-link extensions are true
- Add comprehensive test suite for paging link extensions
- Ensure @typespec/openapi import is added when using paging link decorators

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 prevLink decorator from OpenAPI extension feat(openapi3): Add paging link decorator import from x-ms-list-*-link extensions Feb 6, 2026
Copilot AI requested a review from baywet February 6, 2026 17:57
@baywet baywet marked this pull request as ready for review February 6, 2026 18:09
@baywet baywet enabled auto-merge February 6, 2026 18:09
@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@9627
npm i https://pkg.pr.new/microsoft/typespec/@typespec/openapi3@9627

commit: e2c933f

@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 importing paging link decorators (@prevLink, @nextLink, @firstLink, @lastLink) based on x-ms-list-*-link OpenAPI extensions

@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 9be6023 Feb 6, 2026
29 checks passed
@baywet baywet deleted the copilot/add-import-support-prevlink-decorator branch February 6, 2026 19:00
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

4 participants