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

Field are optional by default but should be required #17

Closed
fmvilas opened this issue Oct 20, 2020 · 9 comments
Closed

Field are optional by default but should be required #17

fmvilas opened this issue Oct 20, 2020 · 9 comments
Labels
bug Something isn't working

Comments

@fmvilas
Copy link
Member

fmvilas commented Oct 20, 2020

Describe the bug

When using Avro, the fields are always required unless a default value is given. Currently, fields are not being tagged as required when converted to JSON Schema.

Expected behavior

Unless a default value is given, a field should be required.

@fmvilas fmvilas added the bug Something isn't working label Oct 20, 2020
@M3lkior
Copy link
Collaborator

M3lkior commented Oct 26, 2020

Hi @fmvilas , the default attribut for simple type (not only enum) in avro schema is handle ?

I have a similar issue concernant the nullable fields :

I think that not nullable field must be set as required by default, contrary to ["null", "string"] type for example.

So required field declaration :

{"name": "SHORT_PRODUCT_DESCRIPTION", "type": "string", "doc": "A short description of the product"},

Optional field declaration :

        
{"name": "SHORT_PRODUCT_DESCRIPTION", "type": ["null", "string"], "doc": "A short description of the product."},

@github-actions
Copy link

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 ❤️

@github-actions github-actions bot added the stale label Dec 26, 2020
@derberg derberg removed the stale label Jan 4, 2021
@github-actions
Copy link

github-actions bot commented Mar 6, 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 ❤️

@github-actions github-actions bot added the stale label Mar 6, 2021
@derberg derberg removed the stale label Mar 8, 2021
@github-actions
Copy link

github-actions bot commented May 8, 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 ❤️

@github-actions github-actions bot added the stale label May 8, 2021
@derberg derberg removed the stale label May 9, 2021
@github-actions
Copy link

github-actions bot commented Jul 9, 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 ❤️

@github-actions github-actions bot added the stale label Jul 9, 2021
@derberg derberg removed the stale label Aug 23, 2021
@M3lkior
Copy link
Collaborator

M3lkior commented Oct 4, 2021

i support required fields in #82 . We just need to validate the required rules (default value or not null union)

M3lkior added a commit to M3lkior/avro-schema-parser that referenced this issue Oct 4, 2021
- supports of required fields: required fields are field without default value or without a union containing the 'null' element
- brings supports for additional attributes in avro file. See the README.MD for the list of supported attributes
- also add the format precision for the double and float type by setting the format attribute in the json definition

Closes asyncapi#17,asyncapi#18
@M3lkior
Copy link
Collaborator

M3lkior commented Oct 4, 2021

i work on them as hacktoberfest issue

M3lkior added a commit to M3lkior/avro-schema-parser that referenced this issue Oct 14, 2021
- supports of required fields: required fields are field without default value or without a union containing the 'null' element
- brings supports for additional attributes in avro file. See the README.MD for the list of supported attributes
- also add the format precision for the double and float type by setting the format attribute in the json definition

Closes asyncapi#17,asyncapi#18
M3lkior added a commit to M3lkior/avro-schema-parser that referenced this issue Oct 18, 2021
- supports of required fields: required fields are field without default value or without a union containing the 'null' element
- brings supports for additional attributes in avro file. See the README.MD for the list of supported attributes
- also add the format precision for the double and float type by setting the format attribute in the json definition

Closes asyncapi#17,asyncapi#18
@M3lkior
Copy link
Collaborator

M3lkior commented Oct 27, 2021

@M3lkior M3lkior closed this as completed Oct 27, 2021
@Rustamw888
Copy link

Hi @fmvilas , the default attribut for simple type (not only enum) in avro schema is handle ?

I have a similar issue concernant the nullable fields :

I think that not nullable field must be set as required by default, contrary to ["null", "string"] type for example.

So required field declaration :

{"name": "SHORT_PRODUCT_DESCRIPTION", "type": "string", "doc": "A short description of the product"},

Optional field declaration :

        
{"name": "SHORT_PRODUCT_DESCRIPTION", "type": ["null", "string"], "doc": "A short description of the product."},

Hi, I use { "name": "SHORT_PRODUCT_DESCRIPTION", "type": "string", "doc": "A short description of the product"}, to make the field mandatory. but when I pass null, the test ignores it and passes. if the data type is long, then null is no longer passed as expected, since the field I want to make mandatory. so how do I do this for data type string?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants