Skip to content

Commit 09530b4

Browse files
authored
Set removeEnumValuePrefix to false by default (#20452)
* set removeEnumValuePrefix to false by default * update tests
1 parent 479cd52 commit 09530b4

File tree

16 files changed

+52
-49
lines changed

16 files changed

+52
-49
lines changed

bin/configs/java-okhttp-gson.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ additionalProperties:
1515
useOneOfDiscriminatorLookup: true
1616
disallowAdditionalPropertiesIfNotPresent: false
1717
useReflectionEqualsHashCode:: true
18+
removeEnumValuePrefix: true
1819
enumNameMappings:
1920
s: LOWER_CASE_S
2021
S: UPPER_CASE_S

modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ apiTemplateFiles are for API outputs only (controllers/handlers).
297297
// acts strictly upon a spec, potentially modifying it to have consistent behavior across generators.
298298
protected boolean strictSpecBehavior = true;
299299
// flag to indicate whether enum value prefixes are removed
300-
protected boolean removeEnumValuePrefix = true;
300+
protected boolean removeEnumValuePrefix = false;
301301

302302
// Support legacy logic for evaluating discriminators
303303
@Setter protected boolean legacyDiscriminatorBehavior = true;

modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,7 @@ public void updateCodegenPropertyEnumWithExtension() {
889889
@Test
890890
public void updateCodegenPropertyEnumWithPrefixRemoved() {
891891
final DefaultCodegen codegen = new DefaultCodegen();
892+
codegen.setRemoveEnumValuePrefix(true);
892893
CodegenProperty enumProperty = codegenProperty(Arrays.asList("animal_dog", "animal_cat"));
893894

894895
codegen.updateCodegenPropertyEnum(enumProperty);
@@ -925,6 +926,7 @@ public void updateCodegenPropertyEnumWithoutPrefixRemoved() {
925926
@Test
926927
public void postProcessModelsEnumWithPrefixRemoved() {
927928
final DefaultCodegen codegen = new DefaultCodegen();
929+
codegen.setRemoveEnumValuePrefix(true);
928930
ModelsMap objs = codegenModel(Arrays.asList("animal_dog", "animal_cat"));
929931
CodegenModel cm = objs.getModels().get(0).getModel();
930932

samples/client/petstore/java/okhttp-gson-3.1/docs/CodesEnum.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
## Enum
66

77

8-
* `_1` (value: `"Code 1"`)
8+
* `CODE_1` (value: `"Code 1"`)
99

10-
* `_2` (value: `"Code 2"`)
10+
* `CODE_2` (value: `"Code 2"`)
1111

12-
* `_3` (value: `"Code 3"`)
12+
* `CODE_3` (value: `"Code 3"`)
1313

1414

1515

samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/CodesEnum.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
@JsonAdapter(CodesEnum.Adapter.class)
3030
public enum CodesEnum {
3131

32-
_1("Code 1"),
32+
CODE_1("Code 1"),
3333

34-
_2("Code 2"),
34+
CODE_2("Code 2"),
3535

36-
_3("Code 3");
36+
CODE_3("Code 3");
3737

3838
private String value;
3939

samples/client/petstore/rust/hyper/petstore/src/models/unique_item_array_testing.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ impl UniqueItemArrayTesting {
3131
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
3232
pub enum UniqueItemArray {
3333
#[serde(rename = "unique_item_1")]
34-
Variant1,
34+
UniqueItem1,
3535
#[serde(rename = "unique_item_2")]
36-
Variant2,
36+
UniqueItem2,
3737
#[serde(rename = "unique_item_3")]
38-
Variant3,
38+
UniqueItem3,
3939
}
4040

4141
impl Default for UniqueItemArray {
4242
fn default() -> UniqueItemArray {
43-
Self::Variant1
43+
Self::UniqueItem1
4444
}
4545
}
4646

samples/client/petstore/rust/hyper0x/petstore/src/models/unique_item_array_testing.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ impl UniqueItemArrayTesting {
3131
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
3232
pub enum UniqueItemArray {
3333
#[serde(rename = "unique_item_1")]
34-
Variant1,
34+
UniqueItem1,
3535
#[serde(rename = "unique_item_2")]
36-
Variant2,
36+
UniqueItem2,
3737
#[serde(rename = "unique_item_3")]
38-
Variant3,
38+
UniqueItem3,
3939
}
4040

4141
impl Default for UniqueItemArray {
4242
fn default() -> UniqueItemArray {
43-
Self::Variant1
43+
Self::UniqueItem1
4444
}
4545
}
4646

samples/client/petstore/rust/reqwest-trait/petstore/src/models/unique_item_array_testing.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ impl UniqueItemArrayTesting {
3131
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
3232
pub enum UniqueItemArray {
3333
#[serde(rename = "unique_item_1")]
34-
Variant1,
34+
UniqueItem1,
3535
#[serde(rename = "unique_item_2")]
36-
Variant2,
36+
UniqueItem2,
3737
#[serde(rename = "unique_item_3")]
38-
Variant3,
38+
UniqueItem3,
3939
}
4040

4141
impl Default for UniqueItemArray {
4242
fn default() -> UniqueItemArray {
43-
Self::Variant1
43+
Self::UniqueItem1
4444
}
4545
}
4646

samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/unique_item_array_testing.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ impl UniqueItemArrayTesting {
3131
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
3232
pub enum UniqueItemArray {
3333
#[serde(rename = "unique_item_1")]
34-
Variant1,
34+
UniqueItem1,
3535
#[serde(rename = "unique_item_2")]
36-
Variant2,
36+
UniqueItem2,
3737
#[serde(rename = "unique_item_3")]
38-
Variant3,
38+
UniqueItem3,
3939
}
4040

4141
impl Default for UniqueItemArray {
4242
fn default() -> UniqueItemArray {
43-
Self::Variant1
43+
Self::UniqueItem1
4444
}
4545
}
4646

samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/unique_item_array_testing.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ impl UniqueItemArrayTesting {
3131
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
3232
pub enum UniqueItemArray {
3333
#[serde(rename = "unique_item_1")]
34-
Variant1,
34+
UniqueItem1,
3535
#[serde(rename = "unique_item_2")]
36-
Variant2,
36+
UniqueItem2,
3737
#[serde(rename = "unique_item_3")]
38-
Variant3,
38+
UniqueItem3,
3939
}
4040

4141
impl Default for UniqueItemArray {
4242
fn default() -> UniqueItemArray {
43-
Self::Variant1
43+
Self::UniqueItem1
4444
}
4545
}
4646

samples/client/petstore/rust/reqwest/petstore-async/src/models/unique_item_array_testing.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ impl UniqueItemArrayTesting {
3131
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
3232
pub enum UniqueItemArray {
3333
#[serde(rename = "unique_item_1")]
34-
Variant1,
34+
UniqueItem1,
3535
#[serde(rename = "unique_item_2")]
36-
Variant2,
36+
UniqueItem2,
3737
#[serde(rename = "unique_item_3")]
38-
Variant3,
38+
UniqueItem3,
3939
}
4040

4141
impl Default for UniqueItemArray {
4242
fn default() -> UniqueItemArray {
43-
Self::Variant1
43+
Self::UniqueItem1
4444
}
4545
}
4646

samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/unique_item_array_testing.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ impl UniqueItemArrayTesting {
3131
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
3232
pub enum UniqueItemArray {
3333
#[serde(rename = "unique_item_1")]
34-
Variant1,
34+
UniqueItem1,
3535
#[serde(rename = "unique_item_2")]
36-
Variant2,
36+
UniqueItem2,
3737
#[serde(rename = "unique_item_3")]
38-
Variant3,
38+
UniqueItem3,
3939
}
4040

4141
impl Default for UniqueItemArray {
4242
fn default() -> UniqueItemArray {
43-
Self::Variant1
43+
Self::UniqueItem1
4444
}
4545
}
4646

samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/unique_item_array_testing.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ impl UniqueItemArrayTesting {
3131
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
3232
pub enum UniqueItemArray {
3333
#[serde(rename = "unique_item_1")]
34-
Variant1,
34+
UniqueItem1,
3535
#[serde(rename = "unique_item_2")]
36-
Variant2,
36+
UniqueItem2,
3737
#[serde(rename = "unique_item_3")]
38-
Variant3,
38+
UniqueItem3,
3939
}
4040

4141
impl Default for UniqueItemArray {
4242
fn default() -> UniqueItemArray {
43-
Self::Variant1
43+
Self::UniqueItem1
4444
}
4545
}
4646

samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_unique_item_array_testing.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ impl FooUniqueItemArrayTesting {
3131
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
3232
pub enum UniqueItemArray {
3333
#[serde(rename = "unique_item_1")]
34-
Variant1,
34+
UniqueItem1,
3535
#[serde(rename = "unique_item_2")]
36-
Variant2,
36+
UniqueItem2,
3737
#[serde(rename = "unique_item_3")]
38-
Variant3,
38+
UniqueItem3,
3939
}
4040

4141
impl Default for UniqueItemArray {
4242
fn default() -> UniqueItemArray {
43-
Self::Variant1
43+
Self::UniqueItem1
4444
}
4545
}
4646

samples/client/petstore/rust/reqwest/petstore/src/models/unique_item_array_testing.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ impl UniqueItemArrayTesting {
3131
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
3232
pub enum UniqueItemArray {
3333
#[serde(rename = "unique_item_1")]
34-
Variant1,
34+
UniqueItem1,
3535
#[serde(rename = "unique_item_2")]
36-
Variant2,
36+
UniqueItem2,
3737
#[serde(rename = "unique_item_3")]
38-
Variant3,
38+
UniqueItem3,
3939
}
4040

4141
impl Default for UniqueItemArray {
4242
fn default() -> UniqueItemArray {
43-
Self::Variant1
43+
Self::UniqueItem1
4444
}
4545
}
4646

samples/client/petstore/typescript-axios/builds/with-complex-headers/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ export interface Category {
7474
*/
7575

7676
export const MediaType = {
77-
Json: 'application/json',
78-
Xml: 'application/xml'
77+
ApplicationJson: 'application/json',
78+
ApplicationXml: 'application/xml'
7979
} as const;
8080

8181
export type MediaType = typeof MediaType[keyof typeof MediaType];

0 commit comments

Comments
 (0)