You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Handle in proper way empty object/array in has* like functions #201
After discussion in this PR #192 (comment #192 (comment)) we should consider in which way we should go with handling empty object/array in has* like functions. At this moment, parser-js returns true if given field has object/array with values, and also true if object/array is empty - in those functions is used !! statement to convert value to boolean. Unfortunately JS treats empty object/array as true value. In opposite, empty object/array should treat as false value.
Description
If we decide to change default behavior, then changing logic will be huge breaking change to handle schema in templates.
Also we should discuss point of view from this comment: #173 (comment)
I still have the point of view that has* implies something has been defined i.e. it has values or has been defined with values in which empty arrays/objects does not 😄
I like has* functions (didn't think if they can have better name) as they imply clearly what function is for. We should have those functions all around and use them only to determine if given part of spec is present or not. This way, in the future, it will be easy to change the logic inside those, depending how we understand that something is there or isn't. Function like properties should be only to extract properties, but I'd like to easily check if they are there with hasProperties.
For me, if object or array are empty, has* function should return false
This issue has been automatically marked as stale because it has not had recent activity 😴
It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
Thank you for your contributions ❤️
At this moment, parser-js returns true if given field has object/array with values, and also true if object/array is empty - in those functions is used !! statement to convert value to boolean. Unfortunately JS treats empty object/array as true value. In opposite, empty object/array should treat as false value
for that :) Probably when we will release 3.0.0 version of AsyncAPI ParserJS will have breaking changes and we can think about handling such a problem.
Activity
jonaslagoni commentedon Nov 19, 2020
I still have the point of view that
has*implies something has been defined i.e. it has values or has been defined with values in which empty arrays/objects does not 😄derberg commentedon Nov 19, 2020
I like
has*functions (didn't think if they can have better name) as they imply clearly what function is for. We should have those functions all around and use them only to determine if given part of spec is present or not. This way, in the future, it will be easy to change the logic inside those, depending how we understand that somethingis thereorisn't. Function likepropertiesshould be only to extract properties, but I'd like to easily check if they are there withhasProperties.For me, if object or array are empty,
has*function should returnfalsegithub-actions commentedon Jan 19, 2021
This issue has been automatically marked as stale because it has not had recent activity 😴
It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
Thank you for your contributions ❤️
derberg commentedon Oct 5, 2021
I'm wondering what is the point of keeping it open 😄
magicmatatjahu commentedon Oct 5, 2021
@derberg
for that :) Probably when we will release
3.0.0version of AsyncAPI ParserJS will have breaking changes and we can think about handling such a problem.smoya commentedon Mar 7, 2022
I think you might be interested in joining #453
smoya commentedon Jul 11, 2022
This is already being handled in the future
v2.0.0release, which follows the Intent-Driven API.We could close this ticket once the
v2.0.0version of the parser is fixed.magicmatatjahu commentedon Oct 25, 2022
Issue is resolved in v2 ParserJS - now in https://github.com/asyncapi/parser-js/tree/next-major branch