I'm seeing a discrepancy between using swagger-codegen in the online editor (http://editor.swagger.io/) to generate a client with typescript-node, which works as expected, and locally, which does not.
Specifically, when running locally using swagger-codgen all parameters are designated as required in the Typescript class definitions. PR #7849 looks it addressed this exact problem some time back, and it works as expected from the online editor, so I can't figure out what my issue running locally is. Using the latest homebrew swagger-codegen formula on macOS High Sierra
Apologies for creating an issue on what is presumably a simple oversight on my part, but I haven't been able to make progress.
Typescript output:
export class ApiUser {
'email': string;
'userId': string;
// ...
}
3.0.5
{
"swagger": "2.0",
"host": "api.sample.com",
"basePath": "/",
"paths": {},
"securityDefinitions": {},
"definitions": {
"ApiUser": {
"type": "object",
"required": [ "email" ],
"properties": {
"email": { "type": "string" },
"userId": { "type": "string" }
}
}
}
}
swagger-codegen generate -i <my_json_doc> -l typescript-node -o <my_output_file>
Language: typescript-node
Local installation: macOS High Sierra with homebrew
brew info swagger-codegen
swagger-codegen: stable 3.0.5 (bottled), HEAD
Generate clients, server stubs, and docs from an OpenAPI spec
https://swagger.io/swagger-codegen/
/usr/local/Cellar/swagger-codegen/2.3.1 (6 files, 13.7MB) *
Poured from bottle on 2018-08-08 at 08:58:07
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/swagger-codegen.rb
==> Dependencies
Build: maven ✘
==> Requirements
Required: java = 1.8 ✔
==> Options
--HEAD
Install HEAD version
brew install swagger-codegen
swagger-codegen generate -i sample-api-docs.json -l typescript-node -o ./
Solved, issue with homebrew formula (can even see the problem in my brew info swagger-codegen output)
Related to #9171. Default swagger-codegen brew formula falls back to version 2.3.1 for typescript-node, which does not include PR #7849
Manual workaround is to just use v2
brew install swagger-codegen@2
brew unlink swagger-codegen
brew link swagger-codegen@2 --force
Most helpful comment
Solved, issue with homebrew formula (can even see the problem in my
brew info swagger-codegenoutput)Related to #9171. Default
swagger-codegenbrew formula falls back to version 2.3.1 fortypescript-node, which does not include PR #7849Manual workaround is to just use v2