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

Correct handling of style and explode. #238

Open
r34son opened this issue Mar 19, 2024 · 2 comments
Open

Correct handling of style and explode. #238

r34son opened this issue Mar 19, 2024 · 2 comments

Comments

@r34son
Copy link

r34son commented Mar 19, 2024

OpenAPI spec:

targets:

  get:
    tags:
      - targets
    operationId: getProductTargets
    parameters:
      - name: searchParameters
        description: "Some description"
        in: query
        required: true
        schema:
          $ref: "..ProductTargetsSearch"
    responses:
      200:
        description: "Some description"
        content:
          application/json:
            schema:
              $ref: "..GetProductTargetsResponse"
      400:
        description: "Some description"
        content:
          application/json:
            schema:
              $ref: "..ErrorDto"
      500:
        description: "Ошибка на сервере"
        content:
          application/json:
            schema:
              $ref: "..ErrorDto"

Generator emits type for queryParams:

export type GetProductTargetsQueryParams = {
    /**
     * Some description
     */
    searchParameters: Schemas.ProductTargetsSearch;
};

But by spec https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#parameter-object
parameter in: query has default value of style - form. So explode default value is true for form style. Spec says:

When this is true, parameter values of type array or object generate separate parameters for each value of the array or key-value pair of the map

Should generator emit queryParam type with spreaded params? if no, why?

@r34son
Copy link
Author

r34son commented Mar 19, 2024

@fabien0102 Hi Fabien! Thanks for the great work! Could you take a look at that?

@fabien0102
Copy link
Owner

Hey, thx for raising the issue, I don't think the style and explode are implemented here.

Usually, the entire API should follow the same style so you can handle this in your custom fetcher. This is at least the assumption I did ^^ I'm always happy to improve the library to handle more usecase, so if you have time, I'm open to pull-request 😀

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

2 participants