OpenAPITools / OpenAPITools/openapi-generator

[BUG] 'oneOf' property is not working with two references Description

Open
#9,290 1 comment 1 reaction 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

oneOf directive of openapi 3.0.0 is not working as expected in openapitool generator version 5.1.0 for java client.

Generator used : Spring
library : spring-mvc

Issue it is appending both the names in the import eg import com.test.cx.communications.dx4c.fuzz.tmf632.model.OneOfDX4CPartyIndividualPayloadDX4CPartyOrganizationPayload;

                    snippet:
                    
                                      DX4CPartyEventPayload:
                                          type: object
                                          description: The notification data structure
                                          properties:
                                            eventId:
                                              type: string
                                              description: The identifier of the notification.
                                            eventTime:
                                              type: string
                                              description: Time of the event occurrence.
                                            description:
                                              type: string
                                              description: An explanatory of the event.
                                            title:
                                              type: string
                                              description: The title of the event.
                                            eventType:
                                              type: string
                                              description: The type of the notification.
                                            correlationId:
                                              type: string
                                              description: The correlation id for this event.
                                            event:
                                              oneOf:
                                                - $ref: "#/components/schemas/DX4CPartyIndividualPayload"
                                                - $ref: "#/components/schemas/DX4CPartyOrganizationPayload"
                                    
                                    
                                        DX4CPartyIndividualPayload:
                                          type: object
                                          description: Individual Payload
                                          properties:
                                            individual:
                                              $ref: "#/components/schemas/Individual"
                                    
                                        DX4CPartyOrganizationPayload:
                                          type: object
                                          description: Organization Payload
                                          properties:
                                            organization:
                                              $ref: "#/components/schemas/Organization"

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 by reproducing the supplied OpenAPI 3 schema with the Java Spring generator using the spring-mvc library. Inspect the generated imports for the oneOf property containing DX4CPartyIndividualPayload and DX4CPartyOrganizationPayload; done means the generated client no longer combines both referenced names incorrectly in one import.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.