pub struct ErrorResponseRules { /* private fields */ }Expand description
Error responses and response headers to document on every matching operation, as data.
A status rule adds a response with the shared ErrorEnvelope schema and the product’s
description when the operation does not document that status yet. A header rule adds a header
to the selected inline responses when they do not have a header of that name, compared without
regard to case. Responses given as a $ref are left unchanged, because they are shared
components. Applying the same rules twice changes nothing.
Implementations§
Source§impl ErrorResponseRules
impl ErrorResponseRules
Sourcepub fn status(
self,
condition: OperationCondition,
status: u16,
description: impl Into<String>,
) -> Self
pub fn status( self, condition: OperationCondition, status: u16, description: impl Into<String>, ) -> Self
Adds an error response with this status and description to operations that match.
Sourcepub fn header(
self,
condition: OperationCondition,
responses: ResponseSelector,
name: impl Into<String>,
header: Header,
) -> Self
pub fn header( self, condition: OperationCondition, responses: ResponseSelector, name: impl Into<String>, header: Header, ) -> Self
Adds a response header to the selected responses of operations that match.
Sourcepub fn standard_headers(self) -> Self
pub fn standard_headers(self) -> Self
Adds the headers that baukit-http and baukit-auth send: X-Request-Id on every
response, Retry-After on 429, and WWW-Authenticate on 401.
Sourcepub fn apply(&self, document: &mut OpenApi)
pub fn apply(&self, document: &mut OpenApi)
Applies the rules to every operation in the document.
Sourcepub fn apply_where(
&self,
document: &mut OpenApi,
include: impl Fn(&str, &HttpMethod) -> bool,
)
pub fn apply_where( &self, document: &mut OpenApi, include: impl Fn(&str, &HttpMethod) -> bool, )
Applies the rules to the operations whose path template and method pass include.
Use it for statuses only some routes return, such as a 412 on conditional writes, or to skip public documents such as the OpenAPI route itself.