yaml - swagger 不应该有使用 OpenAPI (3.0.0) 的附加属性
问题描述
我查看了已经提出的问题,但没有一个能够解决我的问题。
https://stackoverflow.com/questions/45534187/path-and-formdata-paramter-at-the-same-time
https://stackoverflow.com/questions/50562971/swagger-editor-shows-the-schema-error-should-not-have-additional-properties-e
https://stackoverflow.com/questions/48283801/swagger-3-0-schema-error-should-not-have-additional-properties
我正在使用OpenAPI 3.0.0
. 我在 line 收到以下问题6
。我经历了多次缩进,移动了一些东西,然后重新开始。我已经使用了,swagger documentation
但我仍然遇到这个问题。我将在yaml
下面发布。任何提示将不胜感激。
Error:
should not have additional properties:
additionalProperty: /author/author{id}
# openapi: 3.0.0
# info:
# version: 0.0.1
# title: Author API
# description: Author API documentation
openapi: 3.0.0
info:
title: Author API
description: Author API
version: 0.0.1
servers:
- url: 'http://localhost:8080/'
description: Local dev server
# post new author done
# find author {id} done
# get all author done
# update author {id} done
# delete author {id} done
paths:
/author:
post:
summary: Add a author to database
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Author'
responses:
'201':
description: return the author to the user with the id attached
content:
application/json:
schema:
$ref: '#/components/schemas/Author'
get:
summary: Get all the authors in the database
responses:
'200':
description: Return all the authors in the database
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Author'
/author/{authorId}:
update:
summary: update the author with the id
parameters:
- name: authorId
in: path
required: true
description: Id of the author to update
schema:
type: integer
responses:
'200':
description: Return just the author at that id
content:
application/json:
schema:
$ref: '#/components/schemas/Author'
get:
summary: get the author with the specific id
paramaters:
- name: authorId
in : path
required: true
description: Id of the author to retrieve
schema:
type: integer
responses:
'200':
description: Return just the author at that id
content:
application/json:
schema:
$ref: '#/components/schemas/Author'
delete:
summary: Remove a author by the given Id
parameters:
- name: authorId
in: path
required: true
description: Id of the author to delete
schema:
type: integer
responses:
'200':
description: The author was successfully removed
components:
schemas:
Author:
type: object
properties:
authorId:
type: integer
firstName:
type: string
lastName:
type: string
street:
type: string
city:
type: string
state:
type: string
postalCode:
type: string
phone:
type: string
email:
type : string
解决方案
在前面添加两个空格/author/{authorId}
,使这一行的缩进与/author
. YAML 需要正确缩进嵌套项。
paths:
/author:
...
/author/{authorId}:
...
推荐阅读
- c++ - 安装先决条件 wxWidgets 时出错“E:无法纠正问题,您持有损坏的软件包。”
- android - Recyclerview android中的微调器问题
- python - 云服务如何访问您的托管脚本?
- ios - SQLite 查询语句插入在 swift 中无法正常工作
- python - 下面代码中的函数调用如何反转字符串?
- python - Django 项目的主题选择选项无法正常工作
- java - 指定为非 null 的参数是 null.SocketService
- mongodb - 如何使用与 V2.4 的 maxTimeMS 等效的函数来增加 MongoDB 查询的超时时间?
- python - List[Optional[int]] 分配时的类型检查
- mysql - codeigniter 的情况下在哪里不工作?