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
version
3.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.推断出来的。
主机
是从
服务器
推断出来的。你是对的。缩进问题的发生是因为在多个编辑器中混合了制表符和空格。我一开始没注意到,你是对的。缩进问题的发生是因为在多个编辑器中混合了制表符和空格。我一开始并没有注意到这一点。