GREsau / okapi

OpenAPI (AKA Swagger) document generation for Rust projects
MIT License
606 stars 110 forks source link

Write "offline" golden test for OpenApi spec #107

Closed SBechstedt closed 2 years ago

SBechstedt commented 2 years ago

Question:

Is there any way to write a golden test for the OpenApi spec without having to launch a rocket server before?

I can generate it with the openapi_get_spec! macro and would like to test its content against an earlier created openapi spec stored as Json file on my system. I retrieved the Json file through the Swagger Web UI which was served using this crate.

SBechstedt commented 2 years ago

I noticed the point "Tests" in the todo, but want to be sure I am not missing anything.

ralpha commented 2 years ago

Yes, using openapi_get_spec! is indeed the right macro for this. If you want you can also compare it to an other OpenApi object. Or serialize it using the serde_json or any other crate/type.

The "Tests" todo is an old todo. Although we do not have tests at the moment. We do have compile tests with the examples. Feel free if you want to create a PR that adds some tests.

SBechstedt commented 2 years ago

@snpschaaf