Skip to content

[Java][Spring] Add examples parameter in @Schema annotation for OAS 3.1 spec - #25003

Open
peter-em wants to merge 2 commits into
OpenAPITools:masterfrom
SabreOSS:feature/support-examples-in-codegen-property
Open

peter-em wants to merge 2 commits into
OpenAPITools:masterfrom
SabreOSS:feature/support-examples-in-codegen-property

Conversation

@peter-em

@peter-em peter-em commented Sep 23, 2026 •

Copy link
Copy Markdown

Added handling of examples keyword for OAS 3.1 spec.
They are generated in the corresponding @Schema annotation, next to the singular example

Resolve #24755

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    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.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Java | @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @martin-mfg (2023/08) @KannaKim (2026/07)

Java Spring | @cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @banlevente (2022/02) @Zomzog (2022/09) @martin-mfg (2023/08) @KannaKim (2026/07)


Summary by cubic

Adds support for the OAS 3.1 examples keyword so Java Spring generators emit it in the @Schema annotation alongside the singular example.

  • Adds an examples property to CodegenProperty, populated from the schema's examples list via new toExampleValues / getExampleValueToString hooks that stringify scalar, array, and object values.
  • Refactors AbstractJavaCodegen.toExampleValue so example and examples share the same string escaping and Date handling; error reporting is consolidated in handleExampleException.
  • Updates the Java Spring pojo.mustache template to render examples = { ... } only when at least one value is present.
  • Adds tests and a sample spec (issue_24755.yaml) covering string, integer, array, object, and empty examples lists.

Resolves #24755.

Written for commit d156fdc. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 6 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@peter-em
peter-em force-pushed the feature/support-examples-in-codegen-property branch from ae66997 to 5d5d531 Compare September 25, 2026 13:58

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 6 files (changes from recent commits).

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.

Re-trigger cubic

@peter-em
peter-em force-pushed the feature/support-examples-in-codegen-property branch 2 times, most recently from 298fee1 to cc246ef Compare September 25, 2026 14:47

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

@peter-em
peter-em force-pushed the feature/support-examples-in-codegen-property branch from cc246ef to d156fdc Compare September 25, 2026 14:58
@peter-em
peter-em force-pushed the feature/support-examples-in-codegen-property branch from d156fdc to 7cb1aa5 Compare September 25, 2026 16:21
@peter-em

Copy link
Copy Markdown
Author

There is already a PR for #24755 similar to this, but it has been inactive for a while now.
If examples support could be included in one of upcoming releases, it would be useful for my company's project, so I decided to create a new PR.

This branch has not been deployed

No deployments
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.

[BUG][Java][Spring] Missing examples parameter in @Schema annotation for OAS 3.1 spec

1 participant