Expand description
The OpenAPI 3.1 and 3.2 document model.
This crate is the data model Kynos emits into, and is deliberately free of
any runtime dependency: no tokio, no hyper. It can be used on its own to
build, serialize, or validate an OpenAPI description.
§Specification versions
openapi31 is the baseline and is enabled by default. openapi32 adds the
fields introduced by OpenAPI 3.2.0 as a strict superset.
Fields introduced by 3.2 are #[cfg]-gated rather than runtime-optional, so
a build without openapi32 cannot construct a document it would be unable
to describe. Where a program needs a 3.1 document from a build that has
openapi32 enabled — Cargo unifies features across a dependency graph, so
this is not always the program’s own choice — use Document::emit, which
fails with the list of 3.2-only constructs that block the downgrade rather
than silently emitting an invalid description.
§A note on the JSON Schema dialect
OpenAPI 3.2 did not mint a new JSON Schema dialect. Both 3.1 and 3.2 use
https://spec.openapis.org/oas/3.1/dialect/base, exposed here as
model::schema::dialect::OAS_DIALECT. It is not versioned by feature
flag.
§Example
use kynos_openapi::{Document, Info, SpecVersion};
let doc = Document::new(SpecVersion::V3_1, Info::new("Orders", "1.0.0"));
let json = doc.to_json().expect("serializable");
assert!(json.contains("\"openapi\""));Re-exports§
pub use crate::annotation::MalformedAnnotation;pub use crate::annotation::Opaque;pub use crate::annotation::OpaqueReason;pub use crate::annotation::OpaqueRoute;pub use crate::model::body::RequestBody;pub use crate::model::body::encoding::Encoding;pub use crate::model::body::media_type::MediaType;pub use crate::model::callback::Callback;pub use crate::model::components::ComponentName;pub use crate::model::components::Components;pub use crate::model::document::Document;pub use crate::model::document::SpecVersion;pub use crate::model::example::Example;pub use crate::model::example::ExampleValue;pub use crate::model::example::Examples;pub use crate::model::extensions::Extensions;pub use crate::model::external_docs::ExternalDocumentation;pub use crate::model::info::Contact;pub use crate::model::info::Info;pub use crate::model::info::License;pub use crate::model::link::Link;pub use crate::model::link::LinkTarget;pub use crate::model::parameter::Parameter;pub use crate::model::parameter::ParameterIn;pub use crate::model::parameter::ParameterShape;pub use crate::model::parameter::header::Header;pub use crate::model::parameter::header::HeaderShape;pub use crate::model::parameter::style::EncodingStyle;pub use crate::model::parameter::style::HeaderStyle;pub use crate::model::parameter::style::Style;pub use crate::model::paths::Paths;pub use crate::model::paths::item::PathItem;pub use crate::model::paths::method::Method;pub use crate::model::paths::operation::Operation;pub use crate::model::paths::template::PathTemplate;pub use crate::model::reference::Ref;pub use crate::model::reference::RefOr;pub use crate::model::response::Response;pub use crate::model::response::Responses;pub use crate::model::response::status::StatusPattern;pub use crate::model::schema::Schema;pub use crate::model::schema::discriminator::Discriminator;pub use crate::model::schema::object::SchemaObject;pub use crate::model::schema::xml::Xml;pub use crate::model::security::SecurityScheme;pub use crate::model::security::oauth::OAuthFlow;pub use crate::model::security::oauth::OAuthFlows;pub use crate::model::security::requirement::SecurityRequirement;pub use crate::model::server::Server;pub use crate::model::server::ServerVariable;pub use crate::model::tag::Tag;pub use crate::validate::violation::Severity;pub use crate::validate::violation::SpecError;pub use crate::validate::violation::Violation;
Modules§
- annotation
- The
x-kynos-*annotations: what a waiver leaves on a description. - emit
- Producing an artifact from a
Document, at a chosen specification version. - model
- The OpenAPI object model.
- validate
- Structural validation of a
Document.
Type Aliases§
- Map
- The ordered map used throughout the model.