How to filter generated Swagger JSON (yaml)

后端 未结 2 1918
醉酒成梦
醉酒成梦 2021-01-25 04:10

I have over 5k lines long swagger.json file describing hundreds of paths and objects. I want to generate a TypeScript client (using swagger-codegen) using only a part of the end

2条回答
  •  别那么骄傲
    2021-01-25 04:31

    I think you can do it, using task automation (grunt, gulp, shell, whatever). Basically it could be a 3 steps task:

    1. get the swagger.json (or call the swagger code-gen to get the json, with something like java -jar swagger-codegen-cli-x.x.x.jar generate -i -l swagger -o GeneratedCodeSwagger )
    2. remove the definitions/paths that you want to exclude and create a modified swagger.json
    3. call the code-gen passing the modified json with java -jar swagger-codegen-cli-x.x.x.jar generate -i GeneratedCodeSwagger\swagger.json -l typescript-angular

提交回复
热议问题