forked from loafle/openapi-generator-original
[Java] Fix compilation for Map of InnerEnum (#19401)
This commit is contained in:
parent
cdafa5a0cc
commit
8ce332a540
@ -4323,7 +4323,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
if (baseItem != null) {
|
if (baseItem != null) {
|
||||||
// set both datatype and datetypeWithEnum as only the inner type is enum
|
// set both datatype and datetypeWithEnum as only the inner type is enum
|
||||||
property.datatypeWithEnum = property.datatypeWithEnum.replace(", " + baseItem.baseType, ", " + toEnumName(baseItem));
|
property.datatypeWithEnum = property.datatypeWithEnum.replace(baseItem.baseType + ">", toEnumName(baseItem) + ">");
|
||||||
|
|
||||||
// naming the enum with respect to the language enum naming convention
|
// naming the enum with respect to the language enum naming convention
|
||||||
// e.g. remove [], {} from array/map of enum
|
// e.g. remove [], {} from array/map of enum
|
||||||
|
@ -2317,6 +2317,25 @@ public class JavaClientCodegenTest {
|
|||||||
.bodyContainsLines("if (b.value.equals(value)) {");
|
.bodyContainsLines("if (b.value.equals(value)) {");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMapOfInnerEnum_issue19393() {
|
||||||
|
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue_19393_map_of_inner_enum.yaml");
|
||||||
|
final JavaClientCodegen codegen = new JavaClientCodegen();
|
||||||
|
codegen.setOpenAPI(openAPI);
|
||||||
|
codegen.setOutputDir(newTempFolder().toString());
|
||||||
|
|
||||||
|
Map<String, File> files = new DefaultGenerator().opts(new ClientOptInput().openAPI(openAPI).config(codegen))
|
||||||
|
.generate().stream().collect(Collectors.toMap(File::getName, Function.identity()));
|
||||||
|
|
||||||
|
JavaFileAssert.assertThat(files.get("EmployeeWithMapOfEnum.java"))
|
||||||
|
.assertProperty("projectRole")
|
||||||
|
.withType("Map<String, InnerEnum>");
|
||||||
|
|
||||||
|
JavaFileAssert.assertThat(files.get("EmployeeWithMultiMapOfEnum.java"))
|
||||||
|
.assertProperty("projectRoles")
|
||||||
|
.withType("Map<String, Set<InnerEnum>>");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWebClientResponseTypeWithUseAbstractionForFiles_issue16589() {
|
public void testWebClientResponseTypeWithUseAbstractionForFiles_issue16589() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
openapi: 3.0.0
|
||||||
|
info:
|
||||||
|
version: 1.0.0
|
||||||
|
title: OpenAPI Test API
|
||||||
|
license:
|
||||||
|
name: Apache-2.0
|
||||||
|
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
|
||||||
|
paths:
|
||||||
|
/status:
|
||||||
|
get:
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: desc
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
EmployeeWithMapOfEnum:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
projectRole:
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- DEVELOPER
|
||||||
|
- TESTER
|
||||||
|
- OWNER
|
||||||
|
EmployeeWithMultiMapOfEnum:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
projectRoles:
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
uniqueItems: true
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- DEVELOPER
|
||||||
|
- TESTER
|
||||||
|
- OWNER
|
Loading…
x
Reference in New Issue
Block a user