api-client-generator icon indicating copy to clipboard operation
api-client-generator copied to clipboard

[models] add option to fill default field values

Open petomalina opened this issue 6 years ago • 1 comments

It would be awesome if the API client could generate constructor functions which would automatically fill null fields.

E.g:

interface User {
  name: string;
  email: string;
}

and the response from the API would be:

{
  "email": "[email protected]"
}

the client would automatically migrate this model into:

{
  "name": "",
  "email": "[email protected]"
}

petomalina avatar Mar 27 '18 11:03 petomalina

in user.model.ts file there would be a function getUser which will take User as an optional parameter. It will return an empty user merged with the user provided in params

vmasek avatar Mar 27 '18 11:03 vmasek