【发布时间】:2017-06-20 13:48:57
【问题描述】:
我的 OpenAPI 规范文件有问题。我试图调用一个暴露的 url 来“获取”一个 id,但是每次我将服务转发到我的本地然后尝试通过 API 文档发送请求时,我的连接都被拒绝了。我将不胜感激任何帮助。我期望的 id 将采用 JSON 格式。以下是我的规范文件
openapi: "3.0.0"
info:
version: 1.0.0
title: Id Generator
servers:
url: www.someurl.com
paths:
/posts:
get:
summary: Get Id
operationId: id
tags:
- posts
responses:
200:
description: successful operation
content:
application/json:
schema:
$ref: "#/definition/Post"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/definition/Error"
definition:
Post:
type: object
properties:
id:
type: string
Error:
properties:
id:
type: string
【问题讨论】:
-
您如何进行 API 调用 - 从浏览器中的 Swagger UI 或其他方式?
-
顺便说一下,您的规范不是有效的 3.0.0 或 2.0 规范。缩进在几个地方是错误的,并且规范使用了错误的 2.0 和 3.0.0 关键字。
-
@Helen 我正在使用 swagger UI 进行 API 调用。我没有收到 Visual Studio 代码的缩进错误。
-
@Helen 我做了一些更正以减轻 2.0 和 3.0 的混合。我在上面重新发布了我的规范。由于我直接将其粘贴到此处,因此可能存在缩进问题。但我在 Visual Studio 代码上没有任何缩进错误。我仍然无法使用我的规范文件成功获得响应。
-
我是openapi新手,想问一下openapi yaml文件是怎么得到的?生成了吗?
标签: swagger swagger-2.0 openapi