pub struct OpenApi31Spec {
pub openapi: String,
pub info: ApiInfo31,
pub json_schema_dialect: Option<String>,
pub servers: Option<Vec<Server>>,
pub paths: HashMap<String, PathItem>,
pub webhooks: Option<HashMap<String, Webhook>>,
pub components: Option<Components31>,
pub security: Option<Vec<HashMap<String, Vec<String>>>>,
pub tags: Option<Vec<Tag>>,
pub external_docs: Option<ExternalDocs>,
}Expand description
OpenAPI 3.1.0 specification
Fields§
§openapi: StringOpenAPI version (always “3.1.0”)
info: ApiInfo31API information
json_schema_dialect: Option<String>JSON Schema dialect (optional, defaults to JSON Schema 2020-12)
servers: Option<Vec<Server>>Server list
paths: HashMap<String, PathItem>API paths
webhooks: Option<HashMap<String, Webhook>>Webhooks (new in 3.1)
components: Option<Components31>Components (schemas, security schemes, etc.)
security: Option<Vec<HashMap<String, Vec<String>>>>Security requirements
Tags for organization
external_docs: Option<ExternalDocs>External documentation
Implementations§
Source§impl OpenApi31Spec
impl OpenApi31Spec
Sourcepub fn new(title: impl Into<String>, version: impl Into<String>) -> Self
pub fn new(title: impl Into<String>, version: impl Into<String>) -> Self
Create a new OpenAPI 3.1.0 specification
Sourcepub fn description(self, desc: impl Into<String>) -> Self
pub fn description(self, desc: impl Into<String>) -> Self
Set API description
Sourcepub fn terms_of_service(self, url: impl Into<String>) -> Self
pub fn terms_of_service(self, url: impl Into<String>) -> Self
Set terms of service URL
Sourcepub fn webhook(self, name: impl Into<String>, webhook: Webhook) -> Self
pub fn webhook(self, name: impl Into<String>, webhook: Webhook) -> Self
Add a webhook (new in 3.1)
Sourcepub fn schema(self, name: impl Into<String>, schema: JsonSchema2020) -> Self
pub fn schema(self, name: impl Into<String>, schema: JsonSchema2020) -> Self
Add a schema to components
Sourcepub fn schema_from_30(self, name: impl Into<String>, schema: Value) -> Self
pub fn schema_from_30(self, name: impl Into<String>, schema: Value) -> Self
Add a schema from an existing OpenAPI 3.0 schema (will be transformed)
Sourcepub fn register<T: for<'a> ToSchema<'a>>(self) -> Self
pub fn register<T: for<'a> ToSchema<'a>>(self) -> Self
Register a type that implements utoipa::ToSchema
The schema will be automatically transformed to OpenAPI 3.1 format
Sourcepub fn security_scheme(
self,
name: impl Into<String>,
scheme: SecurityScheme,
) -> Self
pub fn security_scheme( self, name: impl Into<String>, scheme: SecurityScheme, ) -> Self
Add a security scheme
Sourcepub fn security_requirement(
self,
name: impl Into<String>,
scopes: Vec<String>,
) -> Self
pub fn security_requirement( self, name: impl Into<String>, scopes: Vec<String>, ) -> Self
Add a global security requirement
Sourcepub fn external_docs(self, docs: ExternalDocs) -> Self
pub fn external_docs(self, docs: ExternalDocs) -> Self
Set external documentation
Sourcepub fn callback(self, name: impl Into<String>, callback: Callback) -> Self
pub fn callback(self, name: impl Into<String>, callback: Callback) -> Self
Add a callback to components
Sourcepub fn to_json_pretty(&self) -> String
pub fn to_json_pretty(&self) -> String
Convert to pretty-printed JSON string
Trait Implementations§
Source§impl Clone for OpenApi31Spec
impl Clone for OpenApi31Spec
Source§fn clone(&self) -> OpenApi31Spec
fn clone(&self) -> OpenApi31Spec
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more