You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Generator 3.3.4 does not respect Java import mapping for string refs #2858
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 typecomponents:
schemas:
EntityIdentifier:
type: stringpattern: '^\w+:[\w\d-]+$'ResolveExpressionRequest:
type: objectproperties:
expression:
type: stringminLength: 1rootObject:
type: objectadditionalProperties:
$ref: '#/components/schemas/EntityIdentifier'
changed the title [-][BUG] Generator 3.3.4 does not respect language-specific primitive for string refs[/-][+][BUG] Generator 3.3.4 does not respect Java import mapping for string refs[/+]on May 10, 2019
After noticing something else, I tried removing the language-specific primitive that was suggested in docs; the import mapping is the controlling variable and is both necessary and sufficient for this use case (although apparently having a completely flat namespace for the $ref types is a little concerning).
With 4.0.0.beta3, this substitution fails in both cases. In the case of type: string, the Java type is java.lang.String, and with type: object, it is java.lang.Object.
This bug is still present in 4.2.1. Specifically, it presents when either the custom type is of type: string (think something like a UUID) or when the custom type is of type: objectbut does not have properties defined. Only when the custom type has at least one property is the import mapping respected.
Activity
[-][BUG] Generator 3.3.4 does not respect language-specific primitive for string refs[/-][+][BUG] Generator 3.3.4 does not respect Java import mapping for string refs[/+]chrylis commentedon May 10, 2019
After noticing something else, I tried removing the language-specific primitive that was suggested in docs; the import mapping is the controlling variable and is both necessary and sufficient for this use case (although apparently having a completely flat namespace for the
$reftypes is a little concerning).wing328 commentedon May 10, 2019
You may also want to try the latest master (the snapshot version can be found in the README)
chrylis commentedon May 10, 2019
With 4.0.0.beta3, this substitution fails in both cases. In the case of
type: string, the Java type isjava.lang.String, and withtype: object, it isjava.lang.Object.java: allow aliased types to have custom mappings
chrylis commentedon Nov 17, 2019
This bug is still present in 4.2.1. Specifically, it presents when either the custom type is of
type: string(think something like a UUID) or when the custom type is oftype: objectbut does not have properties defined. Only when the custom type has at least one property is the import mapping respected.wing328 commentedon Nov 17, 2019
What about using something like the following instead?
I remember it works for type mapping but not sure about import mapping. Please give it a try.