swagger-api / swagger-api/swagger-codegen
Wrong Query parameter serialization when using Object
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
We are using objects in query parameters for a get operations, when we call the service, object parameters are not serialized as expected.
The toString method is call and le url is corrupted
/v1/declarations/etablissements?page=class%20PageInType%20%7B%0A%20%20%20%20page%3A%2010%0A%20%20%20%20size%3A%2050%0A%7D&filtre=class%20FiltreRechercherEtablissementDSNType%20%7B%0A%20%20%20%20siret%3A%20null%0A%20%20%20%20siren%3A%20808332670%0A%20%20%20%20annee%3A%202017%0A%20%20%20%20mois%3A%2001%0A%20%20%20%20localite%3A%20null%0A%20%20%20%20effectifCalculeDebutDePeriode%3A%20null%0A%20%20%20%20effectifCalculeFinDePeriode%3A%20null%0A%20%20%20%20denomination%3A%20null%0A%20%20%20%20codeNAF%3A%20null%0A%7D&tri=class%20TriRechercherEtablissementsDSNType%20%7B%0A%20%20%20%20siret%3A%20null%0A%20%20%20%20siren%3A%20desc%0A%20%20%20%20mois%3A%20null%0A%20%20%20%20localite%3A%20null%0A%20%20%20%20effectifCalculeFinDePeriode%3A%20null%0A%20%20%20%20effectifCalculeDebutDePeriode%3A%20null%0A%20%20%20%20denomination%3A%20null%0A%20%20%20%20codeNAF%3A%20null%0A%20%20%20%20annee%3A%20null%0A%7D
Swagger-codegen version
3.0.0-SNAPSHOT
Swagger declaration file content or url
tags:
- declarations
parameters:
- name: page
in: query
required: false
style: form
schema:
$ref: '#/components/schemas/PageIn_Type'
- name: filtre
in: query
required: false
style: form
schema:
$ref: '#/components/schemas/FiltreRechercherEtablissementDSN_Type'
- name: tri
in: query
required: false
style: form
explode: false
schema:
$ref: '#/components/schemas/TriRechercherEtablissementsDSN_Type'
responses:
...
PageIn_Type:
type: object
properties:
page:
type: number
size:
type: number
...
FiltreRechercherEtablissementDSN_Type:
type: object
properties:
siret:
type: string
siren:
type: string
annee:
type: string
mois:
type: string
localite:
type: string
effectifCalculeDebutDePeriode:
type: string
effectifCalculeFinDePeriode:
type: string
denomination:
type: string
codeNAF:
type: string
Command line used for generation
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>${swagger-codegen-version}</version>
<executions>
<execution>
<id>generate-client</id>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/dsnci_ws_consultation_be_v1.0.yaml</inputSpec>
<language>java</language>
<apiPackage>fr.recouv.dsn.ws.rest.api.v1</apiPackage>
<modelPackage>fr.recouv.dsn.ws.rest.dto.v1</modelPackage>
<output>${generated-swagger-path}</output>
<withXml>true</withXml>
<generateApis>true</generateApis>
<generateApiTests>true</generateApiTests>
</configuration>
</execution>
</executions>
</plugin>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generated Java client and the swagger-codegen Maven execution shown in the report, using the supplied OpenAPI schema as the reproduction input. Trace query-parameter serialization for the object parameters page, filtre, and tri, then add a regression check for the generated request URL. Done means object properties are serialized according to the declared query style rather than via toString.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100