Expand description
OpenAPI 3.1 types and schema generation.
This crate provides:
- OpenAPI 3.1 document types
- JSON Schema types
JsonSchematrait for compile-time schema generation
§Role In The System
fastapi-openapi owns the OpenAPI 3.1 and JSON Schema data model. It is
fed by metadata emitted from fastapi-macros and by runtime route info from
fastapi-core/fastapi-router. The resulting spec is then exposed through
the fastapi facade so applications can serve or export documentation.
§Example
ⓘ
use fastapi_openapi::{OpenApiBuilder, JsonSchema};
#[derive(JsonSchema)]
struct Item {
id: i64,
name: String,
}
let spec = OpenApiBuilder::new("My API", "1.0.0")
.route(&get_items_route())
.build();Structs§
- Array
Schema - Array schema.
- Components
- Reusable components.
- Const
Schema - Schema for a constant value (used for unit enum variants).
- Discriminator
- Discriminator for oneOf schemas (OpenAPI 3.1).
- Enum
Schema - Enum/union schema supporting oneOf, anyOf, allOf, and string enums.
- Example
- Example object for OpenAPI.
- Info
- API information.
- Media
Type - Media type content.
- OAuth2
Flow - OAuth 2.0 flow configuration.
- OAuth2
Flows - OAuth 2.0 flow configurations.
- Object
Schema - Object schema.
- OpenApi
- OpenAPI 3.1 document.
- Open
ApiBuilder - OpenAPI document builder.
- Operation
- API operation.
- Param
Meta - Parameter metadata for OpenAPI documentation.
- Parameter
- Operation parameter.
- Path
Item - Path item (operations for a path).
- Primitive
Schema - Primitive type schema.
- RefSchema
- Schema reference.
- Request
Body - Request body.
- Response
- Response definition.
- Schema
Registry - Registry for collecting and deduplicating JSON schemas.
- Server
- Server information.
- String
Enum Schema - Schema for string enums (unit variants only).
- Tag
- API tag.
Enums§
- ApiKey
Location - Location of an API key.
- Parameter
Location - Parameter location.
- Schema
- JSON Schema representation.
- Schema
Type - JSON Schema primitive types.
- Security
Scheme - Security scheme definition.
Traits§
- HasParam
Meta - Trait for types that provide parameter metadata.
- Json
Schema - Trait for types that can generate JSON Schema.
Functions§
- converter_
to_ schema - Convert a router
Convertertype to an OpenAPISchema. - param_
info_ to_ parameter - Convert a
ParamInfoto an OpenAPIParameterobject. - path_
params_ to_ parameters - Extract path parameters from a route path pattern and convert them to OpenAPI Parameters.
Type Aliases§
- Security
Requirement - Security requirement object.