Regression: Version 3 does not merge path and operation properties
See original GitHub issueIn a specification where parameters are defined on both the path and the operation, the parameters from the path appear to be ignored. For example:
'use strict';
const assert = require('assert');
const http = require('http');
const SwaggerClient = require('swagger-client');
const TEST_HOST = 'localhost';
const TEST_ID = 123;
const TEST_PORT = 8888;
http
.createServer((req, res) => {
assert.strictEqual(req.url, `/cars/${TEST_ID}`);
res.writeHead(200, {'Content-Type': 'application/json'});
res.end('{}');
})
.listen(TEST_PORT, TEST_HOST, () => {
new SwaggerClient({
usePromise: true,
spec: {
swagger: '2.0',
info: {
title: 'Path Parameter API',
version: '1.0.0'
},
host: `${TEST_HOST}:${TEST_PORT}`,
schemes: [
'http'
],
paths: {
'/cars/{carId}': {
parameters: [
{
name: 'carId',
in: 'path',
type: 'number',
required: true
}
],
get: {
operationId: 'getCar',
parameters: [
{
name: 'clean',
in: 'query',
type: 'boolean'
}
],
responses: {
200: {
description: 'A car',
schema: {
type: 'object'
}
}
}
}
}
}
}
})
.then(client => client.apis.default.getCar({carId: TEST_ID}))
.then(
() => {
console.log('It works.');
process.exit();
},
err => {
console.error(err);
process.exit(1);
}
);
});
With swagger-js
version 3.0.1 this fails with AssertionError: '/cars/%7BcarId%7D' === '/cars/123'
while swagger-js
version 2.1.32 prints It works.
. I bisected the regression to 7678d40, but that’s obviously not very helpful since almost everything was replaced in that commit.
Thanks, Kevin
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Patch drops properties that are null or are an empty array ...
edited. I see this problem starting in v3. 8.0. When a resource defines a property with null, or an array as empty, the...
Read more >Multiple Regression - an overview | ScienceDirect Topics
The objective of multiple regression analysis is to use the independent variables whose values are known to predict the value of the single...
Read more >Lecture notes on ridge regression - arXiv
This document is a collection of many well-known results on ridge regression. The current status of the document is 'work-in-progress' as it is...
Read more >7 Github Actions Tricks I Wish I Knew Before I Started
Here are 7 tricks with github actions that changed my life (or at least my CI/CD pipeline). These tricks helped me create a...
Read more >Apply SPSS Linear Regression results to predict ... - IBM
If merging these data sets is not feasible, then Method 3 can be applied. Method 1: Scoring from an XML file of 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 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
Will do. So far this is the only issue I’ve noticed.
I actually started writing a test for this one but got bogged down when the test behaved differently than calling the API directly (looks like
parameters
is moved out of thepath
object somewhere outside of thebuildRequest
function used in the tests, but I could be wrong on that). I’ll try to send a test and/or fix with future issues.Thanks @saharj and @buunguyen! The fix is working well for me with v3.0.3.