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

Normalize request body ContentTypes #863

Merged

Conversation

rayvincent2
Copy link
Contributor

Fixes #862

First I tackled ensuring that any ContentType type could be normalized so we could perform easy comparisons between what an HTTP request may send vs what the openapi document is expecting. By normalizing as well, I was able to easily ensure that cache keys for validators don't have any conflicts.

Tests have been added to showcase the working solution.

@rayvincent2
Copy link
Contributor Author

Has anybody had a chance to review this?

}
types.push(new ContentType(this.mediaType));

if (!this.parameters['charset']) {
Copy link
Owner

Choose a reason for hiding this comment

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

Looks like this will add utf-8 as an equivalent content type 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Glad you noticed. I saw that you were accounting for utf-8 and wanted to make sure I maintained that.

return types;
}

public normalize(excludeParams: string[] = ['boundary']) {
Copy link
Owner

Choose a reason for hiding this comment

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

Nit: add the method’s return type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@cdimascio
Copy link
Owner

Has anybody had a chance to review this?

Getting to this now. Looks good. Thank you! One minor review nit

@rayvincent2
Copy link
Contributor Author

Has anybody had a chance to review this?

Getting to this now. Looks good. Thank you! One minor review nit

Thanks for the review! I went ahead and made the update, rebased, and squashed. It's ready for another look.

@cdimascio cdimascio merged commit 0099b0d into cdimascio:master Dec 2, 2023
5 checks passed
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.

Request Body content-types don't consider custom parameters
2 participants