pub struct OpenApiRouteConfig { /* private fields */ }Expand description
Per-route OpenAPI metadata.
Implementations§
Source§impl OpenApiRouteConfig
impl OpenApiRouteConfig
Sourcepub fn undescribed_inputs(&self) -> &[UndescribedInput]
pub fn undescribed_inputs(&self) -> &[UndescribedInput]
Returns the handler inputs this operation describes without their fields, because
they cannot be inferred - see UndescribedInput.
Sourcepub fn described_parameters(&self) -> usize
pub fn described_parameters(&self) -> usize
Returns how many parameters this operation already describes.
Taken before an extractor is described and handed back through ConstraintTarget,
so its constraints reach its own parameters and no others.
Adds multiple tags to the operation.
Sourcepub fn with_summary(self, summary: impl Into<String>) -> Self
pub fn with_summary(self, summary: impl Into<String>) -> Self
Sets the operation summary.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Sets the operation description.
Sourcepub fn with_operation_id(self, operation_id: impl Into<String>) -> Self
pub fn with_operation_id(self, operation_id: impl Into<String>) -> Self
Sets the operation id.
Sourcepub fn with_request_schema(self, schema: OpenApiSchema) -> Self
pub fn with_request_schema(self, schema: OpenApiSchema) -> Self
Sets the request body schema for this operation.
This is how a body whose fields cannot be inferred is described - see
UndescribedInput.
Sourcepub fn with_query_schema(self, schema: OpenApiSchema) -> Self
pub fn with_query_schema(self, schema: OpenApiSchema) -> Self
Describes the query parameters by hand: one for each property of schema, required
when its required list names it - the way a Query<T> extractor describes the
fields of T.
This is how a query whose fields cannot be inferred is described - see
UndescribedInput. A parameter this operation already describes under the same
name is replaced.
Sourcepub fn with_response_schema(
self,
status: impl IntoStatusCode,
schema: OpenApiSchema,
) -> Self
pub fn with_response_schema( self, status: impl IntoStatusCode, schema: OpenApiSchema, ) -> Self
Sets the response schema for this operation.
Sourcepub fn consumes_named_path<T: DeserializeOwned>(self) -> Self
pub fn consumes_named_path<T: DeserializeOwned>(self) -> Self
Generates path parameters schema.
Sourcepub fn consumes_query<T: DeserializeOwned>(self) -> Self
pub fn consumes_query<T: DeserializeOwned>(self) -> Self
Generates query parameters schema.
Sourcepub fn consumes_json<T: DeserializeOwned>(self) -> Self
pub fn consumes_json<T: DeserializeOwned>(self) -> Self
Generates JSON request schema and example.
Sourcepub fn consumes_form<T: DeserializeOwned>(self) -> Self
pub fn consumes_form<T: DeserializeOwned>(self) -> Self
Generates form request schema and example.
Sourcepub fn consumes_multipart(self) -> Self
pub fn consumes_multipart(self) -> Self
Generates multipart request schema.
Sourcepub fn consumes_stream(self) -> Self
pub fn consumes_stream(self) -> Self
Generates stream request schema.
Sourcepub fn produces_text(self, status: impl IntoStatusCode) -> Self
pub fn produces_text(self, status: impl IntoStatusCode) -> Self
Generates text/plain response schema.
Sourcepub fn produces_no_schema(self, status: impl IntoStatusCode) -> Self
pub fn produces_no_schema(self, status: impl IntoStatusCode) -> Self
Generates a response without a schema.
Sourcepub fn produces_json<T: Serialize + Default>(
self,
status: impl IntoStatusCode,
) -> Self
pub fn produces_json<T: Serialize + Default>( self, status: impl IntoStatusCode, ) -> Self
Generates JSON response schema and example from T::default().
Sourcepub fn produces_empty_json(self, status: impl IntoStatusCode) -> Self
pub fn produces_empty_json(self, status: impl IntoStatusCode) -> Self
Generates empty JSON response schema.
Sourcepub fn produces_form<T: Serialize + Default>(
self,
status: impl IntoStatusCode,
) -> Self
pub fn produces_form<T: Serialize + Default>( self, status: impl IntoStatusCode, ) -> Self
Generates form response schema and example from T::default().
Sourcepub fn produces_empty_form(self, status: impl IntoStatusCode) -> Self
pub fn produces_empty_form(self, status: impl IntoStatusCode) -> Self
Generates empty form response schema.
Sourcepub fn produces_multipart(self, status: impl IntoStatusCode) -> Self
pub fn produces_multipart(self, status: impl IntoStatusCode) -> Self
Generates default multipart/form-data response schema.
Sourcepub fn produces_stream(self, status: impl IntoStatusCode) -> Self
pub fn produces_stream(self, status: impl IntoStatusCode) -> Self
Generates stream response schema.
Sourcepub fn produces_sse(self, status: impl IntoStatusCode) -> Self
pub fn produces_sse(self, status: impl IntoStatusCode) -> Self
Generates SSE stream response schema.
Sourcepub fn produces_json_example<T: Serialize>(
self,
status: impl IntoStatusCode,
example: T,
) -> Self
pub fn produces_json_example<T: Serialize>( self, status: impl IntoStatusCode, example: T, ) -> Self
Generates JSON response schema and example.
Sourcepub fn produces_form_example<T: Serialize>(
self,
status: impl IntoStatusCode,
example: T,
) -> Self
pub fn produces_form_example<T: Serialize>( self, status: impl IntoStatusCode, example: T, ) -> Self
Generates form response schema and example.
Sourcepub fn with_constraints(
self,
target: ConstraintTarget,
constraints: &[FieldConstraint],
) -> Self
pub fn with_constraints( self, target: ConstraintTarget, constraints: &[FieldConstraint], ) -> Self
Publishes the constraints of the extractor that declared them, on the one thing in this operation that extractor describes.
The target matters: handler arguments are described one after another, so a body and a query struct sharing a field name would otherwise hand each other their bounds. A field the target does not describe is ignored.
Sourcepub fn merge_outer(self, outer: &Self) -> Self
pub fn merge_outer(self, outer: &Self) -> Self
Merges the configuration of an enclosing scope - a route group - into this one.
Whatever the route describes for itself wins, exactly as in merge;
the difference is the order of the tags, which read outermost first no matter when
the group’s configuration was registered.