swagger-api / swagger-api/swagger-ui
How to hide “Try out” area from individual parameters in swagger API docs?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
I am working on documenting our APIs using OAS 2.0 and swaggerhub. After defining the APIs on the swaggerhub I generated JSON files and then using "swagger-ui" package, embedded these API docs on my website.
The API docs have "Authorize" and "Try Out" buttons which I don't want to show on my website. So, as suggested in many solutions I managed to hide these buttons using the following piece of code:
const DisableAuthorizePlugin = function() {
return {
wrapComponents: {
authorizeBtn: () => () => null
}
};
};
And,
SwaggerUi({
dom_id: '#' + id,
url: this.props.source,
spec: this.props.source,
supportedSubmitMethods : [],
presets: [
SwaggerUi.presets.apis,
DisableAuthorizePlugin
]
});
}
But, the above script only hides the "Authorize" and "Try Out" buttons from the top of API definition. The "Try out" area with each individual parameter is still showing up (as shown in the attached screenshot). How can I hide this try out area from individual parameters?
P.S: I am using swagger-ui version 3.18.1 and my website is built on react.js
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the SwaggerUi initialization and DisableAuthorizePlugin configuration shown in the issue, then trace how the individual parameter Try Out area is rendered in swagger-ui 3.18.1. Done means the per-parameter Try Out controls are hidden while the embedded API documentation remains usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- documentation, frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100
