Crate salvo_oapi

Crate salvo_oapi 

Source
Expand description

OpenAPI support for salvo, modified from utoipa, It uses simple proc macros which you can use to annotate your code to have items documented.

§Crate Features

  • yaml Enables serde_norway serialization of OpenAPI objects.

  • chrono Add support for chrono DateTime, Date, NaiveDate and Duration types. By default these types are parsed to string types with additional format information. format: date-time for DateTime and format: date for Date and NaiveDate according RFC3339 as ISO-8601. To override default string representation users have to use value_type attribute to override the type. See docs for more details.

  • time Add support for time OffsetDateTime, PrimitiveDateTime, Date, and Duration types. By default these types are parsed as string. OffsetDateTime and PrimitiveDateTime will use date-time format. Date will use date format and Duration will not have any format. To override default string representation users have to use value_type attribute to override the type. See docs for more details.

  • decimal Add support for rust_decimal Decimal type. By default it is interpreted as String. If you wish to change the format you need to override the type. See the value_type in ToSchema derive docs.

  • decimal-float Add support for rust_decimal Decimal type. By default it is interpreted as Number. This feature is mutually exclusive with decimal and allow to change the default type used in your documentation for Decimal much like serde_with_float feature exposed by rust_decimal.

  • uuid Add support for uuid. Uuid type will be presented as String with format uuid in OpenAPI spec.

  • ulid Add support for ulid. Ulid type will be presented as String with format ulid in OpenAPI spec.

  • url Add support for url. Url type will be presented as String with format uri in OpenAPI spec.

  • smallvec Add support for smallvec. SmallVec will be treated as Vec.

  • indexmap Add support for indexmap. When enabled IndexMap will be rendered as a map similar to BTreeMap and HashMap.

§Go beyond the surface

Re-exports§

pub use endpoint::Endpoint;
pub use endpoint::EndpointArgRegister;
pub use endpoint::EndpointOutRegister;

Modules§

endpoint
Enhanced of handler for generate OpenAPI documentation.
extract
Request extractors for the API operation.
info
Implements OpenAPI Metadata types.
naming
Module for name schemas.
operation
Implements OpenAPI Operation Object types.
parameter
Implements OpenAPI Parameter Object types.
path
Implements OpenAPI Path Object types.
rapidocrapidoc
This crate implements necessary boiler plate code to serve RapiDoc via web server. It works as a bridge for serving the OpenAPI documentation created with salvo library in the RapiDoc.
redocredoc
This crate implements necessary boiler plate code to serve ReDoc via web server. It works as a bridge for serving the OpenAPI documentation created with salvo library in the ReDoc.
request_body
Implements OpenAPI Request Body types.
response
Implements OpenApi Responses.
scalarscalar
This crate implements necessary boiler plate code to serve Scalar via web server. It works as a bridge for serving the OpenAPI documentation created with salvo library in the Scalar.
schema
Implements OpenAPI Schema Object types which can be used to define field properties, enum values, array or object types.
security
Implements OpenAPI Security Schema types.
server
Implements OpenAPI Server Object types to configure target servers.
swagger_uiswagger-ui
This crate implements necessary boiler plate code to serve Swagger UI via web server. It works as a bridge for serving the OpenAPI documentation created with salvo library in the Swagger UI.

Structs§

Array
Array represents Vec or slice type of items.
Components
Implements OpenAPI Components Object which holds supported reusable objects.
Contact
OpenAPI Contact information of the API.
Content
Content holds request body content or response content.
Discriminator
OpenAPI Discriminator object which can be optionally used together with OneOf composite object.
Example
Implements OpenAPI Example Object.
ExternalDocs
Reference of external resource allowing extended documentation.
Header
Implements OpenAPI Header Object for response headers.
Info
Examples
License
OpenAPI License information of the API.
Object
Implements subset of OpenAPI Schema Object which allows adding other Schemas as properties to this Schema.
OpenApi
Root object of the OpenAPI document.
Operation
Implements OpenAPI Operation Object object.
Operations
Collection for save Operations.
Parameter
Implements OpenAPI Parameter Object for Operation.
Parameters
Collection for OpenAPI Parameter Objects.
PathItem
Implements OpenAPI Path Item Object what describes Operations available on a single path.
Paths
Implements OpenAPI Path Object types.
Ref
Implements OpenAPI Reference Object that can be used to reference reusable components such as Schemas or Responses.
RequestBody
Implements OpenAPI Request Body.
Response
Implements OpenAPI Response Object.
Responses
Implements OpenAPI Responses Object.
Schemas
Schemas collection for OpenApi.
SecurityRequirement
OpenAPI security requirement object.
Server
Represents target server object. It can be used to alter server connection for path operations.
ServerVariable
Implements OpenAPI Server Variable used to substitute variables in Server::url.
ServerVariables
Server Variables information for OpenApi.
Servers
Collection for Server objects.
Tag
Implements OpenAPI Tag Object.
Xml
Implements OpenAPI Xml Object.

Enums§

BasicType
Represents data type fragment of Schema.
Deprecated
Value used to indicate whether reusable schema, parameter or operation is deprecated.
KnownFormat
Known schema format modifier property to provide fine detail of the primitive type.
OpenApiVersion
Represents available OpenAPI versions.
ParameterIn
In definition of Parameter.
ParameterStyle
Defines how Parameter should be serialized.
PathItemType
Path item operation type.
RefOr
A Ref or some other type T.
Required
Value used to indicate whether parameter or property is required.
Schema
Is super type for OpenAPI Schema Object. Schema is reusable resource what can be referenced from path operations and other components using Ref.
SchemaFormat
Additional format for SchemaType to fine tune the data type used.
SchemaType
Represents type of Schema.
SecurityScheme
OpenAPI security scheme for path operations.

Traits§

RouterExt
Router extension trait for openapi metadata.
ToParameter
Trait used to give Parameter information for OpenAPI.
ToParameters
Trait used to convert implementing type to OpenAPI parameters.
ToRequestBody
This trait is implemented to document a type (like an enum) which can represent request body, to be used in operation.
ToResponse
This trait is implemented to document a type which represents a single response which can be referenced or reused as a component in multiple operations.
ToResponses
This trait is implemented to document a type (like an enum) which can represent multiple responses, to be used in operation.
ToSchema
Trait for implementing OpenAPI Schema object.

Type Aliases§

PathMap
The structure of the internal storage object paths.
PropMap
The structure of the internal storage object properties.
TupleUnit
Represents nullable type.

Attribute Macros§

endpoint
Enhanced of handler for generate OpenAPI documentation.

Derive Macros§

ToParameters
Generate parameters from struct’s fields.
ToResponse
Generate reusable OpenApi response.
ToResponses
Generate responses with status codes what can be used in OpenApi.
ToSchema
This is #[derive] implementation for ToSchema trait.