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

Looks like format option is ignoring #693

Closed
shandak opened this issue Jul 20, 2023 · 7 comments · Fixed by #928
Closed

Looks like format option is ignoring #693

shandak opened this issue Jul 20, 2023 · 7 comments · Fixed by #928

Comments

@shandak
Copy link

shandak commented Jul 20, 2023

#[utoipa::path(
    get,
    path = "/visitors/v1/{start_date}/{end_date}",
   ...
    params(
        ("start_date", Path, description = "Start date filter", format = DateTime),
        ("end_date", Path, description = "End date filter", format = Date)
    )
)]

The description is showing, but the format is always the string
TinyTake20-07-2023-11-55-54

@juhaku
Copy link
Owner

juhaku commented Jul 20, 2023

How does it look in the openapi.json or yaml file?

@shandak
Copy link
Author

shandak commented Jul 20, 2023

piece of json

[
  {
    "name": "start_date",
    "in": "path",
    "description": "Start date filter",
    "required": true,
    "schema": {
      "type": "string"
    }
  },
  {
    "name": "end_date",
    "in": "path",
    "description": "End date filter",
    "required": true,
    "schema": {
      "type": "string"
    }
  }
]

@shandak
Copy link
Author

shandak commented Jul 20, 2023

The same issue if I'm trying to do it via struct

#[derive(Deserialize, IntoParams, utoipa::ToSchema)]
pub struct StartEndDate {
    /// Start date filter
    #[schema(value_type = String, format = Date)]
    pub start_date: String,
    /// End date filter
    #[schema(value_type = String, format = Date)]
    pub end_date: String,
}

the format is just ignoring in the path part, whereas schema looks correct

TinyTake20-07-2023-12-03-45

@juhaku
Copy link
Owner

juhaku commented Jul 20, 2023

Interesting, there are some known issues with the IntoParams but didn't expect this to be one of them. 👀 Need to check this same time with other IntoParams improvements.

What framework you are using? Axum? Actix_web? Rocket?

@juhaku juhaku moved this to Todo in utoipa kanban Jul 20, 2023
@shandak
Copy link
Author

shandak commented Jul 20, 2023

actix_web

@jayvdb
Copy link
Contributor

jayvdb commented Sep 10, 2023

Hi @shandak , I added a test in #758 which shows one way of getting these data type formats working in actix-web.

@juhaku
Copy link
Owner

juhaku commented May 15, 2024

@jayvdb Yeah it seemingly works with the Query type of parameters, but not with the Path 🤦 But there is a fix finally for this one in here #928.

@juhaku juhaku moved this from Todo to In Progress in utoipa kanban May 15, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in utoipa kanban May 15, 2024
@juhaku juhaku moved this from Done to Released in utoipa kanban Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Released
Development

Successfully merging a pull request may close this issue.

3 participants