如何修复此错误?无法验证架构中的 'oneOf'
How to fix this error? Failed validating 'oneOf' in schema
我正在使用 Flask、Connexion 和 SQLAlchemy 创建一个 API 来访问数据库。为此,我需要以下依赖项:
- Flask-SQLAlchemy
- 烧瓶棉花糖
- Marshmallow-SQLAlchemy
- 棉花糖
当我使用命令 python3 <filename>
运行 带有应用程序实例的文件时,这是产生的错误:
Traceback (most recent call last):
File "server.py", line 16, in <module>
connex_app.add_api("swagger.yml")
File "/home/fidelis/repo/proj4/env/lib/python3.6/site-packages/connexion/apps/flask_app.py", line 57, in add_api
api = super(FlaskApp, self).add_api(specification, **kwargs)
File "/home/fidelis/repo/proj4/env/lib/python3.6/site-packages/connexion/apps/abstract.py", line 153, in add_api
options=api_options.as_dict())
File "/home/fidelis/repo/proj4/env/lib/python3.6/site-packages/connexion/apis/abstract.py", line 75, in __init__
self.specification = Specification.load(specification, arguments=arguments)
File "/home/fidelis/repo/proj4/env/lib/python3.6/site-packages/connexion/spec.py", line 153, in load
return cls.from_file(spec, arguments=arguments)
File "/home/fidelis/repo/proj4/env/lib/python3.6/site-packages/connexion/spec.py", line 107, in from_file
return cls.from_dict(spec)
File "/home/fidelis/repo/proj4/env/lib/python3.6/site-packages/connexion/spec.py", line 144, in from_dict
return Swagger2Specification(spec)
File "/home/fidelis/repo/proj4/env/lib/python3.6/site-packages/connexion/spec.py", line 38, in __init__
self._validate_spec(raw_spec)
File "/home/fidelis/repo/proj4/env/lib/python3.6/site-packages/connexion/spec.py", line 214, in _validate_spec
raise InvalidSpecification.create_from(e)
connexion.exceptions.InvalidSpecification: None is not valid under any of the given schemas
Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^/']['properties']['delete']['properties']['responses']['patternProperties']['^([0-9]{3})$|^(default)$']:
{'oneOf': [{'$ref': '#/definitions/response'},
{'$ref': '#/definitions/jsonReference'}]}
On instance['paths']['/people/{person_id}']['delete']['responses']['200']:
swagger: "2.0"
info:
description: This is the swagger file that goes with our server code
version: "1.0.0"
title: Swagger Rest Article
consumes:
- application/json
produces:
- application/json
basePath: /api
# Paths supported by the server application
paths:
/people:
get:
operationId: people.read_all
tags:
- People
summary: Read the entire set of people, sorted by last name
description: Read the entire set of people, sorted by last name
responses:
200:
description: Successfully read people set operation
schema:
type: array
items:
properties:
person_id:
type: string
description: Id of the person
fname:
type: string
description: First name of the person
lname:
type: string
description: Last name of the person
timestamp:
type: string
description: Creation/Update timestamp of the person
post:
operationId: people.create
tags:
- People
summary: Create a person
description: Create a new person
parameters:
- name: person
in: body
description: Person to create
required: True
schema:
type: object
properties:
fname:
type: string
description: First name of person to create
lname:
type: string
description: Last name of person to create
responses:
201:
description: Successfully created person
schema:
properties:
person_id:
type: string
description: Id of the person
fname:
type: string
description: First name of the person
lname:
type: string
description: Last name of the person
timestamp:
type: string
description: Creation/Update timestamp of the person record
/people/{person_id}:
get:
operationId: people.read_one
tags:
- People
summary: Read one person
description: Read one person
parameters:
- name: person_id
in: path
description: Id of the person to get
type: integer
required: True
responses:
200:
description: Successfully read person from people data operation
schema:
type: object
properties:
person_id:
type: string
description: Id of the person
fname:
type: string
description: First name of the person
lname:
type: string
description: Last name of the person
timestamp:
type: string
description: Creation/Update timestamp of the person record
put:
operationId: people.update
tags:
- People
summary: Update a person
description: Update a person
parameters:
- name: person_id
in: path
description: Id the person to update
type: integer
required: True
- name: person
in: body
schema:
type: object
properties:
fname:
type: string
description: First name of the person
lname:
type: string
description: Last name of the person
responses:
200:
description: Successfully updated person
schema:
properties:
person_id:
type: string
description: Id of the person in the database
fname:
type: string
description: First name of the person
lname:
type: string
description: Last name of the person
timestamp:
type: string
description: Creation/Update timestamp of the person record
delete:
operationId: people.delete
tags:
- People
summary: Delete a person from the people list
description: Delete a person
parameters:
- name: person_id
in: path
type: integer
description: Id of the person to delete
required: true
responses:
200:
我不知道如何解决这个错误。
我忘记在删除响应下方添加说明 200.This 是我忘记的行。
description: successfully deleted a person
我正在使用 Flask、Connexion 和 SQLAlchemy 创建一个 API 来访问数据库。为此,我需要以下依赖项:
- Flask-SQLAlchemy
- 烧瓶棉花糖
- Marshmallow-SQLAlchemy
- 棉花糖
当我使用命令 python3 <filename>
运行 带有应用程序实例的文件时,这是产生的错误:
Traceback (most recent call last):
File "server.py", line 16, in <module>
connex_app.add_api("swagger.yml")
File "/home/fidelis/repo/proj4/env/lib/python3.6/site-packages/connexion/apps/flask_app.py", line 57, in add_api
api = super(FlaskApp, self).add_api(specification, **kwargs)
File "/home/fidelis/repo/proj4/env/lib/python3.6/site-packages/connexion/apps/abstract.py", line 153, in add_api
options=api_options.as_dict())
File "/home/fidelis/repo/proj4/env/lib/python3.6/site-packages/connexion/apis/abstract.py", line 75, in __init__
self.specification = Specification.load(specification, arguments=arguments)
File "/home/fidelis/repo/proj4/env/lib/python3.6/site-packages/connexion/spec.py", line 153, in load
return cls.from_file(spec, arguments=arguments)
File "/home/fidelis/repo/proj4/env/lib/python3.6/site-packages/connexion/spec.py", line 107, in from_file
return cls.from_dict(spec)
File "/home/fidelis/repo/proj4/env/lib/python3.6/site-packages/connexion/spec.py", line 144, in from_dict
return Swagger2Specification(spec)
File "/home/fidelis/repo/proj4/env/lib/python3.6/site-packages/connexion/spec.py", line 38, in __init__
self._validate_spec(raw_spec)
File "/home/fidelis/repo/proj4/env/lib/python3.6/site-packages/connexion/spec.py", line 214, in _validate_spec
raise InvalidSpecification.create_from(e)
connexion.exceptions.InvalidSpecification: None is not valid under any of the given schemas
Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^/']['properties']['delete']['properties']['responses']['patternProperties']['^([0-9]{3})$|^(default)$']:
{'oneOf': [{'$ref': '#/definitions/response'},
{'$ref': '#/definitions/jsonReference'}]}
On instance['paths']['/people/{person_id}']['delete']['responses']['200']:
swagger: "2.0"
info:
description: This is the swagger file that goes with our server code
version: "1.0.0"
title: Swagger Rest Article
consumes:
- application/json
produces:
- application/json
basePath: /api
# Paths supported by the server application
paths:
/people:
get:
operationId: people.read_all
tags:
- People
summary: Read the entire set of people, sorted by last name
description: Read the entire set of people, sorted by last name
responses:
200:
description: Successfully read people set operation
schema:
type: array
items:
properties:
person_id:
type: string
description: Id of the person
fname:
type: string
description: First name of the person
lname:
type: string
description: Last name of the person
timestamp:
type: string
description: Creation/Update timestamp of the person
post:
operationId: people.create
tags:
- People
summary: Create a person
description: Create a new person
parameters:
- name: person
in: body
description: Person to create
required: True
schema:
type: object
properties:
fname:
type: string
description: First name of person to create
lname:
type: string
description: Last name of person to create
responses:
201:
description: Successfully created person
schema:
properties:
person_id:
type: string
description: Id of the person
fname:
type: string
description: First name of the person
lname:
type: string
description: Last name of the person
timestamp:
type: string
description: Creation/Update timestamp of the person record
/people/{person_id}:
get:
operationId: people.read_one
tags:
- People
summary: Read one person
description: Read one person
parameters:
- name: person_id
in: path
description: Id of the person to get
type: integer
required: True
responses:
200:
description: Successfully read person from people data operation
schema:
type: object
properties:
person_id:
type: string
description: Id of the person
fname:
type: string
description: First name of the person
lname:
type: string
description: Last name of the person
timestamp:
type: string
description: Creation/Update timestamp of the person record
put:
operationId: people.update
tags:
- People
summary: Update a person
description: Update a person
parameters:
- name: person_id
in: path
description: Id the person to update
type: integer
required: True
- name: person
in: body
schema:
type: object
properties:
fname:
type: string
description: First name of the person
lname:
type: string
description: Last name of the person
responses:
200:
description: Successfully updated person
schema:
properties:
person_id:
type: string
description: Id of the person in the database
fname:
type: string
description: First name of the person
lname:
type: string
description: Last name of the person
timestamp:
type: string
description: Creation/Update timestamp of the person record
delete:
operationId: people.delete
tags:
- People
summary: Delete a person from the people list
description: Delete a person
parameters:
- name: person_id
in: path
type: integer
description: Id of the person to delete
required: true
responses:
200:
我不知道如何解决这个错误。
我忘记在删除响应下方添加说明 200.This 是我忘记的行。
description: successfully deleted a person