我查看了已经提出的问题,但没有一个能够解决我的问题。
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
。我在第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
答案 0 :(得分:1)
在/author/{authorId}
之前添加两个空格,以便此行的缩进与/author
相同。 YAML需要正确缩进嵌套项目。
paths:
/author:
...
/author/{authorId}:
...