swagger-js icon indicating copy to clipboard operation
swagger-js copied to clipboard

Mandatory custom header fails validation

Open mdcfrancis opened this issue 6 years ago • 1 comments

Q&A (please complete the following information)

  • OS: WIn10
  • Environment: Node.js v10.8.0
  • Method of installation: npm
  • Swagger-Client version: 3.8.23
  • Swagger/OpenAPI version: Swagger 2.0

Content & configuration

Swagger-Client usage:

const Swagger  = require('swagger-client');
const jsYaml = require('@kyleshockey/js-yaml')

const spec = `
swagger: "2.0"
info:
  title: Sample API
  description: API description in Markdown.
  version: 1.0.0
host: api.example.com
schemes:
- https
paths:
  /ping:
    get:
      summary: Checks if the server is alive
      parameters:
      - in: header
        name: X-Request-ID
        schema:
          type: string
          format: uuid
        required: true
`;

const json = jsYaml.safeLoad(spec);

Swagger({ spec: json } ).then(client => {
    client.apis.default.get_ping({}, { headers: { "X-Request-ID" : "012345678-CODE-F00D-0A1E-CAFE00C0FFEE" } })})
        .then(result => {
            console.log( result )
        })
        .catch(err => {
            console.log(err);
        })
        .catch(err => {
            console.log("Got error: " + err);
        });

Describe the bug you're encountering

When the script is run. The following error will get thrown

Error: Required parameter X-Request-ID is not provided 

This is provided in the header, I've tried with request interceptors as well. If I replicate the 'header' in the parameters the validation passes but is sending the data in an incorrect part of the spec.

To reproduce...

Run the attached js snippet

Expected behavior

Request is processed

mdcfrancis avatar Feb 15 '19 13:02 mdcfrancis

hey there, any update on this?

bduisenov avatar Jan 17 '22 16:01 bduisenov