2017-09-03 89 views
0

我正在檢查出搖擺的節點。這似乎是基本的東西,所以我很難相信它是一個錯誤。

我使用swagger project create hello-world創建示例swagger hello world project,如swagger-node git頁面上所示。

我使用一個$ref到具有相對路徑的外部文件,但它無法打開文件。使用控制檯我可以看到它嘗試請求,但有一個404錯誤。這看起來swagger編輯器只能訪問swagger.yaml文件,但沒有別的。

的測試中,我引用的hello.yaml文件複製到項目的每一個文件夾,並仍然得到Reference could not be resolved: hello.yaml

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: 
    /hello: 
    $ref: hello.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 

hello.yaml

# 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" 

回答

1

我遇到同樣的問題,我發現這是一個招搖即是的編輯器錯誤。 請在Known Issues找到描述。 它會給出信息Relative path support for external files is not implemented.