juhaku / utoipa

Simple, Fast, Code first and Compile time generated OpenAPI documentation for Rust
Apache License 2.0
2.48k stars 194 forks source link

Is there way to serve swagger ui from swagger file? #599

Open Kavan72 opened 1 year ago

Kavan72 commented 1 year ago

I'm looking to just serve swagger ui from swagger.yaml, is there way i can do this ? for java we are using springdoc-openapi on this we have option to enable this.

juhaku commented 1 year ago

Yes there is if you are using rocket, axum or actix_web otherwise it is manual procedure. You can use this to expose external openapi spec. https://docs.rs/utoipa-swagger-ui/latest/utoipa_swagger_ui/struct.SwaggerUi.html#method.external_url_unchecked

Note that there is no currently way to serve openapi spec directly from file.