Open donkey-donkey opened 10 months ago
Hey, I just went ahead and implemented my own version using the original source code, which was easy enough.
Here are some of the rough ideas:
fn create_endpoint(spec : &str) -> impl Endpoint {
let ui_html = String::from(swagger_ui::HTML_INDEX).replace("{spec}", spec);
poem::Route::new()
.at("/" , make_sync(move |_| Html(ui_html.clone())))
.at("/oauth2.html", make_sync(move |_| Html(swagger_ui::HTML_OAUTH2)))
}
...
let api_service = OpenApiService::new(...);
let api_ep = api_service
.with(poem::middleware::Cors::new())
...
;
let ui_ep = create_endpoint(&api_service.spec());
let route = Route::new()
.nest("/", api_ep)
.nest("/ui", ui_ep)
;
the HTML_...
consts are just the desired custom html build into the binary with str_include!(...)
.
cool. good one. im looking into that. thanks
Originally posted by @SaculRennorb in https://github.com/poem-web/poem/issues/660#issuecomment-1734736904