OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.77k stars 6.57k forks source link

Using "content" instead of "schema" in query param does not work #14424

Open jishupei opened 1 year ago

jishupei commented 1 year ago
Description

for example, We want our query argument to end up with color=[" blue","black","brown"] instead of color=blue,black,brown or color=blue; color=black; Color = brown, So we use content.

openapi-generator version

6.2.1

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: test_title
  description: test_description
  version: '2022-12-13'
servers:
  - url: https://openapi.alipay.com
    description: Production server
  - url: http://openapi.stable.dl.alipaydev.com
    description: Development server
paths:
  /v3/alipay/trade/query:
    get:
      tags:
        - alipay.trade
      summary: alipay.trade.query
      description: "qqq"
      operationId: alipay.trade.query
      responses:
        '200':
          description: common response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AlipayTradeQueryResponseModel'
        default:
          description: failed
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/CommonErrorType'
                  - $ref: '#/components/schemas/AlipayTradeQueryErrorResponseModel'
      parameters:
        - name: out_trade_no
          in: query
          description: "out_trade_no"
          required: false
          schema:
            type: string
            example: '20150320010101001'
        - name: query_options
          in: query
          description: xxx
          required: false
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string
Command line used for generation
java -jar bin/openapi-generator-cli-6.2.1.jar generate \
    -g java\
    -i src/main/resources/test_enum.yaml\
    -o gen \
    -c src/main/resources/java-sdk.json \
    -t src/main/resources/Java \
    --global-property skipFormModel=false,modelTests=false,apiTests=false,modelDocs=false
Steps to reproduce

The resulting code is:

if (queryOptions != null) {
    localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "query_options", queryOptions));
}

The resulting url is: xxx?color=blue,black,brown

Is there something wrong with my usage or is content not supported?

tiberiu89 commented 1 year ago

any workaround? maybe using a custom api template?

jishupei commented 1 year ago

any workaround? maybe using a custom api template?

Yes, if it's not officially supported, I'll have to use custom api template. But I'm not sure they support it any other way.