swagger-api / swagger-api/swagger-client
Mandatory custom header fails validation
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 765
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 6
Description
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
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 by running the attached JavaScript snippet with the stated Swagger 2.0 document and Node.js environment, then trace the required-parameter validation for the X-Request-ID header. Confirm whether the header supplied through the request options is recognized, and verify that the request is processed without reporting the required parameter as missing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100