Swagger 生成器无法识别控制器

编程入门 行业动态 更新时间:2024-10-23 01:36:47
本文介绍了Swagger 生成器无法识别控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有这个 yaml 文件:

I have this yaml file:

--- swagger: "2.0" info: version: 0.1.0 title: "My API" host: localhost:3000 basePath: /api schemes: - http paths: /weather: get: x-swagger-router-controller: "weatherController" description: "Returns current weather in the specified city to the caller" operationId: getWeather parameters: - name: city in: query description: "The city you want weather for in the form city,state,country" required: true type: "string"

当我运行 swagger-codegen-cli 时,生成/api/Default.js 和/api/DefaultService.js ,但没有/api/weatherController.js.

When I run swagger-codegen-cli, generates /api/Default.js and /api/DefaultService.js , but no /api/weatherController.js.

我也试过这个:

--- swagger: "2.0" info: version: 0.1.0 title: "My API" host: localhost:3000 basePath: /api schemes: - http paths: /weather: x-swagger-router-controller: "weatherController" get: description: "Returns current weather in the specified city to the caller" operationId: getWeather parameters: - name: city in: query description: "The city you want weather for in the form city,state,country" required: true type: "string"

我用这个命令运行生成器:

And I run the generator with this command:

java -jar swagger-codegen-cli.jar generate -l nodejs-server -o output -i api.yaml

我该怎么做?

推荐答案

我认为这是一个错误,如果您能将其归档到 swagger-codegen 项目中,那就太好了.但作为一种解决方法,请考虑添加一个标签:

I think that's a bug, it would be great if you could file that on the swagger-codegen project. But as a work around, consider adding a tag:

/weather: x-swagger-router-controller: "weatherController" get: tags: - weatherController description: "Returns current weather in the specified city to the caller" operationId: getWeather parameters: - name: city in: query description: "The city you want weather for in the form city,state,country" required: true type: "string"

更多推荐

Swagger 生成器无法识别控制器

本文发布于:2023-11-17 00:04:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608064.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:生成器   控制器   无法识别   Swagger

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!