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 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§

Modules§

Structs§

Enums§

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 to null in JSON and schema::empty is used to create the schema::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 in OpenApi.
  • Generate responses with status codes what can be attached to the salvo_oapi::endpoint.
  • This is #[derive] implementation for ToSchema trait. The macro accepts one schema 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.