-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Apply default
property to event fields
#659
Comments
@fmvilas what do yu think we should try to do ? the code should not fail if the event.payload.repeat is undefined.we are trying to solve this only right? |
@Min2who I think the problem here is a little more complicated.
|
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
I think this will increase DX a lot and still makes sense. |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
Reason/Context
If we apply the
default
property value to event fields, users will need less boilerplate in their functions (i.e., checking for the existence of a value).Description
For instance, I have the following definition (notice the
default
value on therepeat
field):Right now, the following code will fail if
event.payload.repeat
is undefined:I think it shouldn't fail since, in our schema definition, we're saying the default value should be 1.
EDIT: After fixing the code above so it doesn't fail, I noticed another thing:
If we don't provide support for this, the default value of 1 is defined in two places: in the schema definition (
default: 1
) and implicitly in the code (... || 1
). This makes things harder to maintain and keep right. For instance, if the default value changes in the code but not in the schema or vice versa, there will be an inconsistency.The text was updated successfully, but these errors were encountered: