Initialized by Create React App.
git clone https://github.com/superwf/ts-gear-example.git
cd ts-gear-example
yarn // or npm install
check the code generated in src/service
.
Bad openapi doc compatible is the killer feature of ts-gear
π‘.
See openapi-typescript-introduction(in ChineseπΌ) for more information.
Fixture source: https://petstore.swagger.io/v2/swagger.json
-
β
ts-gear
-
command:
yarn tsg -p tsGearPetV2
-
result position:
src/service/tsGearPetV2/
Actually, run
yarn tsg
without-p
will generate all service code configured insrc/tsg.config.ts
-
-
β
pont
-
command:
yarn pont
-
result position:
src/service/pont/petV2/
Actually, run
yarn pont
will generate all service code configured inpont-config.json
, in other fixtures case it does not need run again.π’ The request functions generated by pont do NOTconnect request parameters type nor response data type.
-
-
β
openapi-generator
-
command:
yarn openapiGeneratorPetV2
-
result position:
src/service/openapiGeneratorPetV2/
-
-
β
swagger-codegen
-
command:
yarn swaggerCodegenPetV2
-
result position:
src/service/swaggerCodegenPetV2/
-
-
β
oazapfts
-
command:
yarn oazapftsPetV2
-
result position:
src/service/oazapftsPetV2.ts
-
β All tools generate result successfully.
Fixture source: https://petstore3.swagger.io/api/v3/openapi.json
-
β
ts-gear
-
command:
yarn tsg -p tsGearPetV3
-
result position:
src/service/tsGearPetV3/
-
-
β β
pont
-
command:
yarn pont
-
result position:
src/service/pont/petV3/
π’ Run OK, but No definition data type generated.
-
-
β
openapi-generator
-
command:
yarn openapiGeneratorPetV3
-
result position:
src/service/openapiGeneratorPetV3/
-
-
β
swagger-codegen
-
command:
yarn swaggerCodegenPetV3
-
result position:
src/service/swaggerCodegenPetV3/
-
-
β
oazapfts
-
command:
yarn oazapftsPetV3
-
result position:
src/service/oazapftsPetV3.ts
-
β All tools generate result successfully.
Fixture source: https://raw.githubusercontent.com/superwf/ts-gear-example/master/fixture/badDefined1.json
-
β
ts-gear
-
command:
yarn tsg -p tsGearBadDefined1
-
result position:
src/service/tsGearBadDefined1/
-
-
β β
pont
-
β command:
yarn pont
-
βresult position:
src/service/pont/badDefined1/
π’ Run OK, but No meaningful code generated.
-
-
β β
openapi-generator
-
command:
yarn openapiGeneratorBadDefined1
-
β result:
error Command failed with exit code 1
the command tell me use
--skip-validate-spec
to skip validate, so try again with it.-
command:
yarn openapiGeneratorBadDefined1 -- --skip-validate-spec
-
result position:
src/service/openapiGeneratorBadDefined1/
π’ Run OK, but many data type definition missing.
-
-
β β
swagger-codegen
-
command:
yarn swaggerCodegenBadDefined1
-
β result position:
src/service/swaggerCodegenBadDefined1/
π’ Run OK, but many data type definition missing.
-
-
β
oazapfts
-
command:
yarn oazapftsBadDefined1
-
result:
UnhandledPromiseRejectionWarning: MissingPointerError: Token "ReplyVO«PageVO«FieldDefListVO»»" does not exist
-
Fixture source: https://raw.githubusercontent.com/superwf/ts-gear-example/master/fixture/badDefined2.json
-
β
ts-gear
-
command:
yarn tsg -p tsGearBadDefined2
-
result position:
src/service/tsGearBadDefined2/
-
-
β β
pont
-
command:
yarn pont
-
result position:
src/service/pont/badDefined2/
π’ No meaningful code generated.
-
-
β β
openapi-generator
-
command:
yarn openapiGeneratorBadDefined2
-
result:
error Command failed with exit code 1
the command tell me use
--skip-validate-spec
to skip validate, so try again with it.-
command:
yarn openapiGeneratorBadDefined2 -- --skip-validate-spec
-
result position:
src/service/openapiGeneratorBadDefined2/
π’ Run OK, but many data type definition missing.
-
-
β β
swagger-codegen
-
command:
yarn swaggerCodegenBadDefined2
-
result position:
src/service/swaggerCodegenBadDefined2/
π’ Many data type definition missing and type name error.
-
-
β
oazapfts
-
command:
yarn oazapftsBadDefined2
-
result:
UnhandledPromiseRejectionWarning: MissingPointerError: Token "ListVO" does not exist
-
Fixture source: https://raw.githubusercontent.com/superwf/ts-gear-example/master/fixture/badDefined3.json
-
β
ts-gear
-
command:
yarn tsg -p tsGearBadDefined3
-
result position:
src/service/tsGearBadDefined3/
-
-
β
pont
-
command:
yarn pont
-
result position:
src/service/pont/badDefined3/
-
-
β β
openapi-generator
-
β command:
yarn openapiGeneratorBadDefined3
-
β result:
src/service/openapiGeneratorBadDefined3/
π’ Run OK, but result code has syntax error, can not be used directly.
-
-
β β
swagger-codegen
-
command:
yarn swaggerCodegenBadDefined3
-
result position:
src/service/swaggerCodegenBadDefined3/
π’ Run OK, but result code has syntax error, can not be used directly.
-
-
β
oazapfts
-
command:
yarn oazapftsBadDefined3
-
result:
UnhandledPromiseRejectionWarning: MissingPointerError: Token "Map" does not exist
-
tool | bad doc compatibleπ | comment output | Generic type | independent request export | more language support | mock data | custom request logic | translate none english | filter api | openapi V2 & V3 |
---|---|---|---|---|---|---|---|---|---|---|
ts-gear | β | β | β π | β | β | β | β | β | β | β |
pont | β β | β | β | β | β | β | β | β | β | β |
openapi-generator | β | β | β π | β | β | β | β | β | β | β |
swagger-codegen | β | β | β π | β | β | β | β | β | β | β |
oazapfts | β | β | β π | β | β | β | β | β | β | β |
-
Openapi-generator
andSwagger-codegen
are the most common industry general tools, they are powerfull for supportting many program languages and special env. -
Only
pont
andts-gear
use configuration file, all other tools just use cli arguments. -
ts-gear
prove its self the compatibility with bad defined openapi doc.The compatibility of
ts-gear
is not infinite.First the target openapi should be a valid json, and it should not be too ridiculous. π
Whether can generate generic type successfully, depends on the complement of openapi doc definition.