OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Java client] oneOf is not handling inheritance properly
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
If I'm using this component defintions:
AccountReference:
type: object
properties:
currency:
type: string
AccountReferenceIban:
description: IBAN of an account
allOf:
- $ref: '#/components/schemas/AccountReference'
- type: object
properties:
iban:
type: string
required:
- iban
AccountReferenceBban:
description: Basic Bank Account Number (BBAN) Identifier
allOf:
- $ref: '#/components/schemas/AccountReference'
- type: object
properties:
bban:
type: string
required:
- bban
SinglePayment:
type: object
properties:
endToEndIdentification:
type: string
debtorAccount:
oneOf:
- $ref: "#/components/schemas/AccountReferenceIban"
- $ref: "#/components/schemas/AccountReferenceBban"
I have multiple problems with the generated code:
AccountReferenceIban and AccountReferenceBban doesn't extend AccountReference.
public class AccountReferenceBban {
@ApiModelProperty(value = "")
private String currency;
...
SinglePayment has a
private OneOfAccountReferenceIbanAccountReferenceBban debtorAccount = null;
that refers a non existing class.
Insted it should use the common parent AccountReference.
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 with the supplied OpenAPI schema and generate the Java client, then inspect the generated AccountReferenceIban, AccountReferenceBban, and SinglePayment classes. Compare their inheritance and debtorAccount type with the issue’s expected behavior; done means the child classes extend AccountReference and SinglePayment uses the common parent without a nonexistent OneOf class.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- backend-api-design, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100