fix: generate requestBody for messages with oneOf and path params#234
Merged
sudorandom merged 1 commit intosudorandom:mainfrom Mar 6, 2026
Conversation
When a message has both regular fields and oneOf fields, MessageToSchema wraps them under AllOf and sets Properties to nil. The body:"*" code path only checked s.Properties, so it skipped generating the requestBody entirely for these messages. Look for properties inside the AllOf entries when s.Properties is nil, and check for AllOf/OneOf content when deciding whether to emit a requestBody. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 tasks
2 tasks
livio-a
pushed a commit
to zitadel/zitadel
that referenced
this pull request
Mar 6, 2026
# Which Problems Are Solved 1. `oneOf` variant sub-schemas generated from proto `oneof` fields missing `type: "object"`. This causes fumadocs to skip rendering the properties within each variant. Example: https://zitadel.com/docs/reference/api/internal_permission/zitadel.internal_permission.v2.InternalPermissionService.CreateAdministrator [Before](https://zitadel.com/docs/reference/api/internal_permission/zitadel.internal_permission.v2.InternalPermissionService.CreateAdministrator): <img width="977" height="823" alt="Screenshot 2026-03-06 at 09 56 38" src="https://github.com/user-attachments/assets/54ddbbbb-f36b-4a2a-96af-13b3da41de3b" /> [After](https://docs-git-bump-protoc-gen-connect-openapi-version-zitadel.vercel.app/docs/reference/api/internal_permission/zitadel.internal_permission.v2.InternalPermissionService.CreateAdministrator): <img width="964" height="1021" alt="Screenshot 2026-03-06 at 09 56 47" src="https://github.com/user-attachments/assets/a461c4b5-44fe-487b-b4d2-8af47d407d3e" /> 2. missing requestBody for messages with oneOf and path params. Example: https://zitadel.com/docs/reference/api/user/zitadel.user.v2.UserService.UpdateUser [Before](https://zitadel.com/docs/reference/api/user/zitadel.user.v2.UserService.UpdateUser): <img width="994" height="883" alt="Screenshot 2026-03-06 at 09 59 03" src="https://github.com/user-attachments/assets/824f4154-3270-45d7-9af7-a28c7bdc7c44" /> [After](https://docs-git-bump-protoc-gen-connect-openapi-version-zitadel.vercel.app/docs/reference/api/user/zitadel.user.v2.UserService.UpdateUser): <img width="978" height="1293" alt="Screenshot 2026-03-06 at 09 59 25" src="https://github.com/user-attachments/assets/330c1204-ccce-402c-bccb-b27076198dcd" /> (fuma-nama/fumadocs#3063 will also be updated with improved `oneOf` visualization in this case.) # How the Problems Are Solved By fixing `protoc-gen-connect-openapi` to correctly generate the OpenAPI docs. # Additional Changes n/a # Additional Context sudorandom/protoc-gen-connect-openapi#233 sudorandom/protoc-gen-connect-openapi#234
This was referenced Mar 6, 2026
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.
Summary
Fix missing
requestBodyin generated OpenAPI specs for RPCs that usebody: "*"with path parameters when the request message containsoneOffields.Problem
When a proto message has both regular fields and
oneOffields,MessageToSchema()restructures the schema by wrappingPropertiesandOneOfunder anAllOfand settingPropertiestonil:The
body: "*"handling in paths.go then checkss.Properties != nilbefore generating therequestBody. Since Properties was moved intoAllOf, this check fails and the entire request body is silently dropped.For example, this proto:
Previously generated an operation with no
requestBodyat all. After this fix it correctly generates a body with name and the profile/settings oneOf.Test
Added a
path_paramstest scenario with an UpdateRequest message that combines a path parameter, a regular field, and a oneOf group