widdershins icon indicating copy to clipboard operation
widdershins copied to clipboard

Injecting API Key in built document

Open aroach opened this issue 5 years ago • 1 comments

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...

aroach avatar Dec 13 '18 21:12 aroach

I wonder if changes in both widdershins and shins might be needed to achieve this?

  • In widdershins to tag the api-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 injected api-key

What do you think?

MikeRalphson avatar Dec 30 '18 08:12 MikeRalphson