openapi-generator
                                
                                 openapi-generator copied to clipboard
                                
                                    openapi-generator copied to clipboard
                            
                            
                            
                        [BUG][Java][Spring] OpenApi contract with objects having no properties and a parent get wrong generated equals()
Bug Report Checklist
- [x] Have you provided a full/minimal spec to reproduce the issue?
- [x] Have you validated the input using an OpenAPI validator (example)?
- [x] Have you tested with the latest master to confirm the issue still exists?
- [x] Have you searched for related issues/PRs?
- [ ] What's the actual output vs expected output?
- [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Whenever an OpenApi model specification has an allOf, but does not contain any properties of it's own, the openAPI generator fails calling super.equals().
openapi-generator version
7.0.0
OpenAPI declaration file content or url
SomeObject:
  allOf:
    - $ref: 'parent-object.yml#/ParentObject'
  type: object
  description: |
    some description
ParentObject:
  type: object
  discriminator:
    propertyName: some_type
  description: |
    some more description.
  required:
    - property_1
    - value
  properties:
    property_1:
      $ref: 'property-1.yml#/Property1'
    value:
      type: string
      description: Some other description
    some_type:
      type: string
Generation Details
Steps to reproduce
When running openApi generator for objects using allOf, but not having properties of it's own, call to super.equals is missing.
Related issues/PRs
Suggest a fix
Always call super.equals when using allOf.
Attached is a small example project. Employee inherit from Person. If Employee doesn't have any properties of it's own, super.equals() is never called from equals within Employee.
For anyone who wants to work on this:
This bug needs to be fixed here. If the child model doesn't have any variables of it's own (i.e. hasVars is false), a simple "return true;" is put in the generated output. A proper solution can be copied from the other Java generators, e.g. from here. If parent is true, we need to call super.equals. Only otherwise we should return true.
@martin-mfg : I've implemented the above mentioned fix.