-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Regressions with the new OpenAPI generator #863
Comments
…ted code Hoist inline enums to ensure a model is created for them and they can therefore be typed correctly. Fixes #863
Hey @rubenfonseca! Thanks for raising this! Apologies for the regression! Looks like we need to hoist any inline enums such that we generate a type for them! I'll raise a PR to address this shortly - but it won't be reviewed until Monday :/ To unblock yourself for now you could try defining each enum as its own named schema and referencing them, eg for your example you'd change these: TemporaryUploadResponse:
allOf:
- $ref: "#/components/schemas/AssetBaseResponse"
- type: object
properties:
category:
type: string
enum:
- temporary-upload
required:
- category
ArchiverAssetResponse:
allOf:
- $ref: "#/components/schemas/AssetBaseResponse"
- type: object
properties:
category:
type: string
enum:
- archiver
required:
- category
additionalProperties: false to something like TemporaryUploadResponse:
allOf:
- $ref: "#/components/schemas/AssetBaseResponse"
- type: object
properties:
category:
$ref: "#/components/schemas/TemporaryUploadCategory"
required:
- category
ArchiverAssetResponse:
allOf:
- $ref: "#/components/schemas/AssetBaseResponse"
- type: object
properties:
category:
$ref: "#/components/schemas/ArchiverCategory"
required:
- category
additionalProperties: false
ArchiverCategory:
type: string
enum:
- archiver
TemporaryUploadCategory:
type: string
enum:
- temporary-upload Hope this helps! |
Thank you for the fast response! I've tried your workaround, but I'm still stuck on a different part:
The relevant generated code looks like this: const marshal = (statusCode: number, responseBody: any): string => {
let marshalledBody = responseBody;
switch(statusCode) {
case 200:
marshalledBody = JSON.stringify(Array<AssetResponse>ToJSON(marshalledBody));
break; |
Ooh so I think this is from returning an array at the top level- did this work before the new codegen? It should work fine if you return an object with an array property as a workaround :) I’ve got to sign off unfortunately but I’ll look at this first thing on Monday! |
@cogwirrel that's correct, for this case I was already overriding the const marshal = (statusCode: number, responseBody: any): string => {
let marshalledBody = responseBody;
switch(statusCode) {
{{#responses}}
case {{code}}:
{{^isPrimitiveType}}
{{#isArray}}
marshalledBody = JSON.stringify(marshalledBody.map({{baseType}}ToJSON));
{{/isArray}}
{{^isArray}}
marshalledBody = JSON.stringify({{dataType}}ToJSON(marshalledBody));
{{/isArray}}
{{/isPrimitiveType}}
break;
{{/responses}}
default:
break;
}
return marshalledBody;
}; So I guess this is a separate bug / not a regression! |
Ah yep cool - would definitely be good to fix this in the new codegen too! 😄 |
Raised #866 to track the array response issue :) |
Describe the bug
When upgrading to the newer versions of PDK that use the new custom generator, my OpenAPI based TypeSafeApi project stopped compiling.
Expected Behavior
I expect to be able to upgrade the PDK and continue using it without changing my OpenAPI spec.
Current Behavior
Compiling the project ends with these errors:
Reproduction Steps
Current
.projenrc.ts
:Current minimal OpenAPI spec:
Possible Solution
No response
Additional Information/Context
No response
PDK version used
0.23.69
What languages are you seeing this issue on?
Typescript
Environment details (OS name and version, etc.)
macOS 15.0.1
The text was updated successfully, but these errors were encountered: