我有这个yaml文件:
---
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。
我也尝试过这个:
---
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"
然后使用以下命令运行生成器:
java -jar swagger-codegen-cli.jar generate -l nodejs-server -o output -i api.yaml
我怎样才能做到这一点?
我认为这是一个错误,如果可以将其提交到swagger-codegen项目,那就太好了。但是,要解决此问题,请考虑添加标签:
/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"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句