GREsau / okapi

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

unresolved imports `rocket_okapi::rapidoc`, `rocket_okapi::swagger_ui` could not find `swagger_ui` in `rocket_okapi`rustc #96

Closed jiangxiaoqiang closed 2 years ago

jiangxiaoqiang commented 2 years ago

I am import the dependencies like this:

rocket = { version = "=0.5.0-rc.2", features = ["json"] }
okapi = { git = "https://github.com/GREsau/okapi.git"}
schemars = "0.7"
rocket_okapi = { git = "https://github.com/GREsau/okapi.git" }

when I added this imports:

use rocket_okapi::{openapi, openapi_get_routes, rapidoc::*, swagger_ui::*};

show error:

unresolved imports `rocket_okapi::rapidoc`, `rocket_okapi::swagger_ui`
could not find `rapidoc` in `rocket_okapi`rustc

what should I do to fix it?

ralpha commented 2 years ago

Both Swagger and Rapidocs are available under feature flags. https://github.com/GREsau/okapi#feature-flags

So try something like this:

rocket_okapi = { git = "https://github.com/GREsau/okapi.git", features = ["swagger", "rapidoc"] }

That should fix it.