Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 大摇大摆的yaml/yml其中一个不起作用_Python_Python 3.x_Yaml_Swagger - Fatal编程技术网

Python 大摇大摆的yaml/yml其中一个不起作用

Python 大摇大摆的yaml/yml其中一个不起作用,python,python-3.x,yaml,swagger,Python,Python 3.x,Yaml,Swagger,我目前正在构建RESTAPI,在实现我们的文件类型时遇到了困难。文件可以来自用户或组,我用oneOf尝试了这一点,但我得到了一个错误。以下是我的代码和错误: File: type: object properties: owner: oneOf: - $ref: "#/definitions/User" - $ref: "#/definitions/Group" description: Owner of the File

我目前正在构建RESTAPI,在实现我们的文件类型时遇到了困难。文件可以来自用户或组,我用
oneOf
尝试了这一点,但我得到了一个错误。以下是我的代码和错误:

File:
  type: object
  properties:
    owner:
      oneOf:
        - $ref: "#/definitions/User"
        - $ref: "#/definitions/Group"
      description: Owner of the File
错误:

swagger_spec_validator.common.SwaggerValidationError: ("'oneOf' does not match any of the regexes: '^x-'\n\nFailed validating 'additionalProperties' in schema['properties']['definitions']['additionalProperties']['properties']['properties']['additionalProperties']:\n    {'additionalProperties': False,\n     'description': 'A deterministic version of a JSON Schema object.',\n     'patternProperties': {'^x-': {'$ref': '#/definitions/vendorExtension'}},\n     'properties': {'$ref': {'type': 'string'},\n                    'additionalProperties': {'anyOf': [{'$ref': '#/definitions/schema'},\n                                                       {'type': 'boolean'}],\n                                             'default': {}},\n             'allOf': {'items': {'$ref': '#/definitions/schema'},\n                              'minItems': 1,\n                              'type': 'array'},\n                    'default': {'$ref': 'http://json-schema.org/draft-04/schema#/properties/default'},\n                    'description': {'$ref': 'http://json-schema.org/draft-04/schema#/properties/description'},\n                    'discriminator': {'type': 'string'},\n                    'enum': {'$ref': 'http://json-schema.org/draft-04/schema#/properties/enum'},\n                    'example': {},\n                    'exclusiveMaximum': {'$ref': 'http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum'},\n                    'exclusiveMinimum': {'$ref':'http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum'},\n                    'externalDocs': {'$ref': '#/definitions/externalDocs'},\n                    'format': {'type': 'string'},\n                    'items': {'anyOf': [{'$ref': '#/definitions/schema'},\n                                        {'items': {'$ref': '#/definitions/schema'},\n                                         'minItems': 1,\n                                         'type': 'array'}],\n               'default': {}},\n                    'maxItems': {'$ref': 'http://json-schema.org/draft-04/schema#/definitions/positiveInteger'},\n                    'maxLength': {'$ref': 'http://json-schema.org/draft-04/schema#/definitions/positiveInteger'},\n                    'maxProperties': {'$ref': 'http://json-schema.org/draft-04/schema#/definitions/positiveInteger'},\n                    'maximum': {'$ref': 'http://json-schema.org/draft-04/schema#/properties/maximum'},\n          'minItems': {'$ref': 'http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0'},\n                    'minLength': {'$ref': 'http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0'},\n        'minProperties': {'$ref': 'http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0'},\n                    'minimum': {'$ref': 'http://json-schema.org/draft-04/schema#/properties/minimum'},\n                    'multipleOf': {'$ref': 'http://json-schema.org/draft-04/schema#/properties/multipleOf'},\n                    'pattern': {'$ref': 'http://json-schema.org/draft-04/schema#/properties/pattern'},\n                    'properties': {'additionalProperties': {'$ref': '#/definitions/schema'},\n                                   'default': {},\n                                   'type': 'object'},\n                    'readOnly': {'default': False, 'type': 'boolean'},\n                    'required': {'$ref': 'http://json-schema.org/draft-04/schema#/definitions/stringArray'},\n                    'title': {'$ref': 'http://json-schema.org/draft-04/schema#/properties/title'},\n                    'type': {'$ref': 'http://json-schema.org/draft-04/schema#/properties/type'},\n                    'uniqueItems': {'$ref': 'http://json-schema.org/draft-04/schema#/properties/uniqueItems'},\n                    'xml': {'$ref': '#/definitions/xml'}},\n     'type': 'object'}\n\nOn instance['definitions']['File']['properties']['owner']:\n    {'description': 'Owner of the File',\n     'oneOf': {'schema': [{'$ref': '#/definitions/User'},\n                          {'$ref': '#/definitions/Group'}]}}", <ValidationError: "'oneOf' does not match any of the regexes: '^x-'">)
The terminal process terminated with exit code: 1
swagger\u spec\u validator.common.SwaggerValidationError:(“'oneOf'与任何正则表达式都不匹配:'^x-'\n\n验证架构['properties']['definitions']['additionalProperties']['properties']['properties']['additionalProperties']中的'additionalProperties'失败:\n{'additionalProperties':False,\n'description':'JSON架构对象的确定性版本',\n'patternProperties':{'^x-':{'$ref':'.\n/definitions/vendorExtension'},\n'properties':{'$ref':{'type':'string'},\n'additionalProperties':{'anyOf':[{'$ref':'定义/Schema'},\n{type':'boolean'}],\n'default':{},\n'allOf':{'items':{'$ref':'#/definitions/schema'},\n'minItems':1、\n'type':'array'}、\n'default':{'$ref':'http://json-schema.org/draft-04/schema#/properties/default'},\n'说明':{'$ref':'http://json-schema.org/draft-04/schema#/properties/description'},\n'鉴别器':{'type':'string'},\n'enum':{'$ref':'http://json-schema.org/draft-04/schema#/properties/enum'},\n'示例':{},\n'排他最大值':{'$ref':'http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum'}、\n'ExclusiveEmimum':{'$ref':'http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum'},\n'externalDocs':{'$ref':'#/definitions/externalDocs'}、\n'格式':{'type':'string'}、\n'items':{'anyOf':[{'$ref':'#/definitions/schema'}、\n{'items':{'$ref':'#/definitions/schema'},\n'minItems':1,\n'type':'array'}],\n'default':{}}、\n'maxItems':{$ref':'http://json-schema.org/draft-04/schema#/definitions/positiveInteger'},\n'maxLength':{'$ref':'http://json-schema.org/draft-04/schema#/definitions/positiveInteger'},\n'maxProperties':{'$ref':'http://json-schema.org/draft-04/schema#/definitions/positiveInteger'},\n'最大值':{'$ref':'http://json-schema.org/draft-04/schema#/properties/maximum'},\n'minItems':{'$ref':'http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0'},\n'minLength':{'$ref':'http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0'},\n'minProperties':{'$ref':'http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0'},\n“最小值”:{“$ref”:”http://json-schema.org/draft-04/schema#/properties/minimum'}、\n'multipleOf':{'$ref':'http://json-schema.org/draft-04/schema#/properties/multipleOf“}、\n”模式“:{“$ref”:”http://json-schema.org/draft-04/schema#/properties/pattern'},\n'properties':{'additionalProperties':{'ref':'#/definitions/schema'},\n'default':{},\n'type':'object'},\n'readOnly':{'default':False,'type':'boolean'},\n'required':{'$ref':'http://json-schema.org/draft-04/schema#/definitions/stringArray'}、\n'title':{'$ref':'http://json-schema.org/draft-04/schema#/properties/title“}、\n”类型“:{“$ref”:”http://json-schema.org/draft-04/schema#/properties/type“}、\n“唯一项”:{'$ref':'http://json-schema.org/draft-04/schema#/properties/uniqueItems'}、\n'xml':{'$ref':'.\n'definitions/xml'}、\n'type':'object'}\n\n实例['definitions']['File']['properties']['owner']:\n{'description':'文件所有者',\n'oneOf':{'schema':[{'$ref':'.\n/definitions/User'},\n{'$ref':'#/definitions/Group'}]}},)
终端进程终止,退出代码为:1
格式很抱歉,但这是错误消息。。。 如果我是对的,它会因为
oneOf
而失败,但是正如所描述的
oneOf
它在这里完全可用

请帮我把这个修好,因为我已经在上面坐了一个小时了


编辑:我使用的是swagger的2.0版

OpenAPI 3.0中引入了一个
。您的规范是
OpenAPI:3.0.0
还是
swagger:'2.0'
?2.0,但connexion还不支持这一点……还有其他方法实现吗?
一个
在2.0中不起作用。