gpt4 book ai didi

node.js - swagger-node:使用 swagger "project edit with"$ref (多个文件)

转载 作者:太空宇宙 更新时间:2023-11-04 00:17:49 25 4
gpt4 key购买 nike

我正在检查 swagger Node 。这似乎是一些基本的东西,所以我很难相信这是一个错误。

我使用 swagger project create hello-world 创建了 swagger-node git 页面上所示的示例 swagger hello world 项目。

我使用 $ref 到具有相对路径的外部文件,但无法打开该文件。使用控制台我可以看到它尝试发出请求,但出现 404 错误。看来swagger编辑器只能访问swagger.yaml文件,而不能访问其他文件。

作为测试,我将引用的 hello.yaml 文件复制到项目的每个文件夹中,但仍然得到引用无法解析: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"

最佳答案

我遇到了同样的问题,我发现这是一个 swagger-editor 错误。请在 Known Issues 找到描述。它将给出信息未实现对外部文件的相对路径支持。

关于node.js - swagger-node:使用 swagger "project edit with"$ref (多个文件),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46022152/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com