Yaml OpenAPI规范2.0带有正文和标题的帖子
我想在post中发送一个带有api密钥的对象 我如何用英语来描述这一点 我在yaml中尝试了这个子集:Yaml OpenAPI规范2.0带有正文和标题的帖子,yaml,swagger,restful-architecture,swagger-2.0,Yaml,Swagger,Restful Architecture,Swagger 2.0,我想在post中发送一个带有api密钥的对象 我如何用英语来描述这一点 我在yaml中尝试了这个子集: paths: /eau: post: tags: - Pets summary: Send a pet description: 'Send a pet' operationId: sendapet consumes: - application/json produces:
paths:
/eau:
post:
tags:
- Pets
summary: Send a pet
description: 'Send a pet'
operationId: sendapet
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: pet
description: Send a pet
required: true
schema:
$ref: '#/definitions/pet'
- in: header
name: api_key
但在
- in: header
name: api_key
我得到以下错误:
Schema error at paths['/pet'].post.parameters[1].in
should be equal to one of the allowed values
allowedValues: body
Jump to line 36
Schema error at paths['/pet'].post.parameters[1]
should match exactly one schema in oneOf
Jump to line 36
Schema error at paths['/pet'].post.parameters[1]
should NOT have additional properties
additionalProperty: in, name
Jump to line 36
发生错误的原因是标头参数缺少类型 但是,API密钥与身份验证/授权相关,因此应使用securityDefinitions和security关键字(而不是标头参数)来描述它们: 证券定义: apiKey: 类型:apiKey 在:标题 名称:api_密钥 安全: -apiKey:[] 更多信息: