Required Header Param Resets State without Executing
See original GitHub issueQ&A (please complete the following information)
- OS: macOS High Sierra
- Browser: Google Chrome
- Version: Version 68.0.3440.106 (Official Build) (64-bit)
- Method of installation: npm
- Swagger-UI version: 3.18.2
- Swagger/OpenAPI version: OpenAPI 3.0.0
Content & configuration
Example Swagger/OpenAPI definition:
openapi: "3.0.0"
info:
version: 1.0.0
title: Required Header State Reset Example
description: Required header resets state when executing with try it out button.
termsOfService: http://swagger.io/terms/
contact:
name: Swagger API Team
email: apiteam@swagger.io
url: http://swagger.io
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
- url: '....'
security:
- ApiKeyAuth: []
paths:
/tags:
get:
description: Returns all tags.
operationId: getTags
parameters:
- name: workspace
in: header
description: workspace identifier
required: true
schema:
type: string
- name: startIndex
in: query
description: offset to start from
required: false
schema:
type: integer
format: int32
- name: stopIndex
in: query
description: maximum number of results to return
required: false
schema:
type: integer
format: int32
responses:
'200':
description: tags response
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Tag'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
securitySchemes:
ApiKeyAuth:
type: apiKey
in: header
name: Authorization
schemas:
Tag:
allOf:
- $ref: '#/components/schemas/TagModel'
- required:
- id
properties:
id:
type: integer
format: int32
TagModel:
required:
- name
properties:
name:
type: string
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
Swagger-UI configuration options:
const ui = SwaggerUI({
url: `${axios.defaults.baseURL}/endpoints`,
domNode: this.swaggerUI.current,
// Using this: https://github.com/swagger-api/swagger-ui/blob/master/docs/customization/custom-layout.md
plugins: [ OperationsLayoutPlugin ],
layout: "OperationsLayout",
onComplete: () => {
ui.preauthorizeApiKey('ApiKeyAuth', sessionStorage.getItem('token'))
},
})
Describe the bug you’re encountering
When a required header is added to list of parameters the state is reset when Execute is clicked.
To reproduce…
Steps to reproduce the behavior:
- Go to endpoints with a required header.
- Click on Try It Out
- Provide values for the params.
- Click on Execute
- See the state reset and no request executed.
Expected behavior
The request is executed and includes use of the required header.
Screenshots
Additional context or thoughts
Setting the header param to required: false
executes the request, but doesn’t include the header.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
HTTP/1.1: Header Field Definitions
Indicates that the client is willing to accept a response whose freshness lifetime is no less than its current age plus the specified...
Read more >Intercept @RequestHeader exception for missing header
The response when you access your API without the required request header is: Missing request header 'Authorization' for method parameter of type String....
Read more >Strict-Transport-Security - HTTP - MDN Web Docs
Whenever the Strict-Transport-Security header is delivered to the browser, it will update the expiration time for that site, so sites can ...
Read more >HTTP headers and query string parameters for XML API
Without the Authorization header, you receive a MissingSecurityHeader error and your request is rejected. For more information about accessing Cloud Storage ...
Read more >Troubleshooting | React Navigation
If you're testing on iOS and use Mac, make sure you have run pod install in the ... local component state or the...
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
@calmdev, you’re correct - React 16 currently has some problems with Swagger UI.
Check back in a couple of months: we’re currently having some internal discussions about creating a specific flavor of the UI/Editor module for React users, which exposes a component that you can use regardless of your React version.
That’d be great. I’ll keep any eye out for it. For now, I’ve forked the repo to create a custom standalone build that’s loaded using an iframe.