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!: adds inheritance with interfaces for java #1593

Merged
merged 16 commits into from
Nov 20, 2023

Conversation

kennethaasan
Copy link
Collaborator

@kennethaasan kennethaasan commented Nov 2, 2023

Description

This MR adds inheritance with interfaces for Java. Our Java users are complaining about missing interfaces for schemas that include allOf. Unlike TypeScript, In Java, it's problematic to use classes without interfaces if lots of classes are similar. This is an attempt to fix that. This is a difficult one to solve in a good way, and the arguments in #108 describe that, but we need to find a way to improve the generated code for Java.

Related issue(s)

See also #108 and #1613

Copy link

netlify bot commented Nov 2, 2023

Deploy Preview for modelina canceled.

Name Link
🔨 Latest commit 243ee38
🔍 Latest deploy log https://app.netlify.com/sites/modelina/deploys/655b79ddfeae610008ac2b7c

@kennethaasan
Copy link
Collaborator Author

@dlkj, perhaps you have some input here as a Java user who also might need this? Keep in mind that this is still a draft, but something we're prioritizing at the moment.

@kennethaasan kennethaasan changed the base branch from next to master November 2, 2023 13:58
@kennethaasan
Copy link
Collaborator Author

@jonaslagoni, I'm also eager to hear your input on how this can be solved. Am I on the right track, or should this be solved in a different way?

Copy link
Member

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

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

Honestly looks pretty good to me 🤔

Looking forward to seeing this in C# and TypeScript.

My only concern would be how it handles multiple inheritance whenallOf has multiple entries, in languages that only allow a single one? 🤔

@dlkj
Copy link
Contributor

dlkj commented Nov 6, 2023

Yep, representing allOf with interfaces is something I've been asked about by our modelina users. Looks sensible. Thanks for looking at this 👍🏼

@kennethaasan
Copy link
Collaborator Author

Thanks for your feedback! I'm still working through issues we've found by generating code with these changes in our own codebase. Once I'm happy with the output I'll split this draft into multiple smaller PRs.

@jonaslagoni, I think that should be the responsibility of the generator of the language. E.g. in Java, it's natural to use interfaces because it supports multiple, while extend only supports one. I think lots of other programming languages are in a similar situation as Java.

@kennethaasan kennethaasan changed the base branch from master to next November 15, 2023 16:24
Copy link

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 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@kennethaasan kennethaasan marked this pull request as ready for review November 20, 2023 15:24
@kennethaasan
Copy link
Collaborator Author

@jonaslagoni, please review

Copy link
Member

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

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

👍

@jonaslagoni
Copy link
Member

/rtm

@asyncapi-bot asyncapi-bot merged commit 379c35d into asyncapi:next Nov 20, 2023
31 checks passed
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 3.0.0-next.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@kennethaasan kennethaasan deleted the java-allof-interface-2 branch November 20, 2023 19:05
jonaslagoni added a commit that referenced this pull request Feb 1, 2024
* feat!: convert to use multi parser (#1587)
* feat!: adds support for duration in java (#1604)
* feat: enable AsyncAPI v3 (#1600)
* fix!: add csharp support for DateTime, TimeSpan, Guid (#1612)
* feat!: adds extend in common, meta, and constrained models (#1613)
* feat!: adds inheritance with interfaces for java (#1593)
* chore: remove duplicate version entry for AsyncAPI processor (#1609)
* feat!: render python union in pydantic in the pre 3.10 way (#1626)
* feat: add file path as input (#1601)
* feat!: add options as parameter to constraints (#1667)
* fix: (un)marshalling tuple and dictionary unwrapping for Typescript (#1717)
* fix: jsonbinpack preset and runtime tests (#1718)
* chore: fix linting
* chore: remove unused directory
* feat!: add useJavascriptReservedKeywords option for TS (#1727)
* feat: enable raw properties for interface (#1729)
* fix: newtonsoft could not handle enum values (#1731)
* chore: update Java runtime tests (#1739)
* fix: edge case where references was incorrect handled for JSON Schema (#1754)
* fix: recursion bug for get nearest dependencies (#1757)

---------

Co-authored-by: Kenneth Aasan <k.aasan@sportradar.com>
Co-authored-by: jano-petras <jano.petras@gmail.com>
Co-authored-by: Nilkanth Parmar <parmarnilkanth@gmail.com>
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 4.0.0-next.1 🎉

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants