diff --git a/bin/configs/java-okhttp-gson.yaml b/bin/configs/java-okhttp-gson.yaml index 8f5c07cae49c..a5c109e1a38d 100644 --- a/bin/configs/java-okhttp-gson.yaml +++ b/bin/configs/java-okhttp-gson.yaml @@ -15,6 +15,7 @@ additionalProperties: useOneOfDiscriminatorLookup: true disallowAdditionalPropertiesIfNotPresent: false useReflectionEqualsHashCode:: true + removeEnumValuePrefix: true enumNameMappings: s: LOWER_CASE_S S: UPPER_CASE_S diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 3f8dd1f80424..434983fb5e06 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -297,7 +297,7 @@ apiTemplateFiles are for API outputs only (controllers/handlers). // acts strictly upon a spec, potentially modifying it to have consistent behavior across generators. protected boolean strictSpecBehavior = true; // flag to indicate whether enum value prefixes are removed - protected boolean removeEnumValuePrefix = true; + protected boolean removeEnumValuePrefix = false; // Support legacy logic for evaluating discriminators @Setter protected boolean legacyDiscriminatorBehavior = true; diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java index 3eef324a7bdb..a59c1528086a 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java @@ -889,6 +889,7 @@ public void updateCodegenPropertyEnumWithExtension() { @Test public void updateCodegenPropertyEnumWithPrefixRemoved() { final DefaultCodegen codegen = new DefaultCodegen(); + codegen.setRemoveEnumValuePrefix(true); CodegenProperty enumProperty = codegenProperty(Arrays.asList("animal_dog", "animal_cat")); codegen.updateCodegenPropertyEnum(enumProperty); @@ -925,6 +926,7 @@ public void updateCodegenPropertyEnumWithoutPrefixRemoved() { @Test public void postProcessModelsEnumWithPrefixRemoved() { final DefaultCodegen codegen = new DefaultCodegen(); + codegen.setRemoveEnumValuePrefix(true); ModelsMap objs = codegenModel(Arrays.asList("animal_dog", "animal_cat")); CodegenModel cm = objs.getModels().get(0).getModel(); diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/CodesEnum.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/CodesEnum.md index efdb32e2ce37..15fb076ca72b 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/CodesEnum.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/CodesEnum.md @@ -5,11 +5,11 @@ ## Enum -* `_1` (value: `"Code 1"`) +* `CODE_1` (value: `"Code 1"`) -* `_2` (value: `"Code 2"`) +* `CODE_2` (value: `"Code 2"`) -* `_3` (value: `"Code 3"`) +* `CODE_3` (value: `"Code 3"`) diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/CodesEnum.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/CodesEnum.java index 9d6d575fa550..84ac24f392db 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/CodesEnum.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/CodesEnum.java @@ -29,11 +29,11 @@ @JsonAdapter(CodesEnum.Adapter.class) public enum CodesEnum { - _1("Code 1"), + CODE_1("Code 1"), - _2("Code 2"), + CODE_2("Code 2"), - _3("Code 3"); + CODE_3("Code 3"); private String value; diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/unique_item_array_testing.rs b/samples/client/petstore/rust/hyper/petstore/src/models/unique_item_array_testing.rs index 2a1f18ca9cee..bddcf9d5c195 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/unique_item_array_testing.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/unique_item_array_testing.rs @@ -31,16 +31,16 @@ impl UniqueItemArrayTesting { #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] pub enum UniqueItemArray { #[serde(rename = "unique_item_1")] - Variant1, + UniqueItem1, #[serde(rename = "unique_item_2")] - Variant2, + UniqueItem2, #[serde(rename = "unique_item_3")] - Variant3, + UniqueItem3, } impl Default for UniqueItemArray { fn default() -> UniqueItemArray { - Self::Variant1 + Self::UniqueItem1 } } diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/unique_item_array_testing.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/unique_item_array_testing.rs index 2a1f18ca9cee..bddcf9d5c195 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/src/models/unique_item_array_testing.rs +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/unique_item_array_testing.rs @@ -31,16 +31,16 @@ impl UniqueItemArrayTesting { #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] pub enum UniqueItemArray { #[serde(rename = "unique_item_1")] - Variant1, + UniqueItem1, #[serde(rename = "unique_item_2")] - Variant2, + UniqueItem2, #[serde(rename = "unique_item_3")] - Variant3, + UniqueItem3, } impl Default for UniqueItemArray { fn default() -> UniqueItemArray { - Self::Variant1 + Self::UniqueItem1 } } diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/unique_item_array_testing.rs b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/unique_item_array_testing.rs index 2a1f18ca9cee..bddcf9d5c195 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/unique_item_array_testing.rs +++ b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/unique_item_array_testing.rs @@ -31,16 +31,16 @@ impl UniqueItemArrayTesting { #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] pub enum UniqueItemArray { #[serde(rename = "unique_item_1")] - Variant1, + UniqueItem1, #[serde(rename = "unique_item_2")] - Variant2, + UniqueItem2, #[serde(rename = "unique_item_3")] - Variant3, + UniqueItem3, } impl Default for UniqueItemArray { fn default() -> UniqueItemArray { - Self::Variant1 + Self::UniqueItem1 } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/unique_item_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/unique_item_array_testing.rs index 2a1f18ca9cee..bddcf9d5c195 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/unique_item_array_testing.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/unique_item_array_testing.rs @@ -31,16 +31,16 @@ impl UniqueItemArrayTesting { #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] pub enum UniqueItemArray { #[serde(rename = "unique_item_1")] - Variant1, + UniqueItem1, #[serde(rename = "unique_item_2")] - Variant2, + UniqueItem2, #[serde(rename = "unique_item_3")] - Variant3, + UniqueItem3, } impl Default for UniqueItemArray { fn default() -> UniqueItemArray { - Self::Variant1 + Self::UniqueItem1 } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/unique_item_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/unique_item_array_testing.rs index 2a1f18ca9cee..bddcf9d5c195 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/unique_item_array_testing.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/unique_item_array_testing.rs @@ -31,16 +31,16 @@ impl UniqueItemArrayTesting { #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] pub enum UniqueItemArray { #[serde(rename = "unique_item_1")] - Variant1, + UniqueItem1, #[serde(rename = "unique_item_2")] - Variant2, + UniqueItem2, #[serde(rename = "unique_item_3")] - Variant3, + UniqueItem3, } impl Default for UniqueItemArray { fn default() -> UniqueItemArray { - Self::Variant1 + Self::UniqueItem1 } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/unique_item_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/unique_item_array_testing.rs index 2a1f18ca9cee..bddcf9d5c195 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/models/unique_item_array_testing.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/unique_item_array_testing.rs @@ -31,16 +31,16 @@ impl UniqueItemArrayTesting { #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] pub enum UniqueItemArray { #[serde(rename = "unique_item_1")] - Variant1, + UniqueItem1, #[serde(rename = "unique_item_2")] - Variant2, + UniqueItem2, #[serde(rename = "unique_item_3")] - Variant3, + UniqueItem3, } impl Default for UniqueItemArray { fn default() -> UniqueItemArray { - Self::Variant1 + Self::UniqueItem1 } } diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/unique_item_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/unique_item_array_testing.rs index 2a1f18ca9cee..bddcf9d5c195 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/unique_item_array_testing.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/unique_item_array_testing.rs @@ -31,16 +31,16 @@ impl UniqueItemArrayTesting { #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] pub enum UniqueItemArray { #[serde(rename = "unique_item_1")] - Variant1, + UniqueItem1, #[serde(rename = "unique_item_2")] - Variant2, + UniqueItem2, #[serde(rename = "unique_item_3")] - Variant3, + UniqueItem3, } impl Default for UniqueItemArray { fn default() -> UniqueItemArray { - Self::Variant1 + Self::UniqueItem1 } } diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/unique_item_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/unique_item_array_testing.rs index 2a1f18ca9cee..bddcf9d5c195 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/unique_item_array_testing.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/unique_item_array_testing.rs @@ -31,16 +31,16 @@ impl UniqueItemArrayTesting { #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] pub enum UniqueItemArray { #[serde(rename = "unique_item_1")] - Variant1, + UniqueItem1, #[serde(rename = "unique_item_2")] - Variant2, + UniqueItem2, #[serde(rename = "unique_item_3")] - Variant3, + UniqueItem3, } impl Default for UniqueItemArray { fn default() -> UniqueItemArray { - Self::Variant1 + Self::UniqueItem1 } } diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_unique_item_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_unique_item_array_testing.rs index 5091809a3372..22ab4a0d71e0 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_unique_item_array_testing.rs +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_unique_item_array_testing.rs @@ -31,16 +31,16 @@ impl FooUniqueItemArrayTesting { #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] pub enum UniqueItemArray { #[serde(rename = "unique_item_1")] - Variant1, + UniqueItem1, #[serde(rename = "unique_item_2")] - Variant2, + UniqueItem2, #[serde(rename = "unique_item_3")] - Variant3, + UniqueItem3, } impl Default for UniqueItemArray { fn default() -> UniqueItemArray { - Self::Variant1 + Self::UniqueItem1 } } diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/unique_item_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/unique_item_array_testing.rs index 2a1f18ca9cee..bddcf9d5c195 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/unique_item_array_testing.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/unique_item_array_testing.rs @@ -31,16 +31,16 @@ impl UniqueItemArrayTesting { #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] pub enum UniqueItemArray { #[serde(rename = "unique_item_1")] - Variant1, + UniqueItem1, #[serde(rename = "unique_item_2")] - Variant2, + UniqueItem2, #[serde(rename = "unique_item_3")] - Variant3, + UniqueItem3, } impl Default for UniqueItemArray { fn default() -> UniqueItemArray { - Self::Variant1 + Self::UniqueItem1 } } diff --git a/samples/client/petstore/typescript-axios/builds/with-complex-headers/api.ts b/samples/client/petstore/typescript-axios/builds/with-complex-headers/api.ts index d7728f692e7c..0e70f1dd2fc9 100644 --- a/samples/client/petstore/typescript-axios/builds/with-complex-headers/api.ts +++ b/samples/client/petstore/typescript-axios/builds/with-complex-headers/api.ts @@ -74,8 +74,8 @@ export interface Category { */ export const MediaType = { - Json: 'application/json', - Xml: 'application/xml' + ApplicationJson: 'application/json', + ApplicationXml: 'application/xml' } as const; export type MediaType = typeof MediaType[keyof typeof MediaType];