Closed paambaati closed 6 months ago
I've recently started migrating https://github.com/paambaati/neon-js-sdk from openapi-typescript-codegen to @hey-api/openapi-ts, and I've run into an error in the generated output.
openapi-typescript-codegen
@hey-api/openapi-ts
Consider the following snippet of code (where NeonClient is the main class from the generated output) –
NeonClient
const neonClient = new NeonClient({ TOKEN: '<INSERT NEON API KEY HERE>', }); const projects = await neonClient.project.listProjects(); console.log(projects);
The type for the listProjects() function should be CancelablePromise<(ProjectsResponse & PaginationResponse) | GeneralError> – see https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgOQKYQHYGEA2xUbwC+cAZlBCHAOQboYC0AzgCYDW1A3AFDcDGmJvDqZc+QnAC8cOgHcU9MQRgAKBNzia4AFQDyAaQCiyAFw0APAElkAZUMAlbSkO7kcAIIAFS3CMBNOAAJB0MAPmoAGm4iAEoebhUAQyYATww+OBUYqVDEDS0BDCE4MAoAK1Q+GCYpOETZROBhRTxlADpSiAqqtrwhT3LK6qyeLThCpggcVF6IAHMVTu7quOiYrKA
listProjects()
CancelablePromise<(ProjectsResponse & PaginationResponse) | GeneralError>
However, in the generated output using this package, the type for listProjects() becomes CancelablePromise<GeneralError>.
CancelablePromise<GeneralError>
The bug here is that the first union type is lost.
https://dfv3qgd2ykmrx.cloudfront.net/api_spec/release/v2.json
openapi-ts --name NeonClient --client fetch --input https://dfv3qgd2ykmrx.cloudfront.net/api_spec/release/v2.json --output ./generated
OS: Darwin MacBook-Pro.local 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:25 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6030 arm64 Package version: 0.42.1 Node.js version: 21.7.3
Thanks for reporting @paambaati!
@paambaati this will be fixed in the next release, please let me know if that works for you once you try it!
Description
I've recently started migrating https://github.com/paambaati/neon-js-sdk from
openapi-typescript-codegen
to@hey-api/openapi-ts
, and I've run into an error in the generated output.Consider the following snippet of code (where
NeonClient
is the main class from the generated output) –The type for the
listProjects()
function should beCancelablePromise<(ProjectsResponse & PaginationResponse) | GeneralError>
– see https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgOQKYQHYGEA2xUbwC+cAZlBCHAOQboYC0AzgCYDW1A3AFDcDGmJvDqZc+QnAC8cOgHcU9MQRgAKBNzia4AFQDyAaQCiyAFw0APAElkAZUMAlbSkO7kcAIIAFS3CMBNOAAJB0MAPmoAGm4iAEoebhUAQyYATww+OBUYqVDEDS0BDCE4MAoAK1Q+GCYpOETZROBhRTxlADpSiAqqtrwhT3LK6qyeLThCpggcVF6IAHMVTu7quOiYrKAHowever, in the generated output using this package, the type for
listProjects()
becomesCancelablePromise<GeneralError>
.The bug here is that the first union type is lost.
OpenAPI specification (optional)
https://dfv3qgd2ykmrx.cloudfront.net/api_spec/release/v2.json
Configuration
System information (optional)
OS: Darwin MacBook-Pro.local 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:25 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6030 arm64 Package version: 0.42.1 Node.js version: 21.7.3