-
Notifications
You must be signed in to change notification settings - Fork 9k
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 embed a link into each operation in Swagger UI #4806
Comments
hi @Cloudmersive - is there any reason you can't add a Markdown link to each operation's description? or are you looking for an automated solution that generates similar links for each operation? |
@shockey Thanks for the quick response. Yes, we are looking for an automated solution. Also, we wanted to actually make it a bit more elaborate over time where the link ultimately became an iFrame or embedded UX element that allows users to look through generated code examples in various SDK languages. We currently offer this in our static docs (example: https://api.cloudmersive.com/docs/image.asp ) via an iframe and would similarly like to be able to embed an iframe into each of the operations. Is there an easy way to do this via the swagger-ui extension APIs? We were struggling to find a good way to do this so any help is greatly appreciated. |
Any suggestions @shockey ? |
@Cloudmersive sure, this isn't too hard! Plugin codeconst CloudmersiveCodeExamplesAfterResponsesPlugin = () => ({
wrapComponents: {
responses: (Responses, { React }) => (props) => {
return React.createElement("div", null,
React.createElement(Responses, props),
React.createElement("iframe", {
src: "https://docs.cloudmersive.com", // `props.path` and `props.method` are available here so you can identify the operation
width: "100%",
height: "300px"
})
);
}
}
}) ResultThe only gotcha here is that this won't render if an operation has no responses defined (which would make it invalid). |
Awesome answer, thanks @shockey ! Much appreciated. You can see the deployed result here: https://api.cloudmersive.com/swagger/index.html?urls.primaryName=Image%20Recognition%20and%20Processing%20API |
Glad I could help, @Cloudmersive! Looks great 😄 |
Q&A (please complete the following information)
Content & configuration
You can see it here: https://api.cloudmersive.com/swagger/index.html?urls.primaryName=Image%20Recognition%20and%20Processing%20API
Swagger/OpenAPI definition (JSON):
https://api.cloudmersive.com/swagger/api/image
Swagger-UI configuration options:
Screenshots
You can see it running here: https://api.cloudmersive.com/swagger/index.html?urls.primaryName=Image%20Recognition%20and%20Processing%20API
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!
The text was updated successfully, but these errors were encountered: