Wrong Schema Model property type generation - for schema properties of Array of oneOf type
Describe the bug There is a type generation error when generating ab array of oneOf types.
To Reproduce
E.g. when generating the type for an object of this shape:
"CheckoutOperationList": {
"description": "List of checkout operations.",
"properties": {
"operations": {
"description": "List of checkout operations.",
"items": {
"oneOf": [
{
"$ref": "#/components/schemas/SetCostCenter"
},
{
"$ref": "#/components/schemas/SetDeliveryOption"
},
{
"$ref": "#/components/schemas/SetGuestEmail"
},
{
"$ref": "#/components/schemas/SetPaymentType"
},
{
"$ref": "#/components/schemas/SetPurchaseOrderNumber"
},
{
"$ref": "#/components/schemas/SetShippingAddress"
},
{
"$ref": "#/components/schemas/addShippingAddress"
}
]
},
"type": "array"
}
},
"required": [
"operations"
],
"type": "object",
"additionalProperties": false
}
the generated output is the following:
/*
* Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved.
*
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import type { SetCostCenter } from './set-cost-center';
import type { SetDeliveryOption } from './set-delivery-option';
import type { SetGuestEmail } from './set-guest-email';
import type { SetPaymentType } from './set-payment-type';
import type { SetPurchaseOrderNumber } from './set-purchase-order-number';
import type { SetShippingAddress } from './set-shipping-address';
import type { AddShippingAddress } from './add-shipping-address';
/**
* List of checkout operations.
*/
export type CheckoutOperationList = {
/**
* List of checkout operations.
*/
operations:
| SetCostCenter
| SetDeliveryOption
| SetGuestEmail
| SetPaymentType
| SetPurchaseOrderNumber
| SetShippingAddress
| AddShippingAddress[];
};
Expected behavior
In the generated schema example from above we see that only last union type (AddShippingAddress[]) is marked as array. The expected behaviour is that entire union is marked as array! Example:
...
operations:
(SetCostCenter
| SetDeliveryOption
| SetGuestEmail
| SetPaymentType
| SetPurchaseOrderNumber
| SetShippingAddress
| AddShippingAddress)[];
...
` ``
**Used Versions:**
- node version via `node -v` -> v20.12.2
- npm version via `npm -v` -> 10.5.0
- SAP Cloud SDK version you used as dependency -> 3.15.0
**Impact / Priority**
This is blocking our team from generating correct schema SDK. Affects our Release & Production Phase.
Timeline: e.g. Go-Live is in few weeks.
Hi @uroslates ,
We fixed this issue in the latest release. Can you try generating after updating the version?
Hi @deekshas8,
Thank you for the quick reply. I can confirm that this issue does not exist in the latest release and the generation output is the array of the union type as expected.