Skip to content

Propagate type-level OpenAPI extensions to computed body types - #3941

Merged
raphael merged 1 commit into
v3from
type-extension-meta
Jun 10, 2026
Merged

Propagate type-level OpenAPI extensions to computed body types#3941
raphael merged 1 commit into
v3from
type-extension-meta

Conversation

@raphael

@raphael raphael commented Jun 10, 2026

Copy link
Copy Markdown
Member

Why

Meta("openapi:extension:x-...") declared on a type never reached the generated OpenAPI documents. The HTTP body builders (expr/http_body_types.go) wrap design types into computed body user types (<Method>RequestBody / <Service><Method>ResponseBody) and only carried over openapi:typename and openapi:additionalProperties — extension meta was silently dropped before the schemafier ran. The schemafier itself already renders attribute-meta extensions, so the components were the only missing link.

Concrete motivation: schemas referenced exclusively from OpenAPI 3.2 SSE itemSchema (e.g. typed SSE event payloads) are pruned as "unreferenced" by SDK generators like Speakeasy. The documented escape hatch is x-speakeasy-include: true on the schema — which requires type-level extensions to actually render.

What

  • copyOpenAPITypeMeta — one helper shared by the request- and response-body builders that copies openapi:typename, openapi:additionalProperties, and all openapi:extension:*/swagger:extension:* keys from the original type to the computed body type (collapses the two previously duplicated copy blocks).
  • dsl/meta.go: documents that openapi:extension:xxx applies to types (OpenAPI schema object).
  • New golden case type-extension locking the rendering in 3.0 documents.

Compatibility

All pre-existing golden files pass without regeneration — output only changes for designs that already declare type-level extension meta, which previously rendered nothing.

🤖 Generated with Claude Code

The HTTP request and response body builders wrap design types into
computed body user types and only carried over the "openapi:typename"
and "openapi:additionalProperties" meta. Type-level
"openapi:extension:x-*" meta was silently dropped so extensions
declared on types never reached the generated schema components.

Copy the OpenAPI schema meta in one helper shared by both builders and
document that "openapi:extension:xxx" applies to types. This enables
designs to drive schema-level tooling extensions, for example
Speakeasy's x-speakeasy-include which forces SDK generation for schemas
only referenced from OpenAPI 3.2 SSE itemSchema documents.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@raphael
raphael merged commit 8fa7b05 into v3 Jun 10, 2026
5 checks passed
@raphael
raphael deleted the type-extension-meta branch June 10, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant