Univention Bugzilla – Bug 52862
73_udm-rest/01_openapi_validation fails
Last modified: 2021-03-03 18:46:09 CET
Test test fails with File "/usr/local/lib/python3.5/dist-packages/openapi_schema_validator/validators.py", line 1, in <module> (2021-03-02 13:11:22.837827) from jsonschema import _legacy_validators, _utils, _validators (2021-03-02 13:11:22.837873) ImportError: cannot import name '_legacy_validators' seems that jsonschema is to old for the new openapi_schema_validator
just added pip3 install -U jsonschema to update the jsonschema module still fails with + curl -u Administrator:univention http://localhost/univention/udm/openapi.json % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1313k 100 1313k 0 0 144k 0 0:00:09 0:00:09 --:--:-- 136k {'in': 'query', 'description': 'The `LDAP` search scope (sub, base, one).', 'examples': {'one': {'value': 'one', 'summary': 'one-scope'}, 'base': {'value': 'base', 'summary': 'base-scope'}, 'sub': {'value': 'sub', 'summary': 'sub-scope'}}, 'name': 'scope', 'example': 'sub', 'schema': {'default': 'sub', 'type': 'string'}} is not valid under any of the given schemas Failed validating 'oneOf' in schema['properties']['components']['properties']['parameters']['patternProperties']['^[a-zA-Z0-9\\.\\-_]+$']: {'oneOf': [{'$ref': '#/definitions/Reference'}, {'$ref': '#/definitions/Parameter'}]} On instance['components']['parameters']['search.scope']: {'description': 'The `LDAP` search scope (sub, base, one).', 'example': 'sub', 'examples': {'base': {'summary': 'base-scope', 'value': 'base'}, 'one': {'summary': 'one-scope', 'value': 'one'}, 'sub': {'summary': 'sub-scope', 'value': 'sub'}}, 'in': 'query', 'name': 'scope', 'schema': {'default': 'sub', 'type': 'string'}}
The schema validation works again when removing parameter examples. I still have to check if this is an error in the openapi validator or if our schema really was invalid. diff --git management/univention-directory-manager-rest/src/univention/admin/rest/module.py management/univention-directory-manager-rest/src/univention/admin/rest/module.py index 74605dbf87..cd2ea2f32f 100755 --- management/univention-directory-manager-rest/src/univention/admin/rest/module.py +++ management/univention-directory-manager-rest/src/univention/admin/rest/module.py @@ -1504,11 +1504,6 @@ class OpenAPI(Resource): }, "example": "sub", "description": "The `LDAP` search scope (sub, base, one).", - "examples": { - "sub": {"value": "sub", "summary": "sub-scope"}, - "base": {"value": "base", "summary": "base-scope"}, - "one": {"value": "one", "summary": "one-scope"}, - } }, 'search.filter': { "in": "query", @@ -1516,11 +1511,6 @@ class OpenAPI(Resource): "schema": {"type": "string", "default": ""}, "description": "A ldap filter which may contain `UDM` property names instead of `LDAP` attribute names.", "example": "(objectClass=*)", - "examples": { - "users-user": { - "value": "(|(username=Administrator)(username=Admin*))", - } - }, }, 'search.query': { "in": "query",
The OpenAPI schema has been adjusted: examples and example were both specified but are mutually exclusive. The old swagger UI does not show examples. I upgraded swagger UI in UCS 5.0, if you want to have a look: http://fqdn/univention/udm/schema/. univention-directory-manager-rest.yaml e1c42a508758 | YAML Bug #52862 univention-directory-manager-rest (9.0.16-13) 6579096c3ac1 | Bug #52862: fix OpenAPI schema: remove mutual exclusive "example" and "examples" ucs-test (9.0.7-25) 1c482f42ca92 | Bug #52862: 73_udm-rest/01_openapi_validation fails Merged to UCS 5.0: univention-directory-manager-rest (10.0.1-3) 90e6a347bc41 | Bug #52862: fix OpenAPI schema: remove mutual exclusive "example" and "examples" ucs-test (10.0.4-13) 457a75dd6bfa | Bug #52862: 73_udm-rest/01_openapi_validation fails
still get + curl -u Administrator:univention http://localhost/univention/udm/openapi.json % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1693k 100 1693k 0 0 114k 0 0:00:14 0:00:14 --:--:-- 109k {'examples': {'any-object': {'value': '(objectClass=*)'}, 'admin-user': {'value': '(|(username=Administrator)(username=Admin*))'}}, 'name': 'filter', 'description': 'A ldap filter which may contain `UDM` property names instead of `LDAP` attribute names.', 'in': 'query', 'schema': {'type': 'string', 'default': ''}, 'example': '(objectClass=*)'} is not valid under any of the given schemas Failed validating 'oneOf' in schema['properties']['components']['properties']['parameters']['patternProperties']['^[a-zA-Z0-9\\.\\-_]+$']: {'oneOf': [{'$ref': '#/definitions/Reference'}, {'$ref': '#/definitions/Parameter'}]} On instance['components']['parameters']['search.filter']: {'description': 'A ldap filter which may contain `UDM` property names ' 'instead of `LDAP` attribute names.', 'example': '(objectClass=*)', 'examples': {'admin-user': {'value': '(|(username=Administrator)(username=Admin*))'}, 'any-object': {'value': '(objectClass=*)'}}, 'in': 'query', 'name': 'filter', 'schema': {'default': '', 'type': 'string'}} univention-directory-manager-rest: Installiert: 9.0.16-13A~4.4.0.202103031329 Installationskandidat: 9.0.16-13A~4.4.0.202103031329
Sorry, accidentally did not remove the "example" property. univention-directory-manager-rest (9.0.16-14) b25c8cd31866 | fixup! Bug #52862: fix OpenAPI schema: remove mutual exclusive "example" and "examples" univention-directory-manager-rest (10.0.1-3) b0102b976cea | fixup! Bug #52862: fix OpenAPI schema: remove mutual exclusive "example" and "examples"
OK - univention-directory-manager-rest OK - 73_udm-rest/01_openapi_validation OK - yaml OK - merged to 5.0-0
<https://errata.software-univention.de/#/?erratum=4.4x905>