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

How can I do it when a parameter (in: query) is composed ? #581

Open
matheuscamarques opened this issue Dec 8, 2023 · 1 comment
Open

Comments

@matheuscamarques
Copy link

How can I do it when a parameter (in: query) is composed

example

%ObjectParams{
  page: %{
         limit: integer,
         before: string,
         after: string
  }
  filter: %{
         status_not: string
  }
}
@hamir-suspect
Copy link
Contributor

Hey, I'm not a maintainer but I have had an issue that might be useful to your use case as well, it depends on how you want your query params to look like:

1.?page[limit]=1&page[before]=token&filter[status_not]=done
solution is something like:

parameter(
            :page,
            :query,
            %Schema{
              type: :object,
                  properties: %{
                      limit: %Schema{type: :integer, default: 20},
                      before: %Schema{type: :string}},
                      after: %Schema{type: :string}}
            },
            "Page params",
            required: true
          ),
parameter(
    :filter,
    :query,
    %Schema{
....
  1. ?limit=10&before=token&status_not=done
    in this case you want to specify that your parameter is
    explode: true like this:
parameter(
            :some,
            :query,
            %Schema{
              type: :object,
              oneOf: [
                %Schema{
                  type: :object,
                  properties: %{foo: %Schema{type: :string}, bar: %Schema{type: :string}},
                  required: [:foo]
                },
                %Schema{
                  type: :object,
                  properties: %{foo: %Schema{type: :string}, baz: %Schema{type: :string}},
                  required: [:baz]
                }
              ]
            },
            "Some query parameter ",
            explode: true,
            style: :form,
            required: true
          )

The 2nd approach currently does not work but there is a pending PR

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