OpenAPITools / OpenAPITools/openapi-generator
[BUG][Java][Spring] OpenApi contract with objects having no properties and a parent get wrong generated equals()
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the provided SomeObject and ParentObject OpenAPI declarations and inspect the generated Java model equals() methods. Confirm that an allOf model with no own properties compares its parent correctly by calling the parent equality behavior; done means the generated output handles this case without the reported failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100