widdershins
widdershins copied to clipboard
Injecting API Key in built document
I had opened an issue in the Shins project along these lines, but felt it might be better(?) considered here. https://github.com/Mermade/shins/issues/53
To state the scenario from that issue: Once a user is logged into our site, I'd like to be able to inject a user's API key dynamically into the API calls within the documentation. I'm using Widdershins to generate the base docs from OpenAPISpec, and wondering if I would need to add a div/id into the generated Markdown, and then have some custom JS in Shins to accomplish this.
I started experimenting with this approach, but I realized that because many of the places I'd like to inject the user's API Key value are code fenced, I don't see a way that JS within the shins site would have easy access to that element I was considering adding.
Didn't know if any JS wizards in this project might have a suggestion...
I wonder if changes in both widdershins
and shins
might be needed to achieve this?
- In
widdershins
to tag theapi-keys
with<span class="apikey"></span>
or similar prior to the syntax-highlighting being applied. - In
shins
some Javascript to replace those values with the injectedapi-key
What do you think?