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_yaml serialization of OpenAPI objects.
-
chrono Add support for chrono
DateTime
,Date
,NaiveDate
andDuration
types. By default these types are parsed tostring
types with additionalformat
information.format: date-time
forDateTime
andformat: date
forDate
andNaiveDate
according RFC3339 asISO-8601
. To override defaultstring
representation users have to usevalue_type
attribute to override the type. See docs for more details. -
time Add support for time
OffsetDateTime
,PrimitiveDateTime
,Date
, andDuration
types. By default these types are parsed asstring
.OffsetDateTime
andPrimitiveDateTime
will usedate-time
format.Date
will usedate
format andDuration
will not have any format. To override defaultstring
representation users have to usevalue_type
attribute to override the type. See docs for more details. -
decimal Add support for rust_decimal
Decimal
type. By default it is interpreted asString
. If you wish to change the format you need to override the type. See thevalue_type
inToSchema
derive docs. -
decimal-float Add support for rust_decimal
Decimal
type. By default it is interpreted asNumber
. This feature is mutually exclusive with decimal and allow to change the default type used in your documentation forDecimal
much likeserde_with_float
feature exposed by rust_decimal. -
uuid Add support for uuid.
Uuid
type will be presented asString
with formatuuid
in OpenAPI spec. -
ulid Add support for ulid.
Ulid
type will be presented asString
with formatulid
in OpenAPI spec. -
url Add support for url.
Url
type will be presented asString
with formaturi
in OpenAPI spec. -
smallvec Add support for smallvec.
SmallVec
will be treated asVec
. -
indexmap Add support for indexmap. When enabled
IndexMap
will be rendered as a map similar toBTreeMap
andHashMap
.
§Go beyond the surface
- Browse to examples for more comprehensive examples.
- Check
ToResponses
andToResponse
for examples on deriving responses. - More about OpenAPI security in security documentation.
Re-exports§
pub use endpoint::Endpoint;
pub use endpoint::EndpointArgRegister;
pub use endpoint::EndpointOutRegister;
pub use endpoint::EndpointRegistry;
Modules§
- Endpoint attribute macro implements OpenAPI path for the decorated function.
- Request extractors for the API operation.
- Implements OpenAPI Metadata types.
- Implements OpenAPI Operation Object types.
- Implements OpenAPI Parameter Object types.
- Implements OpenAPI Path Object types.
- rapidoc
rapidoc
This crate implements necessary boiler plate code to serve RapiDoc via web server. It works as a bridge for serving the OpenAPI documentation created withsalvo
library in the RapiDoc. - redoc
redoc
This crate implements necessary boiler plate code to serve ReDoc via web server. It works as a bridge for serving the OpenAPI documentation created withsalvo
library in the ReDoc. - Implements OpenAPI Request Body types.
- Implements OpenApi Responses.
- scalar
scalar
This crate implements necessary boiler plate code to serve Scalar via web server. It works as a bridge for serving the OpenAPI documentation created withsalvo
library in the Scalar. - Implements OpenAPI Schema Object types which can be used to define field properties, enum values, array or object types.
- Implements OpenAPI Security Schema types.
- Implements OpenAPI Server Object types to configure target servers.
- swagger_ui
swagger-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 withsalvo
library in the Swagger UI.
Structs§
- Implements OpenAPI Components Object which holds supported reusable objects.
- OpenAPI Contact information of the API.
- Content holds request body content or response content.
- OpenAPI Discriminator object which can be optionally used together with
OneOf
composite object. - Implements OpenAPI Example Object.
- Reference of external resource allowing extended documentation.
- Implements OpenAPI Header Object for response headers.
- Examples
- OpenAPI License information of the API.
- Implements subset of OpenAPI Schema Object which allows adding other
Schema
s as properties to thisSchema
. - Root object of the OpenAPI document.
- Implements OpenAPI Operation Object object.
- Collection for save
Operation
s. - Implements OpenAPI Parameter Object for
Operation
. - Collection for OpenAPI Parameter Objects.
- Implements OpenAPI Path Item Object what describes
Operation
s available on a single path. - Implements OpenAPI Path Object types.
- Implements OpenAPI Reference Object that can be used to reference reusable components such as
Schema
s orResponse
s. - Implements OpenAPI Request Body.
- Implements OpenAPI Response Object.
- Implements OpenAPI Responses Object.
- OpenAPI security requirement object.
- Represents target server object. It can be used to alter server connection for path operations.
- Implements OpenAPI Server Variable used to substitute variables in
Server::url
. - Server Variables information for OpenApi.
- Collection for
Server
objects. - Implements OpenAPI Tag Object.
- Implements OpenAPI Xml Object.
Enums§
- Value used to indicate whether reusable schema, parameter or operation is deprecated.
- Known schema format modifier property to provide fine detail of the primitive type.
- Represents available OpenAPI versions.
- In definition of
Parameter
. - Defines how
Parameter
should be serialized. - Path item operation type.
- A
Ref
or some other typeT
. - Value used to indicate whether parameter or property is required.
- Is super type for OpenAPI Schema Object. Schema is reusable resource what can be referenced from path operations and other components using
Ref
. - Additional format for
SchemaType
to fine tune the data type used. If the format is not supported by the UI it may default back toSchemaType
alone. Format is an open value, so you can use any formats, even not those defined by the OpenAPI Specification. - Represents data type of
Schema
. - OpenAPI security scheme for path operations.
Traits§
- Trait for converting a type to
Array
. - Trait used to give
Parameter
information for OpenAPI. - Trait used to convert implementing type to OpenAPI parameters.
- This trait is implemented to document a type (like an enum) which can represent request body, to be used in operation.
- 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.
- This trait is implemented to document a type (like an enum) which can represent multiple responses, to be used in operation.
- Trait for implementing OpenAPI Schema object.
Type Aliases§
- Represents
nullable
type. This can be used anywhere where “nothing” needs to be evaluated. This will serialize tonull
in JSON andschema::empty
is used to create theschema::Schema
for the type.
Attribute Macros§
Derive Macros§
- Generate path parameters from struct’s fields.
- Generate reusable OpenAPI response what can be used in
salvo_oapi::endpoint
or inOpenApi
. - Generate responses with status codes what can be attached to the
salvo_oapi::endpoint
. - This is
#[derive]
implementation forToSchema
trait. The macro accepts oneschema
attribute optionally which can be used to enhance generated documentation. The attribute can be placed at item level or field level in struct and enums. Currently placing this attribute to unnamed field does not have any effect.