首页 > 解决方案 > swaggerhub 和 REST API

问题描述

我使用 swaggerHub 来编写我的新应用程序节点的文档,但我有一个 api 的问题。

我的 API 需要两个参数。示例:发布http://cloud.amazingwebsite.com/:service/:action

好的,如果你想使用这个API,你必须给两个值。我的问题是 swaggerHub 的文档只提出了带有一个参数的示例。

请问,你有两个参数的例子吗?可能吗 ?谢谢

标签: node.jsswagger

解决方案


如果你这样做:

  "/{service}/{action}":
    x-swagger-router-controller: serviceController
    post:
      summary: To perform an action
      operationId: serviceAction
      parameters:
      - name: service
        in: path
        required: true
        type: string
        description: Request Path Param for service
      - name: action
        in: path
        required: true
        type: string
        description: Request Path Param for Action
      responses:
        '200':
          description: Success
          schema:
            "$ref": "#/definitions/SuccessResponse"
        default:
          description: Error
          schema:
            "$ref": "#/definitions/ErrorResponse"
definitions:
  SuccessResponse:
    type: object
  ErrorResponse:
    required:
    - error
    properties:
      error:
        type: string

推荐阅读