[FEAT] [jaxrs-spec] Support useEnumCaseInsensitive ConfigOption - #24157
Conversation
|
@wing328 could you please check the pr if u find time? |
Chrimle
left a comment
There was a problem hiding this comment.
LGTM. Surprised that there are no samples being updated though?
6125be9 to
d96f477
Compare
d96f477 to
7d16a45
Compare
|
@Chrimle Just added them :) wasnt sure because a lot of tests for the java generators are empty and have todos but I guess it doesnt hurt to add them for that case. |
| @JsonCreator | ||
| public static EnumClass fromValue(String value) { | ||
| for (EnumClass b : EnumClass.values()) { | ||
| if (b.value.equalsIgnoreCase(value)) { |
| @JsonCreator | ||
| public static IntegerEnum fromValue(Integer value) { | ||
| for (IntegerEnum b : IntegerEnum.values()) { | ||
| if (b.value.equals(value)) { |
| @JsonCreator | ||
| public static StatusEnum fromValue(String value) { | ||
| for (StatusEnum b : StatusEnum.values()) { | ||
| if (b.value.equalsIgnoreCase(value)) { |
| * Gets or Sets OuterEnumDefaultValue | ||
| */ | ||
| @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", comments = "Generator version: 7.24.0-SNAPSHOT") | ||
| public enum OuterEnumDefaultValue { |
There was a problem hiding this comment.
The name of this class suggests there should be some default value? 🤔 Perhaps unrelated to this change though...
| @JsonCreator | ||
| public static OuterEnumInteger fromValue(Integer value) { | ||
| for (OuterEnumInteger b : OuterEnumInteger.values()) { | ||
| if (b.value.equals(value)) { |
There was a problem hiding this comment.
Looks good 👍 (outer integer enum)
| * Gets or Sets OuterEnumIntegerDefaultValue | ||
| */ | ||
| @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", comments = "Generator version: 7.24.0-SNAPSHOT") | ||
| public enum OuterEnumIntegerDefaultValue { |
| public class StringEnumTest { | ||
|
|
||
| @Test | ||
| public void fromValueUsesCaseInsensitiveMatching() { |
Chrimle
left a comment
There was a problem hiding this comment.
LGTM 👍
Did spot some odd Enum-classes though, related to "default"-values. But could be out-of-scope for this, and potentially another feature that isn't properly supported yet...
|
Suggestion for PR title:
|
Add USE_ENUM_CASE_INSENSITIVE for jaxrs-spec generator, mustache files already have that.
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
Adds a
useEnumCaseInsensitiveoption to thejaxrs-specgenerator for case-insensitive String enum matching. Includes a new Petstore sample with tests and updates docs forjaxrs-specandjaxrs-cxf-cdi.useEnumCaseInsensitive(default: false) inorg.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen; exposed to templates viaadditionalProperties.bin/configs/jaxrs-spec-enum.yamland generatedsamples/server/petstore/jaxrs-spec-enum(tests validate case-insensitive.fromValue()for string enums). Updated docs forjaxrs-specandjaxrs-cxf-cdi.Written for commit 7d16a45. Summary will update on new commits.