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,NaiveDateandDurationtypes. By default these types are parsed tostringtypes with additionalformatinformation.format: date-timeforDateTimeandformat: dateforDateandNaiveDateaccording RFC3339 asISO-8601. To override defaultstringrepresentation users have to usevalue_typeattribute to override the type. See docs for more details. - time Add support for time
OffsetDateTime,PrimitiveDateTime,Date, andDurationtypes. By default these types are parsed asstring.OffsetDateTimeandPrimitiveDateTimewill usedate-timeformat.Datewill usedateformat andDurationwill not have any format. To override defaultstringrepresentation users have to usevalue_typeattribute to override the type. See docs for more details. - decimal Add support for rust_decimal
Decimaltype. By default it is interpreted asString. If you wish to change the format you need to override the type. See thevalue_typeinToSchemaderive docs. - uuid Add support for uuid.
Uuidtype will be presented asStringwith formatuuidin OpenAPI spec. - ulid Add support for ulid.
Ulidtype will be presented asStringwith formatulidin OpenAPI spec. - url Add support for url.
Urltype will be presented asStringwith formaturiin OpenAPI spec. - smallvec Add support for smallvec.
SmallVecwill be treated asVec. - indexmap Add support for indexmap. When enabled
IndexMapwill be rendered as a map similar toBTreeMapandHashMap.
Go beyond the surface
- Browse to examples for more comprehensive examples.
- Check
ToResponsesandToResponsefor 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 module
- 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
rapidocThis crate implements necessary boiler plate code to serve RapiDoc via web server. It works as a bridge for serving the OpenAPI documentation created withsalvolibrary in the RapiDoc. - redoc
redocThis crate implements necessary boiler plate code to serve ReDoc via web server. It works as a bridge for serving the OpenAPI documentation created withsalvolibrary in the ReDoc. - Implements OpenAPI Request Body types.
- Implements OpenApi Responses.
- 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-uiThis crate implements necessary boiler plate code to serve Swagger UI via web server. It works as a bridge for serving the OpenAPI documentation created withsalvolibrary 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
OneOfcomposite 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
Schemas as properties to thisSchema. - Root object of the OpenAPI document.
- Implements OpenAPI Operation Object object.
- Collection for save
Operations. - Implements OpenAPI Parameter Object for
Operation. - Collection for OpenAPI Parameter Objects.
- Implements OpenAPI Path Item Object what describes
Operations available on a single path. - Implements OpenAPI Path Object types.
- Implements OpenAPI Reference Object that can be used to reference reusable components such as
Schemas orResponses. - 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
Serverobjects. - 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
Parametershould be serialized. - Path item operation type.
- A
Refor 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
SchemaTypeto fine tune the data type used. If the format is not supported by the UI it may default back toSchemaTypealone. 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
Parameterinformation 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
nullabletype. This can be used anywhere where “nothing” needs to be evaluated. This will serialize tonullin JSON andschema::emptyis used to create theschema::Schemafor the type.
Attribute Macros
- Endpoint attribute macro implements OpenAPI path for the decorated function.
Derive Macros
- Generate path parameters from struct’s fields.
- Generate reusable OpenAPI response what can be used in
salvo_oapi::endpointor inOpenApi. - Generate responses with status codes what can be attached to the
salvo_oapi::endpoint. - This is
#[derive]implementation forToSchematrait. The macro accepts oneschemaattribute 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.