openapi
openapi copied to clipboard
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");
}
I think this is related to this serde_yaml issue, if so I will close this: https://github.com/dtolnay/serde-yaml/issues/165