pub struct OpenApiBuilder { /* private fields */ }
Expand description
OpenAPI specificatrion builder.
Implementations§
Source§impl OpenApiBuilder
impl OpenApiBuilder
Sourcepub fn new(title: &str, version: &str) -> Self
pub fn new(title: &str, version: &str) -> Self
Create new builder with specified title and version
Sourcepub fn set_components(&mut self, new_components: Components) -> &mut Self
pub fn set_components(&mut self, new_components: Components) -> &mut Self
Alter default Components
.
§NOTE
This will override existing components in builder. Use this before adding anything to the builder.
Sourcepub fn try_operation<T>(
&mut self,
path: T,
method: Method,
generator: OperationGenerator,
) -> Result<&mut Self, Error>
pub fn try_operation<T>( &mut self, path: T, method: Method, generator: OperationGenerator, ) -> Result<&mut Self, Error>
Add single operation.
Throws an error if (path, method) pair is already present.
Sourcepub fn try_operations<I, S>(
&mut self,
operations: I,
) -> Result<&mut Self, Error>
pub fn try_operations<I, S>( &mut self, operations: I, ) -> Result<&mut Self, Error>
Add multiple operations.
Throws an error if any (path, method) pair is already present.
Sourcepub fn operation<T>(
&mut self,
path: T,
method: Method,
generator: OperationGenerator,
) -> &mut Self
pub fn operation<T>( &mut self, path: T, method: Method, generator: OperationGenerator, ) -> &mut Self
Add single operation.
Replaces operation if (path, method) pair is already present.
Sourcepub fn operations<I, S>(&mut self, operations: I) -> &mut Self
pub fn operations<I, S>(&mut self, operations: I) -> &mut Self
Add multiple operations.
Replaces operation if (path, method) pair is already present.
Sourcepub fn spec_mut(&mut self) -> &mut OpenApi
pub fn spec_mut(&mut self) -> &mut OpenApi
Access inner okapi::openapi3::OpenApi
.
Warning! This allows raw access to underlying OpenApi
object,
which might break generated specification.
§NOTE
Components are overwritten on building specification.
Sourcepub fn apply_global_security<N, S>(&mut self, name: N, scopes: S) -> &mut Self
pub fn apply_global_security<N, S>(&mut self, name: N, scopes: S) -> &mut Self
Apply security scheme globally.
Sourcepub fn build(&mut self) -> Result<OpenApi, Error>
pub fn build(&mut self) -> Result<OpenApi, Error>
Generate okapi::openapi3::OpenApi
specification.
This method can be called repeatedly on the same object.
Sourcepub fn title(&mut self, title: impl Into<String>) -> &mut Self
pub fn title(&mut self, title: impl Into<String>) -> &mut Self
Set specification title.
Empty string by default.
Sourcepub fn version(&mut self, version: impl Into<String>) -> &mut Self
pub fn version(&mut self, version: impl Into<String>) -> &mut Self
Set specification version.
Empty string by default.
Sourcepub fn description(&mut self, description: impl Into<String>) -> &mut Self
pub fn description(&mut self, description: impl Into<String>) -> &mut Self
Add description to specification.
Sourcepub fn terms_of_service(
&mut self,
terms_of_service: impl Into<String>,
) -> &mut Self
pub fn terms_of_service( &mut self, terms_of_service: impl Into<String>, ) -> &mut Self
Add terms_of_service to specification.
Sourcepub fn external_docs(&mut self, docs: ExternalDocs) -> &mut Self
pub fn external_docs(&mut self, docs: ExternalDocs) -> &mut Self
Set external documentation for specification.
Sourcepub fn security_scheme<N>(&mut self, name: N, sec: SecurityScheme) -> &mut Self
pub fn security_scheme<N>(&mut self, name: N, sec: SecurityScheme) -> &mut Self
Add security scheme definition to specification.
Trait Implementations§
Source§impl Clone for OpenApiBuilder
impl Clone for OpenApiBuilder
Source§fn clone(&self) -> OpenApiBuilder
fn clone(&self) -> OpenApiBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more