Yaml 使用openapi 3.0获取重复的映射键错误
我正在尝试使用Yaml 使用openapi 3.0获取重复的映射键错误,yaml,openapi,swagger-3.0,Yaml,Openapi,Swagger 3.0,我正在尝试使用openapiversion3.0.0定义我的api。我已生成以下YAML文件: openapi: 3.0.0 info: title: My YAML description: My YAML version: 1.0.0 servers: - url: http://my.server.url paths: /v1/service/uri: post: summary: Getting some inf
openapi
version3.0.0
定义我的api。我已生成以下YAML文件:
openapi: 3.0.0
info:
title: My YAML
description: My YAML
version: 1.0.0
servers:
- url: http://my.server.url
paths:
/v1/service/uri:
post:
summary: Getting some information.
parameters:
- name: Content-Type
in: header
description: Content type of request body.
required: true
style: simple
explode: false
schema:
type: string
- name: Host
in: header
description: Originate host which returns the response.
required: false
style: simple
explode: false
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/MyPostRequest'
example:
my_name: "zizi"
my_age: 29
required: true
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/MyPostResponse'
components:
schemas:
MyPostRequest:
type: object
properties:
my_name:
type: string
my_age:
type: integer
format: int32
MyPostResponse:
type: object
properties:
status:
type: integer
format: int32
当我将这些行复制/粘贴到中时,它会在第19行上给我复制映射键
错误;用于参数内容类型
的说明
部分
我已经研究过了,但是我没有发现我的YAML文件有任何问题。我不知道你为什么会出现这种错误,我试图找出是用哪种语言编写的Swagger,因为有几个YAML解析器已知有问题,但无法通过谷歌或维基百科轻松确定
您的文件中没有任何重复的键,但由于键内容
缩进(第二次出现在路径
下),该键无效(即无效YAML)→
/v1/service/uri
→ <代码>发布
→ <代码>响应→ <代码>200),应与
description
由于该键不能同时具有标量(OK
)和映射节点content:…
我不确定为什么会出现此错误,我试图找出编写Swagger的语言,因为已知有几个YAML解析器存在问题,但无法通过谷歌或维基百科轻松确定这一点
您的文件中没有任何重复的键,但由于键内容
缩进(第二次出现在路径
下),该键无效(即无效YAML)→
/v1/service/uri
→ <代码>发布→ <代码>响应→ <代码>200),应与
description
由于该键不能同时具有标量(OK
)和映射节点content:…
的值节点,因此除了Anthon的答案之外,还需要删除content Type
和Host
参数。请求的内容类型
是从requestBody.Content中推断出来的。
和主机
是从服务器
中推断出来的。除了Anthon的答案之外,您还需要删除内容类型
和主机
参数。请求的内容类型
是从requestBody.Content.推断出来的。
和主机
是从服务器
推断出来的。你是对的。缩进问题的发生是因为在多个编辑器中混合了制表符和空格。我一开始没注意到,你是对的。缩进问题的发生是因为在多个编辑器中混合了制表符和空格。我一开始并没有注意到这一点。