Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #4808
Closed
Open
Issue created Dec 16, 2019 by Administrator@rootContributor

[BUG] [JAVA] Using an object to pass query params ends up using the toString of that class

Created by: mtohmaz

Description

When specifying the query parameters for an endpoint as an object and generate a Java SDK using openapi-generator-cli, it will actually use the class's toString as the query parameter values instead. For example, here is a sample config I have for openapi version 3.

paths:
  /my_endpoint:
    get:
      tags:
        - "MyEndpoint"
      operationId: "getMyEndpoint"
      parameters:
        - in: query
          name: queryParams
          explode: true
          schema:
            type: object
            properties:
              to:
                type: string
              from:
                type: string

After generating the java SDK and make a request like so:

QueryParams queryParams = new QueryParams();
queryParams.setTo("Person");
MyEndpointSuccessResponse result = apiInstance.getMyEndpoint(queryParams);

The request is received by my endpoint, but this is what the query params look like: {"query_params"=>"class QueryParams {\n to: Person\n from: null\n}"}

openapi-generator version

4.2.1-SNAPSHOT

Command line used for generation
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate
-i ./local/swagger.yaml
-g java
-o ./local/java
-c ./local/config.json
Assignee
Assign to
Time tracking