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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support required and validator attributes in avro files #82

Merged
merged 8 commits into from
Oct 25, 2021

Conversation

M3lkior
Copy link
Collaborator

@M3lkior M3lkior commented Oct 1, 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
  • also add the format precision for the string type by handling the logicalType avro attribute

Close #18

Description

  • 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

I introduce a new asyncapi-avro-1.9.0-additional-attributes.yaml to illustrate the supported attributes and to easily generate the specification from the CLI to see the result in the html template 馃憤

image

Related issue(s)

@M3lkior M3lkior force-pushed the feat/18-support-extra-attributes branch 2 times, most recently from 08e9a8a to e78ebe9 Compare October 8, 2021 11:36
tests/schemas/Person-1.9.0-additional-attributes.avsc Outdated Show resolved Hide resolved
tests/schemas/Person-1.9.0-additional-attributes.avsc Outdated Show resolved Hide resolved
@@ -121,13 +182,18 @@ async function convertAvroToJsonSchema(avroDefinition, isTopLevel) {
case 'enum':
jsonSchema.enum = avroDefinition.symbols;
break;
case 'float':
case 'double':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this fall-through is intentional, but I think it should be marked/flagged as such - maybe a comment or something as a heads-up to the next person who makes changes here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

case 'int':
case 'long':
case 'float':
case 'double':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this fall-through is intentional, but I think it should be marked/flagged as such - maybe a comment or something as a heads-up to the next person who makes changes here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

setAdditionalAttribute('maximum');
setAdditionalAttribute('exclusiveMinimum');
setAdditionalAttribute('exclusiveMaximum');
setAdditionalAttribute('multipleOf');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subjective style idea - a setAdditionalAttributes helper function that takes an array of strings would help simplify this bit.

setAdditionalAttributes(['minimum', 'maximum', 'exclusiveMinimum', ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, done !

@M3lkior M3lkior force-pushed the feat/18-support-extra-attributes branch from cb1fc1d to 1a849a5 Compare October 14, 2021 08:53
M3lkior and others added 6 commits October 18, 2021 11:17
- 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
Co-authored-by: Dale Lane <dale.lane@gmail.com>
@M3lkior M3lkior force-pushed the feat/18-support-extra-attributes branch from 0de4e09 to 139c8bc Compare October 18, 2021 09:17
@M3lkior
Copy link
Collaborator Author

M3lkior commented Oct 20, 2021

@fmvilas / @derberg do you have some time to validate this amazing PR ? ^^

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super tiny stuff from my side

README.md Outdated Show resolved Hide resolved
M3lkior and others added 2 commits October 21, 2021 11:11
@sonarcloud
Copy link

sonarcloud bot commented Oct 21, 2021

Kudos, SonarCloud Quality Gate passed!聽 聽 Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@derberg
Copy link
Member

derberg commented Oct 21, 2021

@dalelane is it ok for you too? can you approve? you had some comments

Copy link
Collaborator

@dalelane dalelane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 馃憤

@asyncapi-bot
Copy link
Contributor

馃帀 This PR is included in version 0.6.0 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle additionals attributes in asvc schema declaration
4 participants