This PR adds the required implementation for OpenAPI v3.0.1. Should fix #7, or at least partially.
In addition to v3.0, this PR adds two new tests (one for v2 and one for v3.0).
Those two tests will deserialize and re-serialize input files to a JSON string through two different
paths, comparing the result.
- File ->
String
-> serde_yaml::Value
-> serde_json::Value
-> String
- File ->
Spec
-> serde_json::Value
-> String
Both conversions of serde_json::Value
-> String
are done using serde_json::to_string_pretty
.
Since the first conversion is independant of the current crate (and only uses serde's json and yaml support), no information should be lost in the final JSON string.
The second conversion goes through the OpenApi
enum, so the final JSON string is a representation of the crate implementation.
By comparing those two JSON conversions, we can validate the implementation. JSON files will be located in:
target/tests/can_deserialize_and_reserialize_v3/{yaml_to_json,yaml_to_spec_to_json}/
Note that the official examples for https://github.com/OAI/OpenAPI-Specification/tree/29ea26df7dfd8def1605521f5f32c692a642de79/examples/v3.0 are added to the data/v3.0
directory.
Those two tests exposes issues not only with the new v3.0 implementation
but also with the previous v2 one.
Missing from v2:
- k8s.json:
additionalProperties
x-*
operationId
- Probably others? File is 1.6 MB
- petstore-simple.json:
allOf
termsOfService
operationId
- petstore_minimal.json:
- rocks.json:
termsOfService
operationId
default
- uber.json:
Missing from v3.0:
- api-with-examples.json:
- callback-example.json:
- link-example.json:
- petstore-expanded.json:
allOf
termsOfService
style
- petstore.json:
- uspto.json:
example
default
- server variables
Note that CI will fail because of those tests. Let me know if you want me to disable the assertion to let the CI pass.
Note that the first commit in this PR (acf8463) is part of PR #19 and ed759ee is PR #20. As such it should either be merged after those two others or be the only one merged.