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

Handle additionals attributes in asvc schema declaration #18

Closed
M3lkior opened this issue Oct 26, 2020 · 18 comments · Fixed by #82
Closed

Handle additionals attributes in asvc schema declaration #18

M3lkior opened this issue Oct 26, 2020 · 18 comments · Fixed by #82
Labels

Comments

@M3lkior
Copy link
Collaborator

M3lkior commented Oct 26, 2020

Reason/Context

Please try answering few of those questions

  • Why we need this improvement?

The Avro specification is limited by a restricted attributes list in field declaration.
For example, the avro spec not handle example, min or max attributes but it is possible to set those attributes in avro specification without breaking the declaration.

I think that the avro-parser should be consider the additional attributes matching with the async api specification like example, min and max for number, etc

  • How will this change help?

By considering those fields, the generated files (HTML for example) should handle those infomations and display them in the generated template (like example values on attributes by example. Today, all values are set to null when using asvc files)

  • What is the motivation?

I use avro specification and html-template to generated AsyncApi documentations in my organization and it could be useful to display those informations.

Description

Please try answering few of those questions

  • What changes have to be introduced?

Handle additional attributes, drived by the AsyncAPI specification

  • Will this be a breaking change?

Nop

  • How could it be implemented/designed?

Check if the avro specification contains the following attributes, and include them in the JSON schema if true :

  • maximum
  • exclusiveMaximum
  • minimum
  • exclusiveMinimum
  • maxLength
  • minLength
  • pattern (This string SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect)
  • maxItems
  • minItems
  • examples
@M3lkior M3lkior added the enhancement New feature or request label Oct 26, 2020
@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 enhancement New feature or request stale labels 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
Copy link
Member

derberg commented Mar 8, 2021

@M3lkior is this one still valid?

@derberg derberg removed the stale label Mar 8, 2021
@M3lkior
Copy link
Collaborator Author

M3lkior commented Mar 8, 2021

Yes.

@derberg
Copy link
Member

derberg commented Mar 8, 2021

@M3lkior something you think you can pick up 😉

@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
@dalelane
Copy link
Collaborator

it is possible to set those attributes in avro specification without breaking the declaration

@M3lkior Can you expand on this a bit, please?

I'm curious exactly what you mean. Are you saying that the Avro specification explicitly tolerates additional attributes that aren't defined in the spec? Or that some specific tooling based on Avro tolerates unexpected attributes? Or something else?

@ITman1
Copy link
Contributor

ITman1 commented May 11, 2021

@dalelane I think that @M3lkior meant that directly Avro tolerates them and actually not just only tolerates them, but also provides official support at least via Java Reflect API which allows you to define them, here is an example from our project:
image

If you accidentially specify in there some reserved key it will fail when building schema. For all reserved keywords there are dedicated annotations.

@M3lkior
Copy link
Collaborator Author

M3lkior commented May 12, 2021

it is possible to set those attributes in avro specification without breaking the declaration

@M3lkior Can you expand on this a bit, please?

I'm curious exactly what you mean. Are you saying that the Avro specification explicitly tolerates additional attributes that aren't defined in the spec? Or that some specific tooling based on Avro tolerates unexpected attributes? Or something else?

Yes this is exactly what i want to explain. The idea behind this capability is to permit displaying additional fields in the generated docs ; like the example or min / max fields.

Given this kind of specification (which not break the AVRO maven plugin for example)

{
    "namespace": "com.adeo.ccr.costing.exchange.avro.model.costingrequest",
    "type": "record",
    "name": "CostingRequestPayload",
    "version": 1,
    "fields": [
        {"name": "Length", "type": ["int"], "example": "10", "min": "0", "max": "1"}
]}

Would allow the parser to display the example ; min and max attributes in the generated doc which is not the case today :
image

@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 Jul 12, 2021
@derberg derberg removed the stale label Jul 26, 2021
@derberg
Copy link
Member

derberg commented Jul 26, 2021

I tried to find some answers in Avro spec documentation but failed. I could not find any information about how they approach additional attributed, could not find a JSON Schema for the spec too. Do you know how to contact Avro folks? do they use Slack or something?

@ITman1
Copy link
Contributor

ITman1 commented Jul 26, 2021

@derberg Is not that mentioned at the beginning of Avro spec?

A JSON object, of the form: {"type": "typeName" ...attributes...} where typeName is either a primitive or derived type name, as defined below. Attributes not defined in this document are permitted as metadata, but must not affect the format of serialized data.

No contacts to Avro folks so far, but maybe @iemejia could confirm, he is quite regular recent committer. 😄

@derberg
Copy link
Member

derberg commented Jul 26, 2021

@ITman1 it does sound like that but I'm not native speaker and would prefer to see JSON Schema with additionalProperties set to true 😅 although I'm not a machine 😄

@derberg
Copy link
Member

derberg commented Jul 26, 2021

Ok, I finally found one here https://json.schemastore.org/avro-avsc.json
I hope it is an official one 😅

I do not see "additionalProperties": false there which means to me they are allowed. Lemme go back to the PR

@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 Sep 25, 2021
@M3lkior
Copy link
Collaborator Author

M3lkior commented Sep 26, 2021

Ok, I finally found one here https://json.schemastore.org/avro-avsc.json
I hope it is an official one 😅

I do not see "additionalProperties": false there which means to me they are allowed. Lemme go back to the PR

@derberg i start working on this feature this week for information

M3lkior added a commit to M3lkior/avro-schema-parser that referenced this issue 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

Close asyncapi#18
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 Author

M3lkior commented Oct 4, 2021

i work on them as hacktoberfest issue :)

@github-actions github-actions bot removed the stale label Oct 5, 2021
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
@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved 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 a pull request may close this issue.

5 participants