swagger-node: используя swagger "редактирование проекта с" $ref (несколько файлов)

Я проверяю узел чванства. Кажется, это что-то базовое, поэтому мне трудно поверить, что это ошибка.

Я создаю пример проекта swagger hello world, как указано на git-странице swagger-node, используя swagger project create hello-world,

Я использую $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 ответ

Я встречал ту же проблему и обнаружил, что это ошибка редактора. Пожалуйста, найдите описание в разделе Известные проблемы. Это даст информацию Relative path support for external files is not implemented.

Другие вопросы по тегам