【问题标题】:Swagger generator doesn't recognize controllerSwagger 生成器无法识别控制器
【发布时间】:2016-07-11 05:46:10
【问题描述】:

我有这个 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

我该怎么做?

【问题讨论】:

    标签: node.js swagger swagger-2.0


    【解决方案1】:

    我认为这是一个错误,如果您可以将其归档到 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"
    

    【讨论】:

    猜你喜欢
    • 2018-11-11
    • 2016-05-30
    • 1970-01-01
    • 2021-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-19
    相关资源
    最近更新 更多