question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

header parameters incorrectly added as operation input parameters

See original GitHub issue

If 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:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Alan-Chacommented, Dec 17, 2019

@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.

1reaction
mikestaubcommented, Dec 4, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found