OpenAPITools / OpenAPITools/openapi-generator

[BUG] [client] [java] [native] [csharp-netcore] multiple use of parameters in deepobjects naming failure

Open
#13,658 0 comments 0 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

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

If a parameter is used multiple times in the same deepObject, then the parameters have all the same name.
In the example below all parameters are named inputOptions. But it should be "options" and "inputOptions"

openapi-generator version

6.2.0

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: deepobject-test
  version: 1.0.0
paths:
  /test:
    get:
      operationId: test
      parameters:
        - name: options
          in: query
          required: false
          style: deepObject
          schema:
            $ref: '#/components/schemas/Options'
          explode: true
        - name: inputOptions
          in: query
          required: false
          style: deepObject
          schema:
            $ref: '#/components/schemas/Options'
          explode: true
      responses:
        '200':
          description: OK
          content:
            text/plain:
              schema:
                type: string
components:
  schemas:
    Options:
      type: object
      properties:
        a:
          nullable: true
          type: string
          format: date-time
        b:
          type: string
          nullable: true
          format: date-time
        c:
          type: array
          items:
            type: string

(for YAML code) or

######## actual result

            if (options != null)
            {
                if (options.A != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "inputOptions[a]", options.A));
                }
                if (options.B != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "inputOptions[b]", options.B));
                }
                if (options.C != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "inputOptions[c]", options.C));
                }
            }
            if (inputOptions != null)
            {
                if (inputOptions.A != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "inputOptions[a]", inputOptions.A));
                }
                if (inputOptions.B != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "inputOptions[b]", inputOptions.B));
                }
                if (inputOptions.C != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "inputOptions[c]", inputOptions.C));
                }
            }

######## expected result

            if (options != null)
            {
                if (options.A != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "options[a], options.A));
                }
                if (options.B != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "options[b], options.B));
                }
                if (options.C != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "options[c], options.C));
                }
            }
            if (inputOptions != null)
            {
                if (inputOptions.A != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "inputOptions[a], inputOptions.A));
                }
                if (inputOptions.B != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "inputOptions[b], inputOptions.B));
                }
                if (inputOptions.C != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "inputOptions[c], inputOptions.C));
                }
            }
Command line used for generation

java -jar openapi-generator-cli.jar generate -g csharp-netcore -i deepobject.yaml
java -jar openapi-generator-cli.jar generate -g java -i deepobject.yaml

Steps to reproduce
Related issues/PRs

##13662

Suggest a fix/enhancement

PR #13662 #13662

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

Use the supplied deepobject-test OpenAPI declaration as deepobject.yaml and run the listed csharp-netcore and java generation commands. Compare repeated deepObject parameter names with the expected options and inputOptions output; PR #13662 is the referenced follow-up work.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.