swagger-api / swagger-api/swagger-ui
How can I disable parameter and request body validation in swagger-ui?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A
- OS: Windows 11
- Browser: Chrome
- Version: 126.0.6478.183
- Method of installation: Plain old HTML/CSS/JS (Standalone)
- Swagger-UI version: 5.17.14
- Swagger/OpenAPI version: OpenAPI v2.0
Content & configuration
Swagger-UI configuration options:
SwaggerUIBundle({
url: window.location.href.substring(0, window.location.href.lastIndexOf('swagger/') + 'swagger/'.length - 1) + "/v2/swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout",
tryItOutEnabled: true
});
Screenshots
How can we help?
I would really like a way to disable parameter and request body validation in swagger-ui. We are using swagger purely as documentation, and as a way to demo our rest api. We have our own validation engine implemented in our backend, which we are unable to test because swagger-ui parameter validation will not send a request where a parameter is f.ex. less than what is specificed via a "minimum" constraint, see part of the schema definition below:
"VedvarendeEnergiOplysningerDTO": {
"properties": {
"maksAntalVindmoeller": {
"type": "integer",
"format": "int32",
"description": "Gemmes kun hvis specifik anvendelse Vindmølleanlæg (8111) er angivet.",
"minimum": 0,
"maximum": 9999999
}
},
"type": "object"
}
We can not test that this minimum constraint works in our backend, because swagger-ui refuses to send the request in the first place. But it refuses to send the request without any feedback to the user. So now I'm wondering, is there a way to disable this validation?
I checked the source code, and in execute.jsx the onClick callback for the Execute button calls handleValidateParameters() and handleValidateRequestBody(), that I would like it to skip.
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 in execute.jsx, where the Execute button calls handleValidateParameters() and handleValidateRequestBody(); trace how those callbacks prevent requests from being sent. The work is complete when Swagger UI provides a way to bypass parameter and request-body validation so requests violating constraints can still be sent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100