Swagger错误:各个端点的相对路径

时间:2017-06-10 22:27:26

标签: node.js swagger

使用节点v7.10.0和npm 4.2.0

我创建了一个nodejs' Hello World'项目,我试图重新组织swagger.yaml将主要yaml文件中的路径转换为sepparate paths.yaml文件:

这是我的api/swagger/swagger.yaml

swagger: "2.0"
info:
  version: "0.0.1"
  title: Hello World App
# during dev, should point to your local machine
host: localhost:10010
# basePath prefixes all resource paths
basePath: /
#
schemes:
  # tip: remove http to make production-grade
  - http
  - https
# format of bodies a client can send (Content-Type)
consumes:
  - application/json
# format of the responses to the client (Accepts)
produces:
  - application/json
paths:
  $ref: './paths.yaml'
  /swagger:
    x-swagger-pipe: swagger_raw
# complex objects have schema definitions
definitions:
  HelloWorldResponse:
    required:
      - message
    properties:
      message:
        type: string
  ErrorResponse:
    required:
      - message
    properties:
      message:
        type: string

这是我引用的api/swagger/paths.yaml

/hello:
  # binds a127 app logic to a route
  x-swagger-router-controller: hello_world
  get:
    description: Returns 'Hello' to the caller
    # used as the method name of the controller
    operationId: hello
    parameters:
      - name: name
        in: query
        description: The name of the person to whom to say hello
        required: false
        type: string
    responses:
      "200":
        description: Success
        schema:
          # a pointer to a definition
          $ref: "#/definitions/HelloWorldResponse"
      # responses may fall through to errors
      default:
        description: Error
        schema:
          $ref: "#/definitions/ErrorResponse"

我收到以下Swagger错误:

Relative paths to the individual endpoints. They must be relative to the 'basePath'.

Reference could not be resolved: ./paths.yaml

这两个文件都是&#; swagger.yaml'和' paths.yaml'放在同一目录中#api / swagger /'。 我试图以不同的方式引用paths.yaml

paths:
  $ref: 'paths.yaml'

paths:
  $ref: './api/swagger/paths.yaml'

但我得到同样的错误。是否可以在sepparate yaml文件中引用路径?

0 个答案:

没有答案