Skip to content

fix(openapi3): convert deprecated: true on operations to #deprecated directive - #10901

Merged
baywet merged 2 commits into
mainfrom
copilot/import-deprecated-for-operations
Jun 5, 2026
Merged

fix(openapi3): convert deprecated: true on operations to #deprecated directive#10901
baywet merged 2 commits into
mainfrom
copilot/import-deprecated-for-operations

Conversation

Copilot AI commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

PR #4453 added deprecated import support for models and properties but missed operations. An OpenAPI operation with deprecated: true would be silently dropped during conversion.

Changes

  • transform-paths.ts: Extract operation.deprecated as a TypeSpecDirective and attach it to the resulting TypeSpecOperation (including through splitOperationByContentType).
  • generate-operation.ts: Add generateDirectives emission; refactor line-joining so directives render on their own line (preamble: doc + directives \n-joined; body: tags + decorators + op space-joined) — #deprecated inline with decorators is invalid TypeSpec syntax.

Example

# Input
paths:
  /widgets:
    get:
      operationId: Widgets_list
      deprecated: true
      responses: ...
// Before (deprecated silently dropped)
op Widgets_list(): ...;

// After
#deprecated "deprecated"
op Widgets_list(): ...;

Copilot AI linked an issue Jun 5, 2026 that may be closed by this pull request
3 tasks
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Copilot AI changed the title [WIP] Add import for deprecated operations fix(openapi3): convert deprecated: true on operations to #deprecated directive Jun 5, 2026
@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 Jun 5, 2026
Copilot finished work on behalf of baywet June 5, 2026 18:09
Copilot AI requested a review from baywet June 5, 2026 18:09
@baywet
baywet marked this pull request as ready for review June 5, 2026 18:20
@baywet
baywet enabled auto-merge June 5, 2026 18:21
@pkg-pr-new

pkg-pr-new Bot commented Jun 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/openapi3@10901

commit: 8541045

@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@baywet
baywet added this pull request to the merge queue Jun 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 5, 2026
@baywet
baywet added this pull request to the merge queue Jun 5, 2026
Merged via the queue into main with commit 422a172 Jun 5, 2026
42 of 44 checks passed
@baywet
baywet deleted the copilot/import-deprecated-for-operations branch June 5, 2026 22:54
JennyPng pushed a commit to JennyPng/typespec that referenced this pull request Jun 10, 2026
…ed` directive (microsoft#10901)

PR microsoft#4453 added `deprecated` import support for models and properties but
missed operations. An OpenAPI operation with `deprecated: true` would be
silently dropped during conversion.

## Changes

- **`transform-paths.ts`**: Extract `operation.deprecated` as a
`TypeSpecDirective` and attach it to the resulting `TypeSpecOperation`
(including through `splitOperationByContentType`).
- **`generate-operation.ts`**: Add `generateDirectives` emission;
refactor line-joining so directives render on their own line (preamble:
doc + directives `\n`-joined; body: tags + decorators + `op`
space-joined) — `#deprecated` inline with decorators is invalid TypeSpec
syntax.

## Example

```yaml
# Input
paths:
  /widgets:
    get:
      operationId: Widgets_list
      deprecated: true
      responses: ...
```

```tsp
// Before (deprecated silently dropped)
op Widgets_list(): ...;

// After
#deprecated "deprecated"
op Widgets_list(): ...;
```

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
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.

Import - Deprecated not imported for operations

3 participants