Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query Parameter Serialization should use explode as default #210

Open
cbartz opened this issue Feb 10, 2022 · 0 comments
Open

Query Parameter Serialization should use explode as default #210

cbartz opened this issue Feb 10, 2022 · 0 comments

Comments

@cbartz
Copy link

cbartz commented Feb 10, 2022

According to the OpenAPI Specification, the default serialization method for query parameters is style: form and explode: true. Therefore, if these keywords are not given, oazapfts should use the method https://github.com/cellular/oazapfts/blob/992128226bbaa103c4fc93b8b2dec81da953520a/src/runtime/query.ts#L45 for parameter serizaliation. Due to line https://github.com/cellular/oazapfts/blob/992128226bbaa103c4fc93b8b2dec81da953520a/src/codegen/generate.ts#L38 the default method used is form instead.

Example: If the lines https://github.com/cellular/oazapfts/blob/310117038b6a5119c8a121063d9f4d6f36f43b59/demo/petstore.json#L172-L173 are removed, the result should be the same as without removal. Instead, the generated code uses QS.form

export function findPetsByStatus(status: ("available" | "pending" | "sold")[], opts?: Oazapfts.RequestOpts) {
    return oazapfts.fetchJson<{
        status: 200;
        data: Pet[];
    } | {
        status: 400;
        data: string;
    }>(`/pet/findByStatus${QS.query(QS.form({
        status
    }))}`, {
        ...opts
    });

instead of QS.explode

export function findPetsByStatus(status: ("available" | "pending" | "sold")[], opts?: Oazapfts.RequestOpts) {
    return oazapfts.fetchJson<{
        status: 200;
        data: Pet[];
    } | {
        status: 400;
        data: string;
    }>(`/pet/findByStatus${QS.query(QS.explode({
        status
    }))}`, {
        ...opts
    });
}

This behaviour was observed with version 3.5.0 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant