[Streams][Streamlang][API] Fully use meta({id}) to reuse schema partials in OAS output#259275
Merged
CoenWarmer merged 5 commits intoelastic:mainfrom Mar 24, 2026
Merged
Conversation
tonyghiani
approved these changes
Mar 24, 2026
Contributor
tonyghiani
left a comment
There was a problem hiding this comment.
Great reduction of the OAS output size 👏
rStelmach
approved these changes
Mar 24, 2026
Contributor
rStelmach
left a comment
There was a problem hiding this comment.
LGTM, Thank you for this change !
Contributor
💔 Build Failed
Failed CI StepsMetrics [docs]Async chunks
cc @rStelmach |
Bamieh
approved these changes
Mar 24, 2026
Contributor
Bamieh
left a comment
There was a problem hiding this comment.
core change in the openapispec zod converter LGTM, deleting the id as it is not allowed in the json schema node. i've read through the original bug issue and this seems to be the fix for it
mbondyra
added a commit
to mbondyra/kibana
that referenced
this pull request
Mar 24, 2026
…ra/kibana into dashboard_align_attachment_to_api * 'dashboard_align_attachment_to_api' of github.com:mbondyra/kibana: (45 commits) [OTel Tracing] HTTP instrumentation (elastic#258663) Replace deprecated EUI icons in files owned by @elastic/ml-ui (elastic#255624) [Codeowners] add missing codeowners for security_solution_api_integration tests (elastic#259223) [CI] fix bad imports that came from a merge-race (elastic#259383) Add `.claude/worktrees/` to `.gitignore` (elastic#259192) Improve unknown-key validation error message in @kbn/config-schema (elastic#258633) [ML] Update Security ML jobs to use entity analytics fields for host and user fields (elastic#255339) [Table sweep] Update table columns responsiveness in Index Management and Dashboards (elastic#259340) skip failing test suite (elastic#258790) skip failing test suite (elastic#259261) chore: util to clean cached images (elastic#259335) [Entity Store] Use last_seen for automated resolution watermark (elastic#258574) [One Workflow] Fix flaky alert trigger Scout test by removing order-dependent assertions (elastic#259299) Skip serverless Discover request counts tests for MKI (elastic#259333) [Security Solution] render header title in new document flyout in Security Solution and Discover (elastic#258166) [Agent Builder] register inference endpoint feature (elastic#259259) [Agent Builder] Skills Command Menu - Add descriptions and scope options to agent (elastic#258964) [Streams][Streamlang][API] Fully use meta({id}) to reuse schema partials in OAS output (elastic#259275) fix(files_example): add tableCaption to EuiInMemoryTable for a11y (elastic#258289) [Entity Store] Adding list endpoint with query filter (elastic#258320) ...
jeramysoucy
pushed a commit
to jeramysoucy/kibana
that referenced
this pull request
Mar 26, 2026
…als in OAS output (elastic#259275) Resolves elastic#259277 ## Summary Improves the Streams and Streamlang OAS output by eliminating deeply nested `anyOf > anyOf > allOf` structures in the generated spec. The root cause was that `.meta({ id })` calls for most schemas lived only in the `oas_definitions.ts` registry files rather than at definition time. Because Zod v4's `.meta()` is immutable (it returns a new schema without modifying the original), the exported schema variables themselves were never registered — so every consumer inlined the full schema instead of emitting a `$ref`. ## Root cause ```typescript // oas_definitions.ts — old pattern: .meta() result is stored but the original // conditionSchema variable remains unregistered Condition: conditionSchema.meta({ id: 'Condition' }), ``` When conditionSchema was used in `routingDefinitionSchema.where`, the OAS generator had no id to look up, so it inlined the full recursive union. The fix is to call `.meta({ id })` at definition time so the exported variable itself is the registered schema. ## Before / after `PUT /api/streams/{name}` request body ``` # Before schema: anyOf: - anyOf: - allOf: ... # After schema: $ref: '#/components/schemas/StreamUpsertRequest' ``` `GET /api/streams/{name}` response ``` # Before: three large inline objects anyOf: - type: object properties: { ... hundreds of lines ... } # After $ref: '#/components/schemas/StreamGetResponse' ``` --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #259277
Summary
Improves the Streams and Streamlang OAS output by eliminating deeply nested
anyOf > anyOf > allOfstructures in the generated spec. The root cause was that.meta({ id })calls for most schemas lived only in theoas_definitions.tsregistry files rather than at definition time. Because Zod v4's.meta()is immutable (it returns a new schema without modifying the original), the exported schema variables themselves were never registered — so every consumer inlined the full schema instead of emitting a$ref.Root cause
When conditionSchema was used in
routingDefinitionSchema.where, the OAS generator had no id to look up, so it inlined the full recursive union. The fix is to call.meta({ id })at definition time so the exported variable itself is the registered schema.Before / after
PUT /api/streams/{name}request bodyGET /api/streams/{name}response