昂首阔步yaml / yml oneOf不起作用

时间:2018-08-02 13:01:56

标签: python python-3.x yaml swagger

我目前正在构建我们的REST API,实现我的文件类型时遇到困难。文件可以来自用户,也可以来自组。我使用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

对不起,格式,但这是错误消息... 当我说对了时,它会因为oneOf而失败,但是正如here oneOf所述,它在这里完全可用。

请坐下一个小时,以帮助我解决此问题

编辑:我使用的是招摇的2.0版本

0 个答案:

没有答案