Giter VIP home page Giter VIP logo

openapi's Introduction

open api Build Status Software License crates.io

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

openapi's People

Contributors

boxdot avatar electron-libre avatar fredszaq avatar jordipolo avatar nbigaouette avatar onelson avatar pluehne avatar softprops avatar wildarch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

openapi's Issues

Better Error location output

Hi...

First, great work...

I'm having a lot of trouble with parsing yaml files.
But, it's really difficult to determine where the error lies.
All I get is:
error: Yaml(Message("data did not match any variant of untagged enum OpenApi", None))
I've trace'd it, I even created a Manual Deserializer.
It parses the top level, but has problems with a sub-level parsing (in "components").

Is there a way to get it to generate a better error.
At least the token it barfs on ?

Thanks
JR

Publish OpenApi 3.0

Crate version 0.1.5 does not include OpenApi 3.0 support, though it looks like the code for it has already been written. Can this be published?

Better ergonomics for Operations

I've started working on code based on this library and working with Operations is difficult I want to do something like:

for operation in operations {
  ...
}

But each operation is a different field in the structure, I do not know if it's possible to iterate them in Rust

Support for vendor extensions

Support keys in the format x-vendorextension. I believe these can be written at any level so maybe is a challenge to do with Serde

fix tests on master

It seems since the initial work on openapi v3 was introduced there has not been any clean up of failing tests. Some work was done in #25 (comment) to help surface errors more clearly to iterate on fixing them but it was out of scope of that pull to fix all the failing tests. lets open a separate pull that focuses mainly on get tests to pass so we can ship #22

Support for $ref part 2

Support for $ref as text was added before. But ideally these $ref are deserialized into pointers to other structs or something like that.
The deserialization should fail if the ref does not point to any known point.
To validate if a ref exist in the doc I'm doing this really really terrible code:
https://github.com/JordiPolo/oatool/blob/master/src/main.rs#L26

If real support is added, then all this code disappears as a non-proper ref would cause deserialization error.

Fail if the spec is not a supported version

Currently there is support for OpenAPI 2.0.
I think OpenAPI < 2.0 and > 2.0 are not compatible with 2.0 so probably the deserialization should check the version and fail gracefully

Unable to deser the "Basic Structure" example from the OpenAPI v2 spec

this crate is unable to deserialize the document shown here, in the OpenAPI v2 spec: https://swagger.io/docs/specification/2-0/basic-structure/ . It fails with the following error:

---- test_basic_structure stdout ----
thread 'test_basic_structure' panicked at 'Couldn't deser doc: Yaml(Message("data did not match any variant of untagged enum OpenApi", None))', src/lib.rs:34:15
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Here is the code I used to generate the error:

#[test]
fn test_basic_structure() {
    use std::io::{self, Cursor};

    let doc = r#"swagger: "2.0"
info:
  title: Sample API
  description: API description in Markdown.
  version: 1.0.0

host: api.example.com
basePath: /v1
schemes:
  - https

paths:
  /users:
    get:
      summary: Some text
      description: Some more text
      produces:
        - application/json
      responses:
        200:
          description: OK"#.to_string();

    let bytes = doc.as_bytes().to_vec();
    let mut bytes = Cursor::new(bytes);

    let api = openapi::from_reader(&mut bytes).expect("Couldn't deser doc");
}

is help needed?

There seem to be lots of unmerged PRs, and unreleased code changes. Is help needed?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.