【问题标题】:Cannot resolve configured swagger-router handler无法解析配置的 swagger-router 处理程序
【发布时间】:2018-07-24 08:22:19
【问题描述】:

当我从我的 Vuejs 应用程序向我的 a127/apigee-127 Rest Service 提交 POST 请求时,http 响应是 500:

{"message":"Cannot resolve the configured swagger-router handler: IAGController_post"}

似乎正在发生的事情是 a127 Rest WebService 正在将“_post”添加到我的 IAGController 的名称中,我不知道为什么?

Vuejs 代码:

let path = 'http://localhost:10010/iag';       
this.$http.post(path, {body: {grantType: 'bar', apiKey: 'abc', apiSecret: 'defg'}, headers: {'Content-Type': 'application/json'}})
          .then(response => {
          return response.json();
        }).then(data => {
            console.log(data);
        });

RESTFul WebService 代码:

大摇大摆:

swagger: "2.0"
info:
  version: "0.0.1"
  title: Hello World App
host: localhost:10010
basePath: /
schemes:
 - http
 - https
produces:
  - application/json
x-a127-config: {}
x-a127-services: {}
paths:
  /iag:
    x-swagger-router-controller: IAGController
    x-a127-apply: {}
    post:
      consumes: [application/json]
      parameters:  
        - name: body
          in: body
          description: Request a secure token
          required: true
          schema:
            $ref: "#/definitions/IAGSecurityRequest"
      responses:
        "200":
          description: Success
          schema:
            # a pointer to a definition
            $ref: "#/definitions/tokenResponse"
        # responses may fall through to errors
        default:
          description: Error
          schema:
            $ref: "#/definitions/ErrorResponse"
definitions:
  IAGSecurityRequest:
    type: object
    properties:
      grantType:
        type: string
      apiKey:
        type: string
      apiSecret:
        type: string
ErrorResponse:
    type: string
  tokenResponse:
    type: object
    properties:
      access_token:
        type: string
      token_type:
        type: string
      expires_in:
        type: integer

【问题讨论】:

    标签: node.js swagger-2.0 apigee


    【解决方案1】:

    尝试这样做: Swagger generator doesn't recognize controller

    也许您还必须以 get.... 开头的函数名称

    【讨论】:

      【解决方案2】:

      有时会发生,因为在 swagger 文件中 x-swagger-router-controller 值与控制器文件名不对应或控制器文件名已更改。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-12-29
        • 2021-08-11
        • 2022-08-19
        • 1970-01-01
        • 1970-01-01
        • 2012-06-30
        • 2011-11-03
        • 2021-09-17
        相关资源
        最近更新 更多