Open Bragolgirith opened 2 months ago
I think the problem is in the DefaultCodegen#updateDataTypeWithEnumForMap
method, on line 4278:
property.datatypeWithEnum = property.datatypeWithEnum.replace(", " + baseItem.baseType, ", " + toEnumName(baseItem));
This will correctly replace a non-parameterized value type, e.g.:
Map<String, String>
-> Map<String, InnerEnum>
but it will fail to replace a parameterized value type, e.g.:
Map<String, Set<String>>
-> Map<String, Set<InnerEnum>>
as it will try to match a ", String"
pattern that doesn't exist.
One (naive) idea could be to simply use the following replacement instead, which should work with both parameterized and non-parameterized value types:
property.datatypeWithEnum = property.datatypeWithEnum.replace(baseItem.baseType + ">", toEnumName(baseItem) + ">")
Description
I have the following schema that describes the different roles an employee can have in different projects as a map of collection of enum, e.g.:
This works correctly with most generators, however the
java
generator seems to have some trouble with it and generates an invalidEmployee.java class
:The compiler error is as follows
Note that the issue only occurs for inline enums (i.e.
InnerEnum
s); enum references work as expected.openapi-generator version
Tested using
openapi-generator
version 7.8.0.OpenAPI declaration file content
A gist with a minimal OpenAPI spec file to reproduce the issue can be found here.
Generation Details
I'm generating the Java client using the
openapi-generator-maven-plugin
as follows:Steps to reproduce