Skip to content

Preserve union variant docs in OpenAPI response descriptions - #11785

Queued
Timothee Guerin (timotheeguerin) with Copilot wants to merge 3 commits into
mainfrom
copilot/openapi-emitter-respect-return-type-doc
Queued

Preserve union variant docs in OpenAPI response descriptions#11785
Timothee Guerin (timotheeguerin) with Copilot wants to merge 3 commits into
mainfrom
copilot/openapi-emitter-respect-return-type-doc

Conversation

Copilot AI commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

OpenAPI response descriptions discarded @doc annotations on return-type union variants, falling back to generic status-code descriptions.

  • Response resolution

    • Propagate each union variant’s documentation while flattening response unions.
    • Preserve existing union-level documentation fallback.
  • Coverage

    • Verify variant-specific descriptions across OpenAPI 3.0, 3.1, and 3.2.
union CreatedResponses {
  @doc("Pet Created") created: PetCreated,
  @doc("Pet Accepted") accepted: PetAccepted,
}

This emits Pet Created and Pet Accepted for the corresponding response descriptions.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added lib:http emitter:openapi3 Issues for @typespec/openapi3 emitter labels Aug 28, 2026
@timotheeguerin Timothee Guerin (timotheeguerin) added the int:azure-specs Run integration tests against azure-rest-api-specs label Aug 28, 2026
Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix openapi emitter to respect return type variant doc in response Preserve union variant docs in OpenAPI response descriptions Aug 28, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: edb52b0

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes OpenAPI response description generation so that @doc applied to return-type union variants is preserved when unions are flattened into concrete HTTP responses (instead of falling back to generic status-code descriptions).

Changes:

  • Propagate union variant documentation through resolveResponseVariants so each resolved response can carry the correct description.
  • Add an OpenAPI emitter regression test asserting variant-specific descriptions for distinct status codes across supported OpenAPI versions.
  • Add a Chronus changelog entry for the behavioral fix in @typespec/http.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/openapi3/test/response-descriptions.test.ts Adds coverage that union variant @doc values become the emitted OpenAPI response descriptions.
packages/http/src/responses.ts Preserves per-variant documentation while flattening response unions by threading variant @doc into the resolved description.
.chronus/changes/copilot-openapi-emitter-respect-return-type-doc-2026-7-28-13-0-55.md Records the fix as a @typespec/http changelog entry.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@timotheeguerin
Timothee Guerin (timotheeguerin) added this pull request to the merge queue Sep 4, 2026
Any commits made after this event will not be merged.
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 int:azure-specs Run integration tests against azure-rest-api-specs lib:http

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Openapi emitter should respect return type variant doc on response

4 participants