-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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] [typescript-fetch] (v4.0.0) Generated models no longer produce valid to/from JSON functions - can't compile #2739
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
I also wanted to mention the issue still exists with the latest snapshot: openapi-generator-cli-4.0.0-20190424.154647-577 |
Hi Wayne |
I have a PR that switches back to the |
Just ran a test with the newly released 4.0.0 = still broken but differently. Now 3 model files are generated: ModelFull.ts, ModelFullAllOf.ts and ModelPartial.ts ModelFull.ts is even more broken now than before (there are no properties included now!): /**
*
* @export
* @interface ModelFull
*/
export interface ModelFull {
/**
*
* @type {string}
* @memberof ModelFull
*/
id: string;
/**
*
* @type {string}
* @memberof ModelFull
*/
name?: string;
/**
*
* @type {Date}
* @memberof ModelFull
*/
readonly creationDate?: Date;
}
export function ModelFullFromJSON(json: any): ModelFull {
return {
};
}
export function ModelFullToJSON(value?: ModelFull): any {
if (value === undefined) {
return undefined;
}
return {
};
} ModelFullAllOf.ts looks like ModelFull.ts looked like during beta3. When trying to compile: > tsc --outdir ./dist
models/ModelFull.ts:51:5 - error TS2741: Property 'id' is missing in type '{}' but required in type 'ModelFull'. CC: @wing328 |
These incompatibilities are becoming more and more serious. We had to switch to v4, but now v4 is causing problems. Any update here? Or should we fork and apply the patches? |
fixed with #2899 |
Bug Report Checklist
Description
I've been using a nightly snapshot from early December (shortly after my last PR) to generate my typescript client. I decided to try out the latest beta and am happy with some of the changes/fixes (great job)! However, there seems to have been a change with how models are computed/generated, models that "extend" another model (e.g. allOf with a $ref) no longer seem to be generated as such. Additionally, the change I previously put in to use
allVars
vsvars
seems to be breaking things now whereas before it was necessary.openapi-generator version
I'm testing via the latest version shipped with the npm package: 4.0.0-beta3
The old version that was working as expected:: 4.0.0-SNAPSHOT (20181206.114535-69)
OpenAPI declaration file content or url
Generated Code (notice the missing inherited fields including the required field
id
inModelFullFromJSON
):Generated code from older generator (notice
ModelFull
extendsModelPartial
and includes all required fields inModelFullFromJSON
):ModelPartial:
Command line used for generation
openapi-generator generate -i test.yaml -g typescript-fetch -o ./test-api
Steps to reproduce
Generate the code from the example yaml and command line I provided.
Related issues/PRs
Suggest a fix
I'm not aware of what happened in the backend for the "parent" attribute to be dropped when generating models and for the
allVars
not to include everything as it did in the past. If this is truly preferred then I think theallVars
can be switched back tovars
when generating the *FromJSON functions.Please let me know if this was intentional and I can try and put in a PR accordingly.
The text was updated successfully, but these errors were encountered: