Add XML conversion to bodies, and fix XML data conversion #214
Open
ySnoopyDogy wants to merge 4 commits intopb33f:mainfrom
Open
Add XML conversion to bodies, and fix XML data conversion #214ySnoopyDogy wants to merge 4 commits intopb33f:mainfrom
ySnoopyDogy wants to merge 4 commits intopb33f:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #214 +/- ##
==========================================
+ Coverage 97.61% 97.64% +0.03%
==========================================
Files 56 57 +1
Lines 5240 5444 +204
==========================================
+ Hits 5115 5316 +201
- Misses 125 128 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
Going to implement a smarter conversion, like the one used in Query Parameter validation, looking to the type defined in the schema. This idea can be used to convert the body to JSON with correct defined types, so we can validate application/xml, x-www-form-urlencoded and also multipart/form-data |
also added a validation for XML namespaces and prefix
a457bde to
09fe157
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The new XML validation functions just convert the data to JSON before validating the schema. With that, we can just convert the data on Request and Response validations just by looking at the content type.
Because in XML everything is a string, there can be problems to validating against a schema that includes other primitive types. Now, we convert the strings based on the schema types. If the property is a boolean, we convert to a boolean to pass the validation. If the value is not a valid boolean, we do nothing to let the schema validation to raise an error.
Also, now we are validating if the payload includes prefixes and namespaces defined in the schema (the XMLNS feature of XML).
Added a new option to
ValidationOptions:AllowXMLBodyValidationto enable XML validations in request/response bodies (the default isfalse). Created a functionWithXmlBodyValidationto enable the new validator option.No breaking changes with the new code, as the updated function was internal, and the XML body validation setting is
falseby default.