[REQ][JAVA] oneOf discriminator type string with enum defined
Created by: tedberg
Description
Using version 6 beta, oneOf is working well, generating POJOs. We get the interface with public String getType();
and the impl classes. The type we want to use had previously been defined as a string/enum, so it would be nice if we could define teh discriminator string to also be an enum.
openapi-generator version
6.0.0-beta
OpenAPI declaration file content or url
title: Type
type: string
default: "A"
enum:
- "A"
- "B"
- "C"
Our discriminator is setup like this.
title: Example
type: object
discriminator:
propertyName: type
type: string
mapping:
A: './A.yaml'
B: './B.yaml'
C: './C.yaml'
oneOf:
- $ref: './A.yaml'
- $ref: './B.yaml'
- $ref: './C.yaml'
The A object adds the type property, referencing the string with enum above.
title: A
type: object
properties:
type:
$ref: './Type.yaml'
...
If we remove the enum part, everything generates properly and works with type as a String object. Seeing that the mapping is essentially an enum itself, it would be nice, if the above would work, generating public Type getType();
in the interface. (It already generates nicely with enum in the implementing classes.)
Command line used for generation
Maven plugin,
<openapi.generator.maven.plugin.templateResourcePath>JavaSpring</openapi.generator.maven.plugin.templateResourcePath>