pub struct OpenApiRegistry { /* private fields */ }Expand description
OpenAPI runtime registry.
Implementations§
Source§impl OpenApiRegistry
impl OpenApiRegistry
Sourcepub fn new(config: OpenApiConfig) -> Self
pub fn new(config: OpenApiConfig) -> Self
Creates a new OpenApiRegistry
Sourcepub fn register_route(
&self,
method: &Method,
path: &str,
cfg: &OpenApiRouteConfig,
)
pub fn register_route( &self, method: &Method, path: &str, cfg: &OpenApiRouteConfig, )
Registers a route in the OpenAPI registry.
Sourcepub fn describe_route_in(
&self,
method: &Method,
path: &str,
cfg: &OpenApiRouteConfig,
docs: &[&str],
)
pub fn describe_route_in( &self, method: &Method, path: &str, cfg: &OpenApiRouteConfig, docs: &[&str], )
Registers a route in docs alone and applies its configuration there.
docs is meant to be some of the documents cfg names - see Self::docs_for - for a
route that has to be left out of the rest. A name no document carries is skipped.
Sourcepub fn describe_route_as(
&self,
method: &Method,
path: &str,
template: &str,
cfg: &OpenApiRouteConfig,
docs: &[&str],
)
pub fn describe_route_as( &self, method: &Method, path: &str, template: &str, cfg: &OpenApiRouteConfig, docs: &[&str], )
Describes a route in docs alone, under the path template spells, replacing the
operation its method has there.
template is a pattern at the route’s own position that names its parameters
otherwise - another route’s. A document takes one set of names for one templated
path, so a route at a position other routes name differently is described under
theirs: its path parameters are renamed position by position, after the ones its
configuration describes are merged in under the names the route was written with.
A name no document carries is skipped.
The operation is built from cfg alone, as Self::rebind_route builds it.
Sourcepub fn remove_position(&self, path: &str)
pub fn remove_position(&self, path: &str)
Removes every operation at the position path is at from every spec, whatever the
parameters there are named - see Self::describe_route_as.
Sourcepub fn docs_for<'a>(&'a self, cfg: &'a OpenApiRouteConfig) -> Vec<&'a str>
pub fn docs_for<'a>(&'a self, cfg: &'a OpenApiRouteConfig) -> Vec<&'a str>
Returns the names of the documents a route configured with cfg is described in: the
ones it is bound to, or the first spec when it is bound to none.
Sourcepub fn rebind_route(
&self,
method: &Method,
path: &str,
cfg: &OpenApiRouteConfig,
)
pub fn rebind_route( &self, method: &Method, path: &str, cfg: &OpenApiRouteConfig, )
Rebinds route to another spec.
Sourcepub fn remove_route(&self, method: &Method, path: &str)
pub fn remove_route(&self, method: &Method, path: &str)
Removes a route’s operation from every spec.
A route that is not in a spec is left out of it, so removing one that was never registered does nothing.
Sourcepub fn apply_route_config(
&self,
method: &Method,
path: &str,
cfg: &OpenApiRouteConfig,
)
pub fn apply_route_config( &self, method: &Method, path: &str, cfg: &OpenApiRouteConfig, )
Applies route configuration
Sourcepub fn document_by_name(&self, name: &str) -> Option<OpenApiDocument>
pub fn document_by_name(&self, name: &str) -> Option<OpenApiDocument>
Returns OpenAPI document by spec name.
Sourcepub fn specs(&self) -> &[OpenApiSpec]
pub fn specs(&self) -> &[OpenApiSpec]
Returns a list of defined specs