Skip to content

feat(openapi3): add @offset decorator for x-ms-list-offset extension#9613

Merged
baywet merged 6 commits intomainfrom
copilot/add-offset-decorator-import
Feb 6, 2026
Merged

feat(openapi3): add @offset decorator for x-ms-list-offset extension#9613
baywet merged 6 commits intomainfrom
copilot/add-offset-decorator-import

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

The OpenAPI importer now emits the @pageIndex decorator when encountering x-ms-list-offset: true on query parameters.

Changes

  • Modified getParameterDecorators(): Detects x-ms-list-offset: true extension and adds @pageIndex decorator alongside the existing @extension decorator
  • Added test coverage: 5 test cases covering true/false/absent values, optional parameters, and multi-parameter scenarios

Example

OpenAPI input:

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

TypeSpec output:

@extension("x-ms-list-offset", true)
@pageIndex
@query
offset: int32

The @extension decorator was already being emitted by existing code; this change adds the semantic @pageIndex decorator when appropriate.

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 nts/�� ebsite/src/conte--llmstxt sh _modules/.bin/no../../website/src/content/docs/docs/emitters/openapi3/reference --no-emit bash ents/reference uname tobu�� astro check --minimumFailingSeve--typekits sh tnet/tools/sh ld.json && pnpm node bash tobuf/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 importing the offset 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: offset
          in: query
          required: true
          schema:
            type: integer
            format: int32
          #this is the extension that matters
          x-ms-list-offset: 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#9612

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

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

commit: 73582b6

@baywet baywet changed the title feat(openapi3): add @pageIndex decorator for x-ms-list-offset extension feat(openapi3): add @offset decorator for x-ms-list-offset extension Feb 6, 2026
@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 @offset decorator when x-ms-list-offset extension is present

Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
@baywet baywet requested a review from timotheeguerin February 6, 2026 18:01
@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 087abac Feb 6, 2026
24 checks passed
@baywet baywet deleted the copilot/add-offset-decorator-import branch February 6, 2026 18:59
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 offset decorator based on the relevant OpenAPI extension

4 participants