Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add Rapidoc logo? #355

Open
outer-core opened this issue May 4, 2022 · 2 comments
Open

How to add Rapidoc logo? #355

outer-core opened this issue May 4, 2022 · 2 comments

Comments

@outer-core
Copy link

Is there a way, via API_SPEC_OPTIONS, OPENAPI_RAPIDOC_CONFIG, or some other app config constant, to set the logo for use in rapidoc? Specifically I'm looking for something like the Change Logo example from https://rapidocweb.com/examples.html.

From what I understand, it doesn't seem like there is without a change to flask_smorest/spec/tempaltes/rapidoc.html to add the <img> tag section as shown in the above example.

@lafrech
Copy link
Member

lafrech commented May 13, 2022

Yeah I'm afraid so.

I'm not sure where to stand, here. Having the API framework serve the doc with close to no effort is certainly practical. We always use it. But ultimately, the user is free to host the doc statically on another server. Some big stable APIs do that for deployment reasons.

I'm happy to allow the user to pass customization parameters through API options (what is currently possible) but I'd rather not engage into too much trouble for features that can't be easily tweaked, especially since the static doc hosting alternative above is viable.

I'm open to suggestion, though. In this specific case, we could add a dedicated app config variable and a conditional block in the template. I won't do it but I guess someone could contribute that. I'm just concerned it might open the door to all kinds of customization requests.

@outer-core
Copy link
Author

But ultimately, the user is free to host the doc statically on another server.

That is what I'm doing, but my aim is to pull down a given rapidoc version and deploy that to my server. As that'll provide flexibility to try new features as needed. But flask-smorest doesn't make available this logo feature.

Speaking of, I also would like a similar ability in Swagger docs, but one thing at a time since I haven't explored that as far yet.

... we could add a dedicated app config variable and a conditional block in the template.

I was exploring the concept of a child dict within OPENAPI_RAPIDOC_CONFIG, (iirc) something like:

OPENAPI_RAPIDOC_CONFIG = {
    "img": {
        "slot": "nav-logo",
        "src": "/path/to/logo.png",
    },
}

with the conditional block in the html template. If desired, that could later be extended to better formalize child dicts, but for now I was just looking to hardcode the img key in the html template.

I won't do it but I guess someone could contribute that.

I can create the PR for that, but first wanted to better understand if that was an acceptable change, especially given your concerns of the slippery slope this could introduce. Though biased, I would argue this just allows for more complete use of the rapidoc spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants