refactor: unify handling of content examples parsing - #24653
Merged
wing328 merged 1 commit intoAug 10, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 8 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Mattias-Sehlstedt
force-pushed
the
harmonize-content-example-parsing
branch
2 times, most recently
from
August 9, 2026 22:27
8f70e09 to
d0bdd79
Compare
Mattias-Sehlstedt
force-pushed
the
harmonize-content-example-parsing
branch
from
August 9, 2026 22:36
d0bdd79 to
ba4d18e
Compare
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.
I saw #24651 that changes what request body example structure that is propagated to the mustache template. It only changed
AbstractJavaCodegenrather thanDefaultCodegen, so I got curious regarding why this was the case. I would expect this change to be of interest to all generators. The reason seemed to be thatJavaoverrode the default to some extent.I have analyzed the structure and found that the generators still have almost everything in common, and that one is basically just the extension of the other. I have thus centralized the logic in the existing
ExamplesUtils, and then used that in the different implementers. The reason for this is to ensure that all generators will benefit from improvements when they are introduced (e.g., all only read the first media type, but if someone introduces so that all are read, then that is also something all generators will want to be able to utilize).This PR also centralized the definition of the reoccurring
x-examplevendor extension.PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
Summary by cubic
Unifies request body example parsing by centralizing logic in
ExamplesUtils.getContentExample. Standardizes thex-examplevendor extension withCodegenConstants.X_EXAMPLEfor consistent behavior and logging.ExamplesUtils.getContentExampleand uses it inDefaultCodegenandTypeScriptClientCodegen;AbstractJavaCodegenkeeps model behavior (warn and ignore complex examples) and delegates to shared logic for primitives."x-example"withCodegenConstants.X_EXAMPLEinDefaultCodegen,AbstractJavaCodegen,AbstractFSharpCodegen,TypeScriptClientCodegen,RustServerCodegen, andRustServerCodegenDeprecated.ExamplesUtils.Written for commit ba4d18e. Summary will update on new commits.