OpenAPITools / OpenAPITools/openapi-generator

[BUG] Object as query paramenter

Open
#10,806 1 comment 10 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

Description

Just found an issue when using an Object as Query-Parameter.
When using e.g. swagger-codegen (Java), it's possible to do the following:

/xyz:
    get:
      parameters:
      - in: query
        required: false
        name: someBoolean
        schema:
          type: boolean
      - in: query
        name: someObject
        required: false
        schema:
          $ref: '#/components/schemas/SomeObjectDto'

In this case e.g. Swagger uses all properties of SomeObjectDto as Query Parameter.

In your lib the toString-Method of each Object is used as query parameter. E.g.:

@override
String toString() => 'SomeObjectDto[propA=$propA, propB=$propB]';

I think this should get corrected :)

openapi-generator version

3.2.1

OpenAPI declaration file content or url

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 Java client generation path for query-parameter serialization and reproduce the OpenAPI declaration using the SomeObjectDto reference. Compare the generated request for an object parameter with the Swagger behavior; done means the object's properties are represented as query parameters instead of using the object's toString() value.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
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.