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

alias not work in param derive #1176

Closed
SamPeng87 opened this issue Nov 1, 2024 · 1 comment · Fixed by #1179
Closed

alias not work in param derive #1176

SamPeng87 opened this issue Nov 1, 2024 · 1 comment · Fixed by #1179
Labels
bug Something isn't working investigate Futher investigation needed before other action

Comments

@SamPeng87
Copy link

my build.rs is

fn main() {
    utoipa_config::Config::new()
        .alias_for("Id","uuid::Uuid")
        .write_to_file();
}

used that :

type Id = uuid::Uuid;
#[derive(Deserialize, IntoParams, Clone, Debug)]
pub struct GetRequest {
    #[param(example = uuid::Uuid::new_v4,value_type=Id)]
    /// this is url
    id: Id,
}

#[derive(Deserialize, Serialize, ToSchema, Clone, Debug)]
pub struct  ConfigDescription {

    #[schema(example = uuid::Uuid::new_v4,value_type=Id)]
    /// this is id
    id: Id,
}

GetRequest parser's json is:

 "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "this is url",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/String"
            },
            "example": "ed61b5a2-004c-4997-8b3b-57b24e64c8c7"
          }
        ],

ConfigDescription parser's json is:

      "ConfigDescription": {
        "type": "object",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "this is id",
            "example": "0255bbc6-f0c7-4467-9a6b-7c1e3c5e7525"
          }
        }
      }

if I changed that:

#[derive(Deserialize, IntoParams, Clone, Debug)]
pub struct GetRequest {
    #[param(example = uuid::Uuid::new_v4,value_type=uuid::Uuid)]
    /// this is url
    id: Id,
}

that work !

@juhaku
Copy link
Owner

juhaku commented Nov 1, 2024

Interesting, this needs some investigation.

@juhaku juhaku added the investigate Futher investigation needed before other action label Nov 1, 2024
@juhaku juhaku moved this to In Progress in utoipa kanban Nov 2, 2024
@juhaku juhaku added the bug Something isn't working label Nov 2, 2024
juhaku added a commit that referenced this issue Nov 2, 2024
This commit fixes missing support for aliases defined via `utoipa-config`
for `IntoParams` derive macro.

Fixes #1176
juhaku added a commit that referenced this issue Nov 2, 2024
This commit fixes missing support for aliases defined via `utoipa-config`
for `IntoParams` derive macro.

Fixes #1176
juhaku added a commit that referenced this issue Nov 2, 2024
This commit fixes missing support for aliases defined via `utoipa-config`
for `IntoParams` derive macro.

Fixes #1176
@github-project-automation github-project-automation bot moved this from In Progress to Done in utoipa kanban Nov 2, 2024
@juhaku juhaku moved this from Done to Released in utoipa kanban Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working investigate Futher investigation needed before other action
Projects
Status: Released
Development

Successfully merging a pull request may close this issue.

2 participants