flowup / api-client-generator

Angular REST API client generator from Swagger YAML or JSON file with camel case settigs
MIT License
115 stars 21 forks source link

[models] add option to fill default field values #41

Open petomalina opened 6 years ago

petomalina commented 6 years ago

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": "foo@bar.baz"
}

the client would automatically migrate this model into:

{
  "name": "",
  "email": "foo@bar.baz"
}
vmasek commented 6 years ago

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