utoipa icon indicating copy to clipboard operation
utoipa copied to clipboard

How to configure API introduction?

Open oliver-impero opened this issue 3 years ago • 3 comments

  1. How can I specify what it shows for "License" / how can I remove it?

image

  1. How can I add a custom API introduction text here (using markdown)? I tried with a doc comment (using #[doc = include_str!("API-Intro.md")]) for my main ApiDoc struct that has #[derive(OpenApi)], but the doc comment seems to be ignored by the generator, any idea why?

  2. How can I specify the html <title> for the generated doc? :)

oliver-impero avatar Jun 02 '22 08:06 oliver-impero

You can use custom modifier to this.

struct ApiDocInfo;
impl Modify for ApiDocInfo {
    fn modify(&self, openapi: &mut openapi::OpenApi) {
        openapi.info.description = Some(include_str!("../README.md").to_string());
    }
}

Also with this you can modify all the info related fields as you may wish. E.g. You could also remove the Licence as well.

juhaku avatar Jun 02 '22 16:06 juhaku

Thanks, that's very useful :) Btw, is it also possible to specify a favicon or to modify the CSS styling?

Or to add a search field, like in slate docs? E.g.: https://mermade.github.io/reslate https://bestbuyapis.github.io/api-documentation

oliver-impero avatar Jun 03 '22 09:06 oliver-impero

Btw, is it also possible to specify a favicon or to modify the CSS styling?

If I'm not mistaken it is not possible with the Swagger UI. But for this you should use another OpenAPI doc "browser". For example those OpenAPI's are using https://redocly.com/redoc/. I've had a plan to support this as well as an alternative to the Swagger UI but no concrete action has been taken towards this so far.

juhaku avatar Jun 03 '22 13:06 juhaku