有没有办法根据元数据/Swagger 自动生成 ServiceStack javascript(无打字稿)客户端?以某种方式将它与 webpack 集成会很好。
我不确定是否可以使用 swagger-js-codegen 执行此操作(此包从 swagger 规范文件生成 nodejs 或 angularjs 类)。
实际上 swagger 插件不共享服务来访问 swagger.json 以获得完整的架构(架构被拆分)。是否有任何解决方法可以将 swagger codegen 用于 javascript?
通过访问http://localhost:12116/resources可以获得
{"swaggerVersion":"1.2","apis":[{"path":"/resource/assignroles"},{"path":"/resource/auth"},{"path":"/resource/authenticate"},{"path":"/resource/criteria"},{"path":"/resource/import"},{"path":"/resource/tenders"},{"path":"/resource/unassignroles"}],"apiVersion":"1.0","basePath":"http://localhost:12116","info":{"title":"App"}}
并使用http://localhost:12116/resource/import
{"swaggerVersion":"1.2","apiVersion":"1.0","basePath":"http://localhost:12116","resourcePath":"/import","apis":[{"path":"/import/stats","operations":[{"method":"GET","nickname":"BrowseImportStats","parameters":[],"errorResponses":[]}]},{"path":"/import/tenders/changes/apply","operations":[{"method":"GET","nickname":"ApplyChanges","parameters":[],"errorResponses":[]},{"method":"POST","nickname":"ApplyChanges","parameters":[{"paramType":"body","name":"body","required":false,"allowMultiple":false,"type":"ApplyChanges"}],"errorResponses":[]},{"method":"PUT","nickname":"ApplyChanges","parameters":[{"paramType":"body","name":"body","required":false,"allowMultiple":false,"type":"ApplyChanges"}],"errorResponses":[]},{"method":"DELETE","nickname":"ApplyChanges","parameters":[],"errorResponses":[]}]},{"path":"/import/tenders/sync","description":"summary","operations":[{"method":"GET","summary":"summary","nickname":"ImportTenders","parameters":[],"errorResponses":[]}]}],"models":{"ImportTenders":{"id":"ImportTenders","properties":{}},"ApplyChanges":{"id":"ApplyChanges","properties":{}},"BrowseImportStats":{"id":"BrowseImportStats","description":"BrowseImportStats","properties":{}}}}
更新 2016-11-26 我能够生成文档
C:\git\testapp>java -jar swagger-codegen-cli-2.2.1.jar generate -i http
://localhost:12116/resources -l javascript -o ./node_modules/testapp_api --additi
onal-properties emitJSDoc=false,usePromises=true