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

IntoParams style container attribute #151

Closed
kellpossible opened this issue May 30, 2022 · 1 comment
Closed

IntoParams style container attribute #151

kellpossible opened this issue May 30, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@kellpossible
Copy link
Contributor

It would be nice to have a single attribute for all fields of a struct deriving IntoParams for style.

Perhaps something like:

#[derive(Deserialize, IntoParams)]
#[param(style = Form)]
struct Filter {
    /// Foo database id.
    id: u64,
    /// Datetime since foo is updated.
    since: Option<String>,
}

Also what happens when different parameters in the same path have different parameter styles? Perhaps the style attribute only makes sense on the container level?

kellpossible added a commit to kellpossible/utoipa that referenced this issue May 31, 2022
kellpossible added a commit to kellpossible/utoipa that referenced this issue Jun 15, 2022
kellpossible added a commit to kellpossible/utoipa that referenced this issue Jun 16, 2022
juhaku added a commit that referenced this issue Jun 18, 2022
…eworks) (#150)

* Support accepting `params(Type)` for `path` where `Type` implements `IntoParams`, closing #129.
* Modified `todo-warp` to show this feature in use.
* Implement #151 container attributes for `IntoParams` including `style` and `parameter_in`. For example: `#[param(style = Form, parameter_in = Query)]`.
*  Add unit tests with this feature.
* Fix failing tests.
* Allow params in `#[utoipa::path(...)}` to be specified using both struct and bracket style.
* Support paths like in #161
* ~Fix todo-warp project~ edit: looks like this is a regression on `master` #173
* Refactor ParameterIn for manual parameter definitions to use the same
parsing logic, this is a breaking change to use Pascal case for these:
`Path`, `Query`, `Header`, `Cookie`
* Update documentation

This work was sponsored by [Arctoris](https://www.arctoris.com/).

Co-authored-by: Juha Kukkonen <juha7kukkonen@gmail.com>
@juhaku juhaku added the enhancement New feature or request label Jun 20, 2022
@juhaku
Copy link
Owner

juhaku commented Jun 21, 2022

One could override the style for each parameter but specifying style that is not supported for Path arguments will result most likely corrupt OpenAPI spec and certainly will not work the way expected. But defining of a correct style is a responsibility of a user.

@juhaku juhaku closed this as completed Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants