chore: refactor date library usage to use CodegenConstants.DATE_LIBRARY#12695
chore: refactor date library usage to use CodegenConstants.DATE_LIBRARY#12695ChihweiLHBird wants to merge 1 commit intoswagger-api:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors Java/Kotlin codegen option handling so dateLibrary is sourced from the shared CodegenConstants.DATE_LIBRARY, reducing duplication across language families and aligning option keys.
Changes:
- Introduce
CodegenConstants.DATE_LIBRARYand update generators/tests to use it. - Add
@Deprecatedaliases forDATE_LIBRARYinAbstractJavaCodegenandKotlinClientCodegen. - Remove
AbstractJavaCodegen’s locally-declaredWITH_XMLconstant and switch internal usage toCodegenConstants.WITH_XML.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/swagger-codegen/src/test/java/io/swagger/codegen/options/KotlinClientCodegenOptionsProvider.java | Update test options to use CodegenConstants.DATE_LIBRARY. |
| modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JaxRSServerOptionsProvider.java | Update test options to use CodegenConstants.DATE_LIBRARY / CodegenConstants.WITH_XML. |
| modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaOptionsProvider.java | Update test options to use CodegenConstants.DATE_LIBRARY / CodegenConstants.WITH_XML. |
| modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java | Switch dateLibrary defaulting check to CodegenConstants.DATE_LIBRARY. |
| modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/KotlinClientCodegen.java | Deprecate local DATE_LIBRARY constant and use CodegenConstants.DATE_LIBRARY throughout. |
| modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java | Deprecate local DATE_LIBRARY, remove local WITH_XML, and use CodegenConstants keys internally. |
| modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java | Add shared DATE_LIBRARY constant. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java
Show resolved
Hide resolved
modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java
Outdated
Show resolved
Hide resolved
3f03898 to
9195974
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java
Show resolved
Hide resolved
...les/swagger-codegen/src/test/java/io/swagger/codegen/options/JaxRSServerOptionsProvider.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
9195974 to
8bb064a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java:65
WITH_XMLis still declared locally inAbstractJavaCodegeneven thoughCodegenConstants.WITH_XMLalready exists. This keeps the shadowing/duplication the PR description says was removed, and makes it easy for the two definitions to drift. Consider removing the localWITH_XMLconstant and switching its usages toCodegenConstants.WITH_XML(or, if you need backward compatibility for external references, keep a deprecated alias similar toDATE_LIBRARY).
public static final String DEFAULT_LIBRARY = "<default>";
public static final String JAVA8_MODE = "java8";
public static final String JAVA11_MODE = "java11";
public static final String SUPPORT_ASYNC = "supportAsync";
public static final String WITH_XML = "withXml";
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\.3.0.0branch for changes related to OpenAPI spec 3.0. Default:master.Description of the PR
Since this may be considered as a breaking change, I would like to leave the decision making to the team.
DATE_LIBRARYtoCodegenConstantsas it is shared acrossthe Java and Kotlin language families
@Deprecatedaliases inAbstractJavaCodegenandKotlinClientCodegenfor backward compatibility