Skip to content

Optional parameter segment in path #1195

Answered by juhaku
myz-dev asked this question in Q&A
Discussion options

You must be logged in to vote

The docs gives some examples of params format https://docs.rs/utoipa/latest/utoipa/attr.path.html#parameter-formats.

You are probably mixing up path params and query params. Path params that are described in the path e.g. /user/{id}/{type} must be present. Path params are always required and cannot be non required. That means that in order to call the path you must give those parameters otherwise the endpoint does not match. You could call the endpoint with /user/null/null which will result in None for both values. But calling it with /user does only give the default behavior of the http framework you are using which is either 404, 415, or 500 most likely.

Query parameters are the ones th…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@myz-dev
Comment options

Answer selected by myz-dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants