OpenAPITools / OpenAPITools/openapi-generator

Unknown Java type created when using oneOf

Open
#8,797 3 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

I am seeing an issue in Java for one of the fields. We have a field called ipAddress and the description in swagger is as below.

ipAddress: description: The location the content is trying to be played from type: string oneOf: [ {format: ipv4}, {format: ipv6} ]

Instead of creating it as a String, the openapi-generator-maven-plugin is creating it as OneOfAnyTypeAnyType

Also it is creating an import in API class for CollectionFormats.* which doesn't exist

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided OpenAPI schema and reproduce generation through the openapi-generator-maven-plugin. Inspect the generated Java field type and API imports for the oneOf ipAddress case. Done means the field is generated as String and the nonexistent CollectionFormats.* import is absent.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.