[BUG] Generator 3.3.4 does not respect Java import mapping for string refs
Created by: chrylis
Description
I am trying to map a custom data type to a JSON string-valued property (more or less equivalent to a custom format); Jackson will transparently handle the conversion for me in Java. However, the generator does not observe user custom mappings when a $ref
type is marked as a string.
openapi-generator version
This behavior is observed with 3.3.4
OpenAPI content
# correctly identifies that EntityIdentifier is a string and produces a Map<String, String>,
# but does not use the LSP to use a custom data type
components:
schemas:
EntityIdentifier:
type: string
pattern: '^\w+:[\w\d-]+$'
ResolveExpressionRequest:
type: object
properties:
expression:
type: string
minLength: 1
rootObject:
type: object
additionalProperties:
$ref: '#/components/schemas/EntityIdentifier'
# Generates a Map<String, EntityIdentifierDto>
components:
schemas:
EntityIdentifier:
type: object
ResolveExpressionRequest:
type: object
properties:
expression:
type: string
minLength: 1
rootObject:
type: object
additionalProperties:
$ref: '#/components/schemas/EntityIdentifier'
Command line used for generation
Invoked via Maven plugin:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>3.3.4</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/openapi/openapi.yaml</inputSpec>
<generatorName>java</generatorName>
<importMappings>EntityIdentifier=foo.EntityIdentifierDto</importMappings>
<configOptions>
<library>resttemplate</library>
<java8>true</java8>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Steps to reproduce
As above, a $ref
that is of type: string
does not get overridden by the custom mapping.