OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Java client] oneOf is refering a non existing class in Swagger annotation
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
If I use this component definitions
CrossBorderCreditTransferResponse:
description: Get payment response
allOf:
- $ref: './xs2a-common.yaml#/components/schemas/BaseResponse'
- $ref: '#/components/schemas/SinglePayment'
HungarianCreditTransferResponse:
description: Get payment response
allOf:
- $ref: './xs2a-common.yaml#/components/schemas/BaseResponse'
- $ref: '#/components/schemas/HungarianCreditTransfer'
PeriodicHungarianCreditTransferResponse:
description: Get periodic payment response
allOf:
- $ref: './xs2a-common.yaml#/components/schemas/BaseResponse'
- $ref: '#/components/schemas/PeriodicHungarianCreditTransfer'
and generate an API for
/{payment-service}/{payment-product}/{payment-id}:
get:
responses:
'200':
description: OK, request received
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/HungarianCreditTransferResponse'
- $ref: '#/components/schemas/CrossBorderCreditTransferResponse'
- $ref: '#/components/schemas/PeriodicHungarianCreditTransferResponse'
with Maven plugin (version 4.0.0-SNAPSHOT) I get an invalid Java code generated:
import hu.cib.psd2.model.xs2a.OneOfHungarianCreditTransferResponseCrossBorderCreditTransferResponsePeriodicHungarianCreditTransferResponse;
@GET
@Path("/{payment-service}/{payment-product}/{payment-id}")
@Produces({ "application/json" })
@ApiOperation(value = "", tags={ "payment-initiation-service", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK, request received", response = OneOfHungarianCreditTransferResponseCrossBorderCreditTransferResponsePeriodicHungarianCreditTransferResponse.class) })
public Response getPayment();
The generator doesn't recognize the common parent BaseResponse, instead it refers to a non existing
OneOfHungarianCreditTransferResponseCrossBorderCreditTransferResponsePeriodicHungarianCreditTransferResponse class.
Actually I don't event need this Swagger anotation to run my code, but this way it doesn't compile.
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 Java client generation with the Maven plugin using the supplied allOf and oneOf schema definitions. Inspect the generated ApiResponse annotation and model reference; done means the generated Java code compiles without referring to the nonexistent OneOfHungarianCreditTransferResponseCrossBorderCreditTransferResponsePeriodicHungarianCreditTransferResponse class.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100