Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The method getHeadersArray doesn't seem to check the path.parameters object it just skips to path path[method].parameters #85

Closed
michaelgwelch opened this issue May 5, 2022 · 2 comments · Fixed by #86

Comments

@michaelgwelch
Copy link
Contributor

michaelgwelch commented May 5, 2022

This can be seen here:

const getHeadersArray = function (openApi, path, method) {
const headers = [];
const pathObj = openApi.paths[path][method];
// 'accept' header:
if (typeof pathObj.consumes !== 'undefined') {
for (let i in pathObj.consumes) {
const type = pathObj.consumes[i];
headers.push({
name: 'accept',
value: type,
});
}
}
// headers defined in path object:
if (typeof pathObj.parameters !== 'undefined') {
for (let k in pathObj.parameters) {

Another issue is that the getFullPath method assumes that only one or the other will have entries.

const getFullPath = function (openApi, path, method) {
let fullPath = path;
const parameters =
openApi.paths[path].parameters || openApi.paths[path][method].parameters;

Finally getQueryStrings appears to do it correctly and checks both:

if (typeof openApi.paths[path].parameters !== 'undefined') {
pathQueryStrings = parseParametersToQuery(
openApi,
openApi.paths[path].parameters,
values
);
}
if (typeof openApi.paths[path][method].parameters !== 'undefined') {
methodQueryStrings = parseParametersToQuery(
openApi,
openApi.paths[path][method].parameters,
values
);
}

I don't think I'll fix this in #82 as that's too large already. This is just a defect I found while testing #82.

@michaelgwelch
Copy link
Contributor Author

michaelgwelch commented May 5, 2022

There's some duplication between getFullPath, getQueryStrings and getHeadersArray this can probably be solved by extracting all of the common logic into one method (Probably getQueryStrings) and then have getFullPath and getHeadersArray delegate to getQueryStrings and customize as needed. For example getFullPath needs to replace a parameter place holder with an actual value.

@michaelgwelch
Copy link
Contributor Author

Resolved in #86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant