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

refactor: adjust mixins to the IntentAPI #499

Merged
merged 3 commits into from
Mar 21, 2022

Conversation

magicmatatjahu
Copy link
Member

Description

  • adjust existed mixins to the IntentAPI.
  • update existed models with missed fields and add implementation for them alongside with unit tests.

NOTE: Models related to the mixins like Tags etc are located in this same file as mixin, due to problems with circular references between modules. There is no other way to do it, unless we write mixins for every model separately.

Related issue(s)
Part of #481
Part of #482

@sonarcloud
Copy link

sonarcloud bot commented Mar 21, 2022

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
No Duplication information No Duplication information

Copy link
Member

@smoya smoya left a comment

Choose a reason for hiding this comment

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

Nice rework @magicmatatjahu 👏 💯 Just dropped a comment so we take a decision, but we can merge and act after anyway 👍

@@ -0,0 +1,20 @@
import type { BaseModel } from "./base";

export abstract class Collection<T extends BaseModel> extends Array<T> {
Copy link
Member

Choose a reason for hiding this comment

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

Noice! 👍

return doc && new License(doc);
}
// TODO: Implement it
id(): string | undefined {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if i like the fact we moved the id from the document to the info object In https://github.com/asyncapi/parser-api/blob/master/docs/v1.md#info.

Making an abstraction exercise, would it make sense to instead leave it in the root document (as it is nowadays)? cc @magicmatatjahu @jonaslagoni

Copy link
Member Author

@magicmatatjahu magicmatatjahu Mar 21, 2022

Choose a reason for hiding this comment

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

The id specifies the unique id of a given AsyncAPI document, so for me the id is more of a document metadata for the user than a semantic value. Similarly with tags and external docs. They serve only as information for the user and I prefer this place than the root of the document - maybe we should move (in the 3.x.x) tags, id and externalDocs from root to the info?

Copy link
Member

@smoya smoya Mar 21, 2022

Choose a reason for hiding this comment

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

Interesting. So you are suggesting just going all through info object opposed to what I suggested. Also to maybe suggest such a change into the spec itself for v3 (not related to the work we are doing here, but interesting anyway).

I'm kinda sold, However, I would love to know what @jonaslagoni –who was also involved in the Intent-Driven API design process– thinks about.

Copy link
Member

@jonaslagoni jonaslagoni Mar 21, 2022

Choose a reason for hiding this comment

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

Think we talked about it as well, can't remember the reasons behind going with A or B. Think it had something to do with extensions, as we still needed a way to access those under asyncapi.info however, there can be other workarounds.

Fine by me, you will quickly realize if it makes sense or not once the API is in use 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

but id etc. have nothing to do with extensions 😅 I guess i don't understand something.

Copy link
Member

@jonaslagoni jonaslagoni Mar 21, 2022

Choose a reason for hiding this comment

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

but id etc. have nothing to do with extensions 😅 I guess i don't understand something.

No, but the info grouping has. If you start to mix and which properties should be fetched under asyncapi.info.prop and others asyncapi.prop it serves as a bad experience, as you have a hard time guessing where you can access the information as a user. It won't be intuitive.

Therefore, I think we went with keeping everything under asyncapi.info.

But yea, I dont mind changing it, cause I like that approach as well, so 🤷

Copy link
Member Author

@magicmatatjahu magicmatatjahu Mar 21, 2022

Choose a reason for hiding this comment

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

but that's why we have the intent api (yeah? 😅 ), so that people don't have to know where the externalDocs are, whether in info or not. They only need to know that in version 2.x.x it was on the root, and in 3.x.x (maybe) in info, so from tolling perspective we won't have any braking changes.

Ok. I will merge that PR and we can continue discussion in this thread. Of course we can change API for id :)

Copy link
Member

Choose a reason for hiding this comment

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

I'm up for moving everything into Info object as suggested by @magicmatatjahu. I'm thinking Info object could be pass around other functions in user's libraries for printing all the basic info of the application.

Copy link
Member Author

Choose a reason for hiding this comment

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

@smoya We can create proposal with that for 3.0.0 :)

Copy link
Member

Choose a reason for hiding this comment

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

Sure! feel free to open a new RFC with that. We will find champions for it!

@magicmatatjahu
Copy link
Member Author

/rtm

@asyncapi-bot asyncapi-bot merged commit 96dd8cf into asyncapi:next-major Mar 21, 2022
@magicmatatjahu magicmatatjahu deleted the next/fix-mixins-2 branch March 21, 2022 12:26
magicmatatjahu added a commit to magicmatatjahu/parser-js that referenced this pull request Oct 3, 2022
derberg pushed a commit that referenced this pull request Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready-to-merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants