How to embed a link into each operation in Swagger UI
See original GitHub issueQ&A (please complete the following information)
- OS: Windows 10 / Mac OS Latest
- Browser: Chrome Latest
- Version: Latest
- Method of installation: Dist Assets
- Swagger-UI version: Latest
- Swagger/OpenAPI version: Swagger 2.0
Content & configuration
You can see it here: https://api.cloudmersive.com/swagger/index.html?urls.primaryName=Image Recognition and Processing API
Swagger/OpenAPI definition (JSON): https://api.cloudmersive.com/swagger/api/image
Swagger-UI configuration options:
SwaggerUI({
// your config options here
})
var configObject = JSON.parse('{"urls":[{"url":"/swagger/api/convert","name":"Convert API"},{"url":"/swagger/api/nlp","name":"Natural Language Processing (NLP) API"},{"url":"/swagger/api/ocr","name":"Optical Character Recognition (OCR) API"},{"url":"/swagger/api/validate","name":"Validate API"},{"url":"/swagger/api/virus","name":"Virus Scan API"},{"url":"/swagger/api/image","name":"Image Recognition and Processing API"},{"url":"/swagger/api/barcode","name":"Barcode API"},{"url":"/swagger/api/speech","name":"Speech API"}],"validatorUrl":null}');
--
| var oauthConfigObject = JSON.parse('{}');
|
| // Apply mandatory parameters
| configObject.dom_id = "#swagger-ui";
| configObject.presets = [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset];
| configObject.layout = "StandaloneLayout";
|
| // If oauth2RedirectUrl isn't specified, use the built-in default
| if (!configObject.hasOwnProperty("oauth2RedirectUrl"))
| configObject.oauth2RedirectUrl = window.location.href.replace("index.html", "oauth2-redirect.html");
|
| configObject.onComplete = function () {
| // Here, "basicAuth" and "apiKey" are the security scheme names/keys in the "securityDefinitions" collection
| ui.preauthorizeApiKey("Apikey", "28e63794-ef8a-4616-80bb-26fdd3709a19");
|
|
| };
|
| // Build a system
| const ui = SwaggerUIBundle(configObject);
Screenshots
You can see it running here: https://api.cloudmersive.com/swagger/index.html?urls.primaryName=Image Recognition and Processing API
How can we help?
We want to add a hyperlink to each Operation that links contextually to help documentation with more information, so ideally it is a parameterized link that includes the ID or name of the operation.
Hopefully this is simple to do - what is the best way to do it? We tried with the documented JS APIs but were not able to get this to work.
Any help with this is greatly appreciated!
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Links
Links are one of the new features of OpenAPI 3.0. Using links, you can describe how various values returned by one operation can...
Read more >How to add <a href> link to make an element clickable in ...
Assuming you mean clickable in Swagger UI – you can add links in the operation description ( notes attribute) using the Markdown syntax....
Read more >Integrating Swagger UI with the rest of your docs
It's pretty easy to embed Swagger into an HTML page — just copy the code from the index.html file from the dist folder...
Read more >Using OpenAPI and Swagger UI
This guide explains how your Quarkus application can expose its API description through an OpenAPI specification and how you can test it via...
Read more >ASP.NET Core web API documentation with Swagger ...
Each public action method in your controllers can be tested from the UI. Select a method name to expand the section. Add any...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Cloudmersive sure, this isn’t too hard!
Plugin code
Result
The only gotcha here is that this won’t render if an operation has no responses defined (which would make it invalid).
Glad I could help, @Cloudmersive! Looks great 😄