swagger-api / swagger-api/swagger-codegen
oneOf not able to generate java class
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
openapi-generator for java is not able to generate class for oneOf field
/Users/....../CustomClass.java:[23,41] cannot find symbol
[ERROR] symbol: class OneOfstringinteger
CustomClass.java class is created with the field
public static final String SERIALIZED_NAME_FIELD_VALUE = "fieldValue";
@SerializedName(SERIALIZED_NAME_FIELD_VALUE)
private OneOfstringinteger fieldValue = null;
But OneOfstringinteger is not getting created.
Swagger-codegen version
org.openapitools openapi-generator-maven-plugin 4.1.1Swagger declaration file content or url
fieldValue:
oneOf:
- type: string
- type: integer
Command line used for generation
mvn clean install takes care of it
Steps to reproduce
trying to build the project by maven command
Related issues/PRs
Suggest a fix/enhancement
open-api generator for java is not able to generate a class for oneOf type for primitive objects (string, integer, number etc).
tried with objects also but same error came:
fieldValue:
oneOf:
- $ref: '#/definitions/StringValue'
- $ref: '#/definitions/NumberValue'
definitions:
StringValue:
type: object
properties:
name:
type: string
NumberValue:
type: object
properties:
name:
type: number
cannot find symbol
[ERROR] symbol: class OneOfStringValueNumberValue
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the OpenAPI schema's oneOf definitions and the generated CustomClass.java, then run the reported mvn clean install command to reproduce the missing OneOfstringinteger or OneOfStringValueNumberValue class. Done means the required Java classes are generated for primitive and referenced oneOf members and the Maven build no longer reports cannot find symbol.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100