tamasfe/aide

Fix OpenApi deserialize

Closed this issue · 0 comments

I'm encountering an issue trying to deserialize OpenApi from the JSON file downloaded via redoc UI. OpenApi structure can't be correctly deserialized due to incorrect implementation of the serde_version::deserialize function for the openapi field.

This minimal test:

#[cfg(test)]
mod tests {
    use crate::openapi::OpenApi;

    #[test]
    fn test_default_openapi_deserialize() {
        let mut api = OpenApi::default();
        api.openapi = "3.1.0";

        let json = serde_json::to_string(&api).unwrap();

        let static_json = Box::leak(json.into_boxed_str());

        let deser_api = serde_json::from_str::<OpenApi>(static_json).unwrap();

        assert_eq!(api, deser_api);
    }
}

Ends up with error:

thread 'openapi::openapi::tests::test_default_openapi_deserialize' panicked at 'called `Result::unwrap()` on an `Err` value: Error("expected `,` or `}`", line: 1, column: 12)'
0

RUSTC: rustc 1.72.0 (5680fa18f 2023-08-23)