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

Define a range of error codes #965

Open
musjj opened this issue Feb 9, 2025 · 0 comments · May be fixed by #966
Open

Define a range of error codes #965

musjj opened this issue Feb 9, 2025 · 0 comments · May be fixed by #966
Labels
enhancement New feature or request

Comments

@musjj
Copy link

musjj commented Feb 9, 2025

Description of the feature

From the spec:

To define a range of response codes, you may use the following range definitions: 1XX, 2XX, 3XX, 4XX, and 5XX. If a response range is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code. Each response status requires a description. For example, you can describe the conditions for error responses. Markdown (CommonMark) can be used for rich text representation.

responses:
  "200":
    description: OK
  "400":
    description: Bad request. User ID must be an integer and larger than 0.
  "401":
    description: Authorization information is missing or invalid.
  "404":
    description: A user with the specified ID was not found.
  "5XX":
    description: Unexpected error.

Code example (if possible)

#[derive(ApiResponse)]
pub enum ApiError {
    #[oai(status = 400)]
    BadUserId,
    #[oai(status = 5XX)]
    UnexpectedError(#[status] http::StatusCode),
}
@musjj musjj added the enhancement New feature or request label Feb 9, 2025
@patrickariel patrickariel linked a pull request Feb 12, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant