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

delete might have a body. #421

Merged
merged 2 commits into from
Mar 21, 2024
Merged

Conversation

fantasy-is-absent
Copy link
Contributor

@fantasy-is-absent fantasy-is-absent commented Dec 29, 2022

Route DELETE and exegesis

exegesis thinks that DELETE might have a body. And If it finds “content-type” it tries to validate the incoming body

## exegesis/lib/utils/httpUtils.js

// `delete` might have a body. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE
const HTTP_METHODS_WITHOUT_BODY = ['get', 'head', 'trace', 'options'];
function requestMayHaveBody(method) {
    return HTTP_METHODS_WITHOUT_BODY.indexOf(method.toLowerCase()) === -1;
}

But on the other hand, exegesis make body-validators only for methods like this(there is no DELETE method)

## exegesis/lib/oas3/Operation.js

const METHODS_WITH_BODY = ['post', 'put', 'patch'];    
const requestBody = oaOperation.requestBody && METHODS_WITH_BODY.includes(method)
            ? context.resolveRef(oaOperation.requestBody)
            : undefined;

Conclusion: If someone sends any “content-type” with the method “DELETE” it always be an error even if you have a schema for this “content-type”

@jwalton jwalton merged commit 8588209 into exegesis-js:master Mar 21, 2024
Copy link

🎉 This PR is included in version 4.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

2 participants