utoipa icon indicating copy to clipboard operation
utoipa copied to clipboard

Looks like format option is ignoring

Open shandak opened this issue 1 year ago • 6 comments

#[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

shandak avatar Jul 20 '23 08:07 shandak

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

juhaku avatar Jul 20 '23 08:07 juhaku

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 avatar Jul 20 '23 09:07 shandak

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

shandak avatar Jul 20 '23 09:07 shandak

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

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

juhaku avatar Jul 20 '23 10:07 juhaku

actix_web

shandak avatar Jul 20 '23 12:07 shandak

Hi @shandak , I added a test in https://github.com/juhaku/utoipa/pull/758 which shows one way of getting these data type formats working in actix-web.

jayvdb avatar Sep 10 '23 05:09 jayvdb

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

juhaku avatar May 15 '24 11:05 juhaku