Generate typescript client/models from swagger.json file
npm install --global swagger-typescript-client-generator
$ swagger-typescript-client-generator models -f swagger.json > models.ts
$ swagger-typescript-client-generator client MyApi "./models.ts" -f swagger.json > client.ts
$ swagger-typescript-client-generator bundle MyApi -f swagger.json > client.ts
models
- generate only modelsclient <name> [importFromFile]
- generate client with givenname
and import models from optional parameter[importFromFile]
(default"./model"
)bundle <name>
- generate models and client in single run
--file, -f
- input file swagger.json-allowVoidParameterTypes, -a
- generate parameter types (query, body, formData, headers) forvoid
values. Can apply to both models and client (see #)