Skip to content

Change name of generic model #1478

@sawa-ko

Description

@sawa-ko

How can I change the name of a schema that was generated by a generic type? Currently, I have the following:

Image
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema, utoipa::ToResponse)]
#[schema(
    description = "Base model for HTTP controller responses that contain a data. In case of critical or uncontrolled \
                   errors, it may be different."
)]
pub struct Response<T>
where
    T: Serialize + utoipa::ToSchema,
{
    pub code: u16,
    pub success: bool,
    pub message: String,
    pub timestamp: String,
    pub data: T,
}

#[derive(Serialize, Deserialize, ToSchema, ToResponse)]
#[schema(title = "User", description = "Basic information about an application user.")]
pub struct UserDto {
    pub id: Uuid,
    pub username: String,
    pub public_name: String,
    pub created_at: DateTime<chrono::Utc>,
    pub updated_at: DateTime<chrono::Utc>,
}

I want to change the name of the model from Response_UserDto to ResponseUserDto or UserResponseDto or something like that, but I don't know how to do it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions