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

Models: Create definitions for everything in AaiComponents #100

Open
EricWittmann opened this issue Dec 20, 2019 · 2 comments
Open

Models: Create definitions for everything in AaiComponents #100

EricWittmann opened this issue Dec 20, 2019 · 2 comments

Comments

@EricWittmann
Copy link
Member

No description provided.

@lbroudoux
Copy link
Contributor

Maybe this one has been addressed through #187 ?

@EricWittmann
Copy link
Member Author

No the issue here is that we're re-using the same models for definitions and non-definitions (in-line usage). So these for example:

https://github.com/Apicurio/apicurio-data-models/blob/master/src/main/java/io/apicurio/datamodels/asyncapi/models/AaiComponents.java#L44-L47

This results in fewer models but more difficult visitation and analysis. Because when you visit e.g. an AaiMessage you don't know if it's inline or a definition found in the /components. The result is code like this:

https://github.com/Apicurio/apicurio-data-models/blob/master/src/main/java/io/apicurio/datamodels/asyncapi/io/AaiDataModelWriter.java#L309-L331

Where we try to figure out from the parent what kind of thing we're writing out. If instead we had a AaiMessageDefinition subclass with its own visitMessageDefinition, we would just know. It makes some other things slightly more difficult (e.g. if you have a visitor that needs to analyze Messages and MessageDefinitions then you need to implement the visit method for both of those). But it's how we do things in the OpenAPI model, so if nothing else we should be consistent.

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

No branches or pull requests

2 participants