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

feat: generate example function for TypeScript models #568

Closed
wants to merge 2 commits into from

Conversation

chinma-yyy
Copy link
Contributor

Description

  • Added a flag tsExampleInstance which if true adds an example of the model generated .
  • Added a snapshot test for the same.

Related issue(s)
Resolves #462

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@chinma-yyy chinma-yyy changed the title Generate example function for TypeScript models feat: Generate example function for TypeScript models May 22, 2023
@chinma-yyy chinma-yyy changed the title feat: Generate example function for TypeScript models feat: generate example function for TypeScript models May 22, 2023
@chinma-yyy
Copy link
Contributor Author

There is a problem in the code formatting and I don't know how to resolve it. Please if anyone can help me with it.

@sonarcloud
Copy link

sonarcloud bot commented May 22, 2023

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

Comment on lines +159 to +164
presets.push({
preset: TS_COMMON_PRESET,
options: {
marshalling: true
}
},
Copy link
Member

Choose a reason for hiding this comment

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

Do you see that the same preset are added twice now, just with slightly different options? 🙂

This should not be the case, it can only be added once, and then the options should change slightly based on the parameters 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not getting added twice even if there are both flags in the command of tsExampleInstance and tsJsonBinPack. I think Modelina has the support for this where the same preset is added with multiple values of options then it gets combined to give the output. Just the order of the functions generated is getting changed somewhat rest is the same for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another approach would be to create an object variable

const options={
    example : tsExampleInstace ,
    marshalling : tsMarshalling
}

presets.push({
    preset: TS_COMMON_PRESET,
    options:options
})

and then use this while pushing the presets which can also resolve #460

Copy link
Member

Choose a reason for hiding this comment

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

Ahh you right, it's allowed as long as the options don't overlap or default behavior adds some stuff. Because otherwise it will be added twice 😄

@chinma-yyy chinma-yyy closed this May 24, 2023
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

Successfully merging this pull request may close these issues.

Generate example function for TypeScript models
2 participants