Repository navigation
[Java] fix: map the OAS 3.1 null type to Object, not a never-generated ModelNull - #24935
Merged
wing328 merged 1 commit intoSep 14, 2026
Merged
Conversation
…d ModelNull
AbstractJavaCodegen has no "null" entry in typeMapping, so getSchemaType falls
through to toModelName("null"). "null" is a Java reserved word, so the model
name becomes ModelNull, a class the generator never emits, and the generated
client does not compile. Python, Go, Elixir and Xojo already map "null" in
their typeMapping; this adds the Java one.
The 3_1 java fixture gains third_property with the quoted form of the null
type. The existing second_property uses unquoted "type: null", which YAML
reads as a null scalar, so that property carries no type at all and already
generated Object. Only bin/configs/java-okhttp-gson-3.1.yaml consumes this
fixture, and samples-java-petsore-client-jdk11 builds that sample, so the
regression is now covered in CI.
Member
|
thanks for the PR cc @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) |
rar91279
added a commit
to rar91279/openapi-generator
that referenced
this pull request
Sep 14, 2026
Picks up OpenAPITools#24935, which maps the OAS 3.1 null type to Object instead of a never-generated ModelNull. The 3.1 test spec gained a third_property declaring the null type as the OAS 3.1 quoted string, so the sample now carries that property as Object. Regenerating all 129 java configs and exporting the generator docs produced no other change.
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.
A Java property declared
type: 'null'becomesModelNull, which is never emitted, so generated clients fail to compile (regression in 7.17.0).AbstractJavaCodegenlacks anulltypeMapping, sogetSchemaTypefalls through totoModelName("null"), where the reserved-word rule prefixesModel. Python, Go, Elixir, and Xojo already mapnull.#24701 used unquoted
type: null, which YAML parses as a null scalar, so it did not exercise this path.third_propertyadds the quoted form. Reverting the mapping makes the new unit test and sample compilation fail; patched, the sample compiles and the module suite passes 4,985 tests.TypeScript still has this gap, so Ref #24520, not Fixes.
Summary by cubic
Maps the OAS 3.1
nulltype toObjectin Java codegen so properties declaredtype: 'null'no longer generate a reference toModelNull, a class the generator never emits. This was a regression in 7.17.0 that made generated clients fail to compile; Python, Go, Elixir, and Xojo already mapnull.Bug Fixes
type: null, which YAML parses as a null scalar, so it didn't exercise this path; the newthird_propertyuses the quoted form.Written for commit 412e049. Summary will update on new commits.