node.js - 无法解析配置的 swagger-router 处理程序

标签 node.js swagger-2.0 apigee

当我从 Vuejs 应用程序向我的 a127/apigee-127 Rest 服务提交 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 Web服务代码:

大摇大摆:

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

最佳答案

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

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

关于node.js - 无法解析配置的 swagger-router 处理程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48775712/

相关文章:

javascript - APIGEE client.loginFacebook如何覆盖apigee生成的用户ID

javascript - Firebase 函数发送后无法设置 header

node.js - AWS Cloudformation - 如何将 sns 主题 arn 传递到堆栈?

node.js - Firebase Cloud Storage getSignedUrl 过期日期不能是过去的(Firebase Cloud Functions)

java - 为什么我的 swagger.json 是空的? - RestEasy,Wildfly 上的 Java

apigee - 使用 Usergrid 如何将相关实体嵌套在单个 json 中,而不仅仅是它们的链接

SSL 客户端验证失败

javascript - 控制 flash 在 node-webkit 中打开的窗口

Swagger ;根据可选参数指定具有相同代码的两个响应

javascript - 有没有办法在 swagger-ui 3.* 中只呈现特定的 api 端点?