#openapi #serde-json #deserialize #specification #structures #v3 #deserializable

openapiv3

This crate provides data structures that represent the OpenAPI v3.0.x specification easily deserializable with serde

23 releases (5 stable)

2.0.0 Dec 8, 2023
2.0.0-rc.1 Oct 21, 2023
1.0.4 Dec 13, 2023
1.0.3 Aug 28, 2023
0.1.3 Mar 5, 2019

#41 in Encoding

Download history 20874/week @ 2024-07-21 16614/week @ 2024-07-28 20516/week @ 2024-08-04 24289/week @ 2024-08-11 21600/week @ 2024-08-18 20844/week @ 2024-08-25 17445/week @ 2024-09-01 18975/week @ 2024-09-08 18983/week @ 2024-09-15 26134/week @ 2024-09-22 24312/week @ 2024-09-29 25622/week @ 2024-10-06 27114/week @ 2024-10-13 30790/week @ 2024-10-20 30130/week @ 2024-10-27 29946/week @ 2024-11-03

118,946 downloads per month
Used in 83 crates (42 directly)

MIT/Apache

375KB
2K SLoC

OpenAPI v3 example workflow

This crate provides data structures that represent the OpenAPI v3.0.x specification. Note this does not cover OpenAPI v3.1 which was an incompatible change.

Example

use serde_json;
use openapiv3::OpenAPI;

fn main() {
    let data = include_str!("openapi.json");
    let openapi: OpenAPI = serde_json::from_str(data).expect("Could not deserialize input");
    println!("{:?}", openapi);
}

Goals

  • Provide a deserialization for the specification that maps cleanly to Rust enums etc.

Non Goals

  • Deserialization and subsequent re-serialization are 100% the same.
    • Some defaults show-up when serializing that may not have existed in the input.

Issues

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.

Similar Crates

License

This crate is licensed under either of

Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1.4–2.5MB
~49K SLoC