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

Inconsistent separator in some oapi macros #1006

Open
johnpyp opened this issue Dec 16, 2024 · 0 comments
Open

Inconsistent separator in some oapi macros #1006

johnpyp opened this issue Dec 16, 2024 · 0 comments

Comments

@johnpyp
Copy link

johnpyp commented Dec 16, 2024

Describe the bug
Some of the #[salvo] attribute macros like #[salvo(response(...))] don't use comma-separated values.

To Reproduce
Example code that fails:

#[derive(Debug, Serialize, Deserialize, ToResponses)]
pub enum GeneralError {
    #[salvo(response(status_code = 400, description = "Bad Request"))]
    BadRequest(String),
    #[salvo(response(status_code = 429 description = "Rate Limit Exceeded"))]
    RateLimit { message: String, retry_after: u64 },
    #[salvo(response(status_code = 500 description = "Something went wrong"))]
    InternalServerError(String),
}

The comma after status_code = 400 throws an error:

error: expected identifier
  --> crates/rustle_web/src/api.rs:33:39
   |
33 |     #[salvo(response(status_code = 400, description = "Bad Request"))]
   |                                       ^

But the second two with just spaces work fine.

Expected behavior

The attribute macros should use commas for separating fields, as it's the Rust standard and is used in other parts of salvo already. E.g:

#[derive(Debug, Serialize, Deserialize, ToResponses)]
pub enum GeneralError {
    #[salvo(response(status_code = 400, description = "Bad Request"))]
    BadRequest(String),
    #[salvo(response(status_code = 429, description = "Rate Limit Exceeded"))]
    RateLimit { message: String, retry_after: u64 },
    #[salvo(response(status_code = 500, description = "Something went wrong"))]
    InternalServerError(String),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant