Skip to content

feat(openapi3): add @continuationToken decorator support for x-ms-list-continuation-token extension on properties and parameters#9629

Merged
baywet merged 7 commits intomainfrom
copilot/add-continue-token-import-support
Feb 6, 2026
Merged

feat(openapi3): add @continuationToken decorator support for x-ms-list-continuation-token extension on properties and parameters#9629
baywet merged 7 commits intomainfrom
copilot/add-continue-token-import-support

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

The OpenAPI3 importer was not generating @continuationToken decorators when encountering the x-ms-list-continuation-token extension in property schemas or query parameters.

Changes

  • Modified decorators.ts:

    • Added detection for x-ms-list-continuation-token extension in getDecoratorsForSchema() for model properties and parameter schemas
    • Added detection in getParameterDecorators() for parameters with the extension directly on the parameter object
    • When the extension value is true, the importer now emits both @extension and @continuationToken decorators
  • Added test coverage:

    • Unit tests for model properties verify decorator generation for true/false/missing extension values
    • Unit tests for query parameters cover extension on schema and on parameter itself
    • Integration test validates the complete widget service example
    • TypeSpec output validation tests ensure correct generation

Examples

Model Property

OpenAPI schema with the extension:

continuationToken:
  type: string
  x-ms-list-continuation-token: true

Now generates:

@extension("x-ms-list-continuation-token", true) @continuationToken continuationToken: string;

Query Parameter

OpenAPI parameter with the extension on schema:

parameters:
  - name: continuationToken
    in: query
    schema:
      type: string
      x-ms-list-continuation-token: true

Or with the extension on the parameter itself:

parameters:
  - name: continuationToken
    in: query
    x-ms-list-continuation-token: true
    schema:
      type: string

Both generate:

@query @extension("x-ms-list-continuation-token", true) @continuationToken continuationToken?: string

The @typespec/openapi import and using OpenAPI; statement are already present in all conversions, so no additional imports are required.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add support for importing the continuationToken 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
     ...

</details>



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

- Fixes microsoft/typespec#9625

<!-- 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.

…-continuation-token extension

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
Copilot AI and others added 2 commits February 6, 2026 18:00
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
…e example

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for importing continuationToken decorator feat(openapi3): add @continuationToken decorator support for x-ms-list-continuation-token extension Feb 6, 2026
Copilot AI requested a review from baywet February 6, 2026 18:04
@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@9629
npm i https://pkg.pr.new/microsoft/typespec/@typespec/openapi3@9629

commit: 9282dd4

@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 the @continuationToken decorator based on x-ms-list-continuation-token extension

@azure-sdk
Copy link
Collaborator

azure-sdk commented Feb 6, 2026

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@baywet baywet disabled auto-merge February 6, 2026 18:39
@baywet
Copy link
Member

baywet commented Feb 6, 2026

@copilot I forgot a scenario in the initial issue. The extension can also be present on a query parameter. In which case it need to be added to the parameter definition during the import to TypeSpec. Start by adding the test cases, and then change the code.

@baywet baywet marked this pull request as draft February 6, 2026 18:40
…-continuation-token on parameters

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 6, 2026

@copilot I forgot a scenario in the initial issue. The extension can also be present on a query parameter. In which case it need to be added to the parameter definition during the import to TypeSpec. ...

Added support for x-ms-list-continuation-token on query parameters. The implementation handles both scenarios:

  1. Extension on parameter schema: parameter.schema["x-ms-list-continuation-token"]
  2. Extension on parameter itself: parameter["x-ms-list-continuation-token"]

Added 4 new test cases covering both scenarios with true/false values and TypeSpec output validation. All tests pass. Commit 7e8ccc3

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�� ../../website/src/content/docs/d--llmstxt sh .0/bin/node import @typespecnode bash /.bin/sh node /nod�� sc -p ./tsconfig.build.json tsconfig.build.json .0_tmp_3821/node_modules/pnpm/dist/node-gyp-bin/sh ld.json &amp;&amp; pnpm sh l/reference tools/pnpm/10.23tsx ./.scripts/regen-compiler-docs.ts node (dns block)

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

Copilot AI changed the title feat(openapi3): add @continuationToken decorator support for x-ms-list-continuation-token extension feat(openapi3): add @continuationToken decorator support for x-ms-list-continuation-token extension on properties and parameters Feb 6, 2026
Copilot AI requested a review from baywet February 6, 2026 18:56
@baywet baywet marked this pull request as ready for review February 6, 2026 19:09
@baywet baywet enabled auto-merge February 6, 2026 19:09
@baywet baywet requested a review from timotheeguerin February 6, 2026 19:09
@baywet baywet added this pull request to the merge queue Feb 6, 2026
Merged via the queue into main with commit d52c247 Feb 6, 2026
29 checks passed
@baywet baywet deleted the copilot/add-continue-token-import-support branch February 6, 2026 20:35
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 continuationToken decorator based on the relevant OpenAPI extension

4 participants