Skip to content

Add OpenAPI discriminator hints for tagged enum schemas#474

Merged
srperens merged 1 commit intomainfrom
feat/openapi-discriminator-hints
Apr 7, 2026
Merged

Add OpenAPI discriminator hints for tagged enum schemas#474
srperens merged 1 commit intomainfrom
feat/openapi-discriminator-hints

Conversation

@srperens
Copy link
Copy Markdown
Collaborator

@srperens srperens commented Apr 7, 2026

Summary

  • Adds discriminator: { propertyName: "type" } to StromEvent, ServerMessage, and ClientMessage oneOf schemas
  • Utoipa's derive macro only supports discriminator for serde(untagged) enums, so this is applied programmatically in openapi_spec()
  • Enables external code generators (openapi-generator for Java/C#/Go, Zod-based validators) to produce proper discriminated union types from the spec

Test plan

  • cargo check passes
  • OpenAPI snapshot test updated and passes
  • Verified generated TypeScript types compile cleanly with openapi-typescript + openapi-fetch

🤖 Generated with Claude Code

StromEvent, ServerMessage, and ClientMessage use serde's
tag = "type" representation which produces oneOf schemas.
Adding the discriminator property enables external code
generators (openapi-generator, Zod-based validators) to
produce proper discriminated union types.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@srperens srperens merged commit ff1405f into main Apr 7, 2026
6 of 7 checks passed
@srperens srperens deleted the feat/openapi-discriminator-hints branch April 7, 2026 08:59
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