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

Support OpenAPI specification with consumes property undefined #2

Merged
merged 4 commits into from
Oct 19, 2018

Conversation

jpettit
Copy link

@jpettit jpettit commented Oct 17, 2018

I found that when the content type is not defined - I'm hitting the following:

This resolved the issue for me.

OS: darwin
node.js: v10.11.0
test-openapi: 38.1.1

TypeError: Cannot read property 'filter' of undefined
    at removeFormDataMimes (/Users/jpettit/dev/github/test-openapi/src/core/spec/start/normalize/form_data.js:32:24)
    at filterFormDataMimes (/Users/jpettit/dev/github/test-openapi/src/core/spec/start/normalize/form_data.js:11:10)
    at getContentTypeParam (/Users/jpettit/dev/github/test-openapi/src/core/spec/start/normalize/content_negotiation.js:21:21)
    at getNegotiationsParams (/Users/jpettit/dev/github/test-openapi/src/core/spec/start/normalize/content_negotiation.js:7:23)
    at getParams (/Users/jpettit/dev/github/test-openapi/src/core/spec/start/normalize/params/main.js:24:31)
    at getOperation (/Users/jpettit/dev/github/test-openapi/src/core/spec/start/normalize/main.js:34:18)
    at Object.entries.map (/Users/jpettit/dev/github/test-openapi/src/core/spec/start/normalize/main.js:27:5)
    at Array.map (<anonymous>)
    at getOperationsByPath (/Users/jpettit/dev/github/test-openapi/src/core/spec/start/normalize/main.js:26:35)
    at Object.entries.map (/Users/jpettit/dev/github/test-openapi/src/core/spec/start/normalize/main.js:16:5)

@jpettit
Copy link
Author

jpettit commented Oct 17, 2018

@ehmicky - could you take a look?

if(consumes === undefined) {
return
}

const consumesA = filterFormDataMimes({ mimes: consumes, params })

if (consumesA === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those three lines can removed since consumesA will now never be undefined.

@@ -3899,7 +3899,7 @@
},
"camelcase-keys": {
"version": "2.1.0",
"resolved": "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package-lock.json update is not related to this PR.

@ehmicky ehmicky changed the title Support null content type Support OpenAPI specification with consumes property undefined Oct 18, 2018
@ehmicky
Copy link
Contributor

ehmicky commented Oct 18, 2018

Thanks a lot for this PR. This is a bug indeed, and your PR solves it. See my few comments.

@jpettit
Copy link
Author

jpettit commented Oct 19, 2018

@ehmicky - should be ready, let me know if you'd like me to rebase my commits into a single commit

@ehmicky ehmicky merged commit 3e51de8 into emanualjade:master Oct 19, 2018
@ehmicky
Copy link
Contributor

ehmicky commented Oct 19, 2018

Thanks again!

@jpettit jpettit deleted the jpettit/null_content_type branch April 25, 2019 20:45
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 this pull request may close these issues.

2 participants