Crates.io | openapiv3-extended |
lib.rs | openapiv3-extended |
version | 6.0.0 |
source | src |
created_at | 2022-04-12 02:22:12.850556 |
updated_at | 2024-02-12 13:34:48.347279 |
description | This crate provides data structures that represent the OpenAPI v3.0.x specification easily deserializable with serde. |
homepage | https://github.com/kurtbuilds/openapiv3 |
repository | https://github.com/kurtbuilds/openapiv3 |
max_upload_size | |
id | 566207 |
size | 4,124,529 |
A library to de/serialize OpenAPI specifications. It offers:
[dependencies]
openapiv3-extended = ".."
Note the library is named openapiv3
and imported as use openapiv3;
, despite the package name being openapiv3-extended
.
This crate provides data structures that represent the OpenAPI v3.0.x specification. Note this does not cover OpenAPI v3.1 (yet) which was an incompatible change.
Here is a basic example:
use serde_json;
use openapiv3::OpenAPI;
fn main() {
let data = include_str!("openapi.json");
let openapi: OpenAPI = serde_json::from_str(data).unwrap();
println!("{:?}", openapi);
}
You can use this crate to upgrade a Swagger 2.0 spec to OpenAPI 3.0.x. To support v2, enable the v2
feature.
// [dependencies]
// openapiv3-extended = { version = "..", features = ["v2"] }
use openapiv3::VersionedOpenAPI;
fn main() {
let data = include_str!("swagger.json");
let openapi: VersionedOpenAPI = serde_json::from_str(data).unwrap();
println!("{:?}", openapi);
let openapi: OpenAPI = openapi.upgrade(); // version 3.0
println!("{:?}", openapi);
}
This library started as a fork of https://github.com/glademiller/openapiv3. Both libraries support full de/ser of OpenAPI v3.0 specs. This fork offers:
Schemas without a type will end up as any data type as per the specification and can have any parameters of any schema type. Some Open API documents don't include the type parameter it would be nice to try to derive the type but the crate as of right now meets my needs.