feat: wsdl option ignoreAttributesUndefined#904
Open
jamienich wants to merge 2 commits intoloopbackio:masterfrom
Open
feat: wsdl option ignoreAttributesUndefined#904jamienich wants to merge 2 commits intoloopbackio:masterfrom
jamienich wants to merge 2 commits intoloopbackio:masterfrom
Conversation
Signed-off-by: jamienich <jamie.nicholson@gmail.com>
Signed-off-by: jamienich <jamie.nicholson@gmail.com>
Pull Request Test Coverage Report for Build 11771217283Details
💛 - Coveralls |
achrinza
requested changes
Nov 14, 2024
Member
achrinza
left a comment
There was a problem hiding this comment.
Hi @jamienich, thanks so much for your contribution.
I've given this PR some thought and have some minor change requests if that's ok 👇
| @@ -0,0 +1,99 @@ | |||
| // Copyright IBM Corp. 2017. All Rights Reserved. | |||
Member
There was a problem hiding this comment.
Suggested change
| // Copyright IBM Corp. 2017. All Rights Reserved. | |
| // Copyright LoopBack contributors 2024 |
Comment on lines
+167
to
+168
| if (val === null ||(val === undefined && this.options.ignoreAttributesUndefined == true)) { | ||
| if (descriptor.isNillable ) { |
Member
There was a problem hiding this comment.
Though about this for a while; The naming is a little unintuitive.
My suggestion is jsonUndefinedAsXmlNil:
- It informs the flow of the conversion (JSON->XML)
- It clearly states what it does (Coerce JSON
undefinedas XMLxsi:nil)
The only thing missing is stating that the XML element must be defined as nillable, but that can be covered by documentation.
Suggested change
| if (val === null ||(val === undefined && this.options.ignoreAttributesUndefined == true)) { | |
| if (descriptor.isNillable ) { | |
| if (val === null ||(val === undefined && this.options.jsonUndefinedAsXmlNil == true)) { | |
| if (descriptor.isNillable) { |
Comment on lines
+1
to
+7
| 2024-11-11, Version 4.1.6 | ||
| ========================= | ||
|
|
||
| Placeholder for package maintainer | ||
|
|
||
| * feat: Override default strong-soap behaviour when mapping undefined element values to self closing tags (<tag/> instead of <tag xsi:nil=true></tag>. Option is ignoreAttributesUndefined, to enable option set to false. (Jamie Nicholson) | ||
|
|
Member
There was a problem hiding this comment.
No need to manually update this file.
It is auto-generated by strong-tools as part of our publishing workflow.
Comment on lines
+533
to
+536
| ### Mapping of undefined element values | ||
|
|
||
| When the wsdl attribute nillable="true" it set, JSON values will map to null and XML values map to nillable='true' unless ignoreAttributesUndefined is set to false. When ignoreAttributesUndefined is set to false undefined element values will map to a self closing tag i.e. <tag/> | ||
|
|
Member
There was a problem hiding this comment.
Can we reword this?
Suggested change
| ### Mapping of undefined element values | |
| When the wsdl attribute nillable="true" it set, JSON values will map to null and XML values map to nillable='true' unless ignoreAttributesUndefined is set to false. When ignoreAttributesUndefined is set to false undefined element values will map to a self closing tag i.e. <tag/> | |
| ### Mapping of JSON `undefined` values | |
| For XML elements that are marked as `nillable` in their descriptor, JSON `undefined` is mapped to `<tag xsi:nil="true" />` by default. | |
| Setting `jsonUndefinedAsXmlNil: false` will cause JSON `undefined` to be mapped to a `<tag/>`. |
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.
Description
Added feature, new wsdl option ignoreAttributesUndefined, when set to false undefined attribute values will be mapped to xml self closing tags i.e. with no values. Only nulls will set XML attribute value to xsi:nil="true" when nillable="true" is defined in the wsdl.
Related issues
None.
Checklist
guide