6 releases

Uses old Rust 2015

0.1.5 Apr 30, 2017
0.1.4 Apr 26, 2017

#61 in #swagger

Download history 138/week @ 2024-12-02 136/week @ 2024-12-09 271/week @ 2024-12-16 394/week @ 2024-12-23 175/week @ 2024-12-30 278/week @ 2025-01-06 207/week @ 2025-01-13 130/week @ 2025-01-20 203/week @ 2025-01-27 136/week @ 2025-02-03 105/week @ 2025-02-10 160/week @ 2025-02-17 128/week @ 2025-02-24 206/week @ 2025-03-03 166/week @ 2025-03-10 99/week @ 2025-03-17

605 downloads per month
Used in 2 crates (via service_policy_kit)

MIT license

94KB
190 lines

open api Build Status

Rust crate for serializing and deserializing open api documents

Documentation

install

add the following to your Cargo.toml file

[dependencies]
openapi = "0.1"

usage

extern crate openapi;

fn main() {
  match openapi::from_path("path/to/openapi.yaml") {
    Ok(spec) => println!("spec: {:?}", spec),
    Err(err) => println!("error: {}", err)
  }
}

Doug Tangren (softprops) 2017


lib.rs:

Openapi provides structures and support for serializing and deserializing openapi specifications

Examples

Typical use deserialing an existing to a persisted spec to rust form of visa versa

The hyper client should be configured with tls.

extern crate openapi;

fn main() {
  match openapi::from_path("path/to/openapi.yaml") {
    Ok(spec) => println!("spec: {:?}", spec),
    Err(err) => println!("error: {}", err)
  }
}

Errors

Operations typically result in a openapi::Result Type which is an alias for Rust's built-in Result with the Err Type fixed to the openapi::errors::Error enum type. These are provided using error_chain crate so their shape and behavior should be consistent and familiar to existing error_chain users.

Dependencies

~3.5–9.5MB
~112K SLoC