Setting dateLibrary=java11 fails to map "java.time" types
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Read AbstractJavaCodegen.java around lines 488–515, then inspect processOpts() and the existing dateLibrary branches. Check how the java11 option is described and how date mappings and imports are configured for related date libraries. Done means selecting dateLibrary=java11 configures the expected java.time mappings and imports without requiring a separate java11=true option.
Written by the indexing model from the issue text.
Description
In the above source code of AbstractJavaCodegen, the dateLibrary enum registers "java11" in the CLI options list. However, the processOpts() method only checks for "threetenbp", "joda", dateLibrary.startsWith("java8"), and "legacy":
• Missing if branch. Because there is no else if ("java11".equals(dateLibrary)) block in AbstractJavaCodegen.processOpts(), the generator skips setting up java.time type mappings and imports.
• Fallback to java.util.Date. By default, AbstractJavaCodegen initializes typeMapping.put("date", "Date"), which resolves to java.util.Date when no dateLibrary branch overrides it.
• Flag discrepancy. Although the CLI description claims "java11" automatically sets java11=true, the code only reads java11 if you explicitly pass true in your configuration.
This leads to the required strange combination of configuration options:
<configOptions>
<!-- don't use "java11" - a bug in swagger lets this fall back to "legacy" -->
<dateLibrary>java8</dateLibrary>
<java11>true</java11>
<jakarta>true</jakarta>
</configOptions>
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from swagger-api/swagger-codegen-generators
-
[Bug]: Python/pythonFlaskConnexion generators validate map keys instead of values for additionalProperties.enumPossibly taken @pvillard31 claimed this 208 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Python generated code: Delete API Requests can be blocked in API Gateways when sends empty bodyOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
[Bug]: Bean validation doesn't work for numbers larger than Integer.MAX_VALUEPossibly taken @apupier claimed this 296 days ago. OpenBug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
swagger-api/swagger-codegen-generators#1370 · 3 comments · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 72/100
All issues in swagger-api/swagger-codegen-generators
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
ROCm/rocm-libraries#15665 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
shadps4-emu/shadPS4#5705 ·
Maintainers usually reply within 1 day
-
bug multiple issues priority: high
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
storytold/gridcraft#3928 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Qiskit/qiskit-aer#2533 ·
Maintainers usually reply within 1 day