簡體   English   中英

swagger-node:使用swagger“使用$ ref進行項目編輯”(多個文件)

[英]swagger-node: using swagger “project edit with” $ref (multiple files)

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

我使用swagger project create hello-world創建了示例swagger hello world項目,如swagger-node git頁面swagger project create hello-world

我使用$ref指向具有相對路徑的外部文件,但無法打開該文件。 使用控制台,我可以看到它嘗試了一個請求,但是出現404錯誤。 看來swagger編輯器只能訪問swagger.yaml文件,而不能訪問其他文件。

作為測試,我將引用的hello.yaml文件復制到項目的每個文件夾中,但仍Reference could not be resolved: 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"

我遇到了同樣的問題,並且發現這是一個不可靠的編輯器錯誤。 請在“ 已知問題”中找到描述。 它將為info Relative path support for external files is not implemented.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM