1 unstable release

0.1.5 Sep 5, 2019

#57 in #swagger

23 downloads per month
Used in cargo-rocketapi

MIT license

115KB
1K SLoC

open api Build Status Software License

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 or 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

~6.5–8.5MB
~202K SLoC