header parameters incorrectly added as operation input parameters
See original GitHub issueIf a parameter is expected to be passed in the request header and not the body, it should not be added as an input variable.
Here is an example of a broken schema:
swagger: "2.0"
info:
version: "1.0.0"
title: Test API
host: localhost:1339
basePath: /
schemes:
- http
- https
consumes:
- application/json
produces:
- application/json
x-servers:
- url: //api.test.com
description: Default server
paths:
/v1/files:
post:
parameters:
- $ref: "#/parameters/headerparam"
summary: Create a file
operationId: postFile
description: Creates a new file
responses:
"201":
description: Success
schema:
$ref: "#/definitions/File"
parameters:
headerparam:
name: headerparam
type: string
in: header
required: true
pattern: "[a-zA-Z0-9-_]+"
minLength: 1
maxLength: 128
definitions:
Type:
enum:
- TEST_ENUM
type: string
File:
type: object
properties:
cadType:
$ref: "#/definitions/Type"
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Web Api How to add a Header parameter for all API in Swagger
Parameters = new List<OpenApiParameter>(); operation.Parameters. ... Another way to add custom headers is by adding parameters into controller action.
Read more >[Minimal API] Incorrect OpenAPI definition of path, query and ...
[Minimal API] Incorrect OpenAPI definition of path, query and header parameters when there is a body and we're using WithOpenApi extension ...
Read more >Adding Input Parameters - Headers and Queries
Adding Input Parameters - Headers and Queries. Define all input parameters for your API operation, irrespective of whether they are mandatory or optional....
Read more >Access multi-value HTTP headers incorrectly in an API Proxy ...
Accessing the values of HTTP headers in Apigee policies in a way that returns only the first value is incorrect and can cause...
Read more >HTTP/1.1: Header Field Definitions
The media-range MAY include media type parameters that are applicable to ... in incorrect operation, such as a silently unexecuted financial transaction.
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 Free
Top 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
@mikestaub Yes, I believe this is expected. The header is hardcoded when you set it using the
headers
option.If you would like to dynamically change the headers at runtime, then I would recommend you to take a look at issue #234 and PR #270.
Let me know your thoughts.
Thanks for being so responsive to my issues, I really appreciate it. This library is providing a lot of value, when I get some extra cycles I will gladly contribute.