【问题标题】:Azure API Management Service not recognizing swaggerAzure API 管理服务无法识别招摇
【发布时间】:2017-01-22 12:15:55
【问题描述】:

我正在尝试使用 Azure API 管理服务。

当我转到 Import API 时,我目前收到以下错误。

One or more fields contain incorrect values:
Parsing error(s): Unexpected character encountered while parsing value: #. Path '', line 0, position 0.
One or more fields contain incorrect values:
API not found

当我上传我的招摇规范时会发生这种情况。这是我第一次写它,但我浏览了我的文档,似乎找不到任何问题。

我也在其他地方使用过这个文档,效果很好。

http://pastebin.com/fb4xiuLu我的招摇文档的链接

任何帮助将不胜感激。谢谢:)

【问题讨论】:

  • 尝试以 json 格式上传您的 swagger 文档。
  • 顺便说一句,您的规范不是有效的 Swagger 规范。 1)type: ['integer','null']等多种类型为not supportedtype 需要单一类型。 2) null 不是有效类型,因为它不是 listed in the spec。但是有一个 discussion in the OpenAPI spec repo 在下一版本的规范 3.0 中添加“空值”支持。

标签: c# rest api azure swagger


【解决方案1】:

正如 mikalai 提到的,我们需要导入 Json 格式的文件。我们可以获取更多关于如何导入 API 的详细信息,请参考官方document。从文档中截取一些片段。

API 管理目前支持 1.2 和 2.0 版本的 Swagger 文档进行导入。确保即使 Swagger 2.0 specification 声明 host、basePath 和 scheme 属性是可选的,您的 Swagger 2.0 文档也必须包含这些属性;否则它不会被导入。

Demo Swagger Json 文件请参考calapijson

【讨论】:

  • 我不太明白 - 您提到主机 basePath 和方案属性是必需的 - 但只有 basePath 显示在您的演示文件中。此外,我在 Swagger 规范中找不到方案或主机示例。我错过了什么?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-02-02
  • 1970-01-01
  • 2021-04-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-23
相关资源
最近更新 更多