OpenAPITools / OpenAPITools/openapi-generator

[Question][Java] Operation parameter with oneOf schema, but generating server

Open
#20,494 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I have rest specification with oneOf in parameters like https://github.com/OpenAPITools/openapi-generator/issues/19442

/users:
    get:
      operationId: getUsers
      summary: Get users by array of numbers OR array of strings
      description: "May pass string or integer array."
      parameters:
        - in: query
          name: identifiers
          description: "String or integer array"
          required: true
          style: form
          explode: true
          schema:
            oneOf:
              - type: string
              - type: integer
        - in: query
          name: someParam
          description: "Just parameter"
          required: false
          schema:
            type: string

It's all ok for client generator now.
But i'm trying to generate spring serverver and in model have only one model for this parameter:

@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.10.0")
public interface GetUsersIdentifiersParameter {
}

May be i'm doing something wrong and need more parameters?

java -jar openapi-generator-cli-7.10.0.jar generate -i rest.yaml -g spring

If parameters are ok and it's boug or not realized feature - can it be realized (may be some suggestions for contribution) or it has no reason?

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 rest.yaml and run the documented openapi-generator-cli 7.10.0 Spring generation command, then inspect the generated GetUsersIdentifiersParameter interface. Compare the server output with the oneOf query-parameter schema and determine what generated representation would correctly preserve the string-or-integer parameter; done means server generation handles this parameter without producing only an empty model.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Feature
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.