Skip to main content

Crate fastapi_openapi

Crate fastapi_openapi 

Source
Expand description

OpenAPI 3.1 types and schema generation.

This crate provides:

  • OpenAPI 3.1 document types
  • JSON Schema types
  • JsonSchema trait 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§

ArraySchema
Array schema.
Components
Reusable components.
ConstSchema
Schema for a constant value (used for unit enum variants).
Discriminator
Discriminator for oneOf schemas (OpenAPI 3.1).
EnumSchema
Enum/union schema supporting oneOf, anyOf, allOf, and string enums.
Example
Example object for OpenAPI.
Info
API information.
MediaType
Media type content.
OAuth2Flow
OAuth 2.0 flow configuration.
OAuth2Flows
OAuth 2.0 flow configurations.
ObjectSchema
Object schema.
OpenApi
OpenAPI 3.1 document.
OpenApiBuilder
OpenAPI document builder.
Operation
API operation.
ParamMeta
Parameter metadata for OpenAPI documentation.
Parameter
Operation parameter.
PathItem
Path item (operations for a path).
PrimitiveSchema
Primitive type schema.
RefSchema
Schema reference.
RequestBody
Request body.
Response
Response definition.
SchemaRegistry
Registry for collecting and deduplicating JSON schemas.
Server
Server information.
StringEnumSchema
Schema for string enums (unit variants only).
Tag
API tag.

Enums§

ApiKeyLocation
Location of an API key.
ParameterLocation
Parameter location.
Schema
JSON Schema representation.
SchemaType
JSON Schema primitive types.
SecurityScheme
Security scheme definition.

Traits§

HasParamMeta
Trait for types that provide parameter metadata.
JsonSchema
Trait for types that can generate JSON Schema.

Functions§

converter_to_schema
Convert a router Converter type to an OpenAPI Schema.
param_info_to_parameter
Convert a ParamInfo to an OpenAPI Parameter object.
path_params_to_parameters
Extract path parameters from a route path pattern and convert them to OpenAPI Parameters.

Type Aliases§

SecurityRequirement
Security requirement object.