question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] No more inheritance for components generated by version 5.0.0

See original GitHub issue
Description

No schema inheritance.

openapi-generator version

5.0.0

OpenAPI declaration file content or url
schemas:
  UserDTO:
      type: object
      properties:
        id:
          type: string
          minLength: 1
          maxLength: 20

  QueryUserResponseDTO:
      type: object
      allOf:
        - $ref: '#/components/schemas/UserDTO'
Generation Details

The above YAML produces:

public class QueryUserResponseDTO   {
   private @Valid String id;
}

Instead as for the 4.3.1:

public class QueryUserResponseDTO extends UserDTO   {
}
Suggest a fix

Does exist a configuration parameter to enforce the DTO inheritance generation? Or it is a bug?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:15
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

15reactions
rgoerscommented, Jun 26, 2021

The problem is that the base class can’t always know all the classes that will extend it. In my case, #9756 it isn’t even necessary as the base class isn’t used for Serialization/Deserialization. But I need the base class for methods that operate on the fields it provides. In my environment we have a “BasePage” object for paged requests. All the services that need paging extend that. BasePage can’t possibly know all the services that will support paging as it is in a common library that the services import. This change has made it impossible to support this.

3reactions
Msurrowcommented, Jan 22, 2021

Just to confirm. I updated from 4.3.1 -> 5.0.0 and I’m seeing the same issue (with dotnet-core generator) and AllOf inheritance. For us, this makes vers 5.0.0 unusable.

If any help, here is a git diff of 4.3.1 generated class and 5.0.0 generated class which shows the issue:

  • superclass gone form class signature
  • base construtor not called
  • superclass properties added to subclass
namespace FOOBAR.Model
 {
@@ -29,7 +29,7 @@ namespace FOOBAR.Model
     /// ProductBankLoan
     /// </summary>
     [DataContract(Name = "ProductBankLoan")]
-    public partial class ProductBankLoan : Product, IEquatable<ProductBankLoan>
+    public partial class ProductBankLoan : IEquatable<ProductBankLoan>, IValidatableObject
     {
         /// <summary>
         /// Initializes a new instance of the <see cref="ProductBankLoan" /> class.
@@ -38,9 +38,12 @@ namespace FOOBAR.Model
         /// <param name="productID">productID.</param>
         /// <param name="debtors">debtors.</param>
         /// <param name="collaterals">collaterals.</param>
-        public ProductBankLoan(double balance = default(double), int productID = default(int), List<Debtor> debtors = default(List<Debtor>), List<Collateral> collaterals = default(List<Collateral>)) : base(productID, debtors, collaterals)
+        public ProductBankLoan(double balance = default(double), int productID = default(int), List<Debtor> debtors = default(List<Debtor>), List<Collateral> collaterals = default(List<Collateral>))
         {
             this.Balance = balance;
+            this.ProductID = productID;
+            this.Debtors = debtors;
+            this.Collaterals = collaterals;
         }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Changelog - ViewComponent
A framework for building reusable, testable & encapsulated view components in Ruby on Rails.
Read more >
Explanation - Rocket Software Documentation
Uniface 10: Changes in Subtype Property Inheritance ... Example: Generating object-dependent menu options ... Missing Characters in Unicode.
Read more >
NEWS
R6 documentation no longer shows inherited methods if there aren't any (#1371), and only links to superclass docs if they're actually available (#1236)....
Read more >
Inheritance In Components Makes Build Error In Angular
area you available in teamviewer? seems to be a strange issue · The question lacks CLI version, while it's most relevant here. ·...
Read more >
Unreal Engine 5.0 Release Notes
Artists and designers are no longer tied to static scenes with precomputed lighting ... Newly created projects in Unreal Engine 5 will use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found