DOMjudge / domjudge

DOMjudge programming contest jury system
https://www.domjudge.org
GNU General Public License v2.0
712 stars 250 forks source link

OpenAPI schema validation failed #2355

Closed baierjan closed 6 months ago

baierjan commented 6 months ago

Description of the problem

The OpenAPI schema provided by http://domjudge/api/doc.json is not valid.

Your environment

Steps to reproduce

  1. Install any DOMjudge version including 1730c9d9703be4b133224bdae1dc51fab974be03
  2. Try to validate doc.json (for example with https://apitools.dev/swagger-parser/online/)

Expected behaviour

Validation succeeds.

Actual behaviour

Validation failed, API is unusable with tools which validates schema.

Any other information that you want to share?

Git bisect identified 1730c9d9703be4b133224bdae1dc51fab974be03 as the first bad commit

Swagger schema validation failed.
  #/paths/~1api~1v4~1judgehosts~1update-judging~1{hostname}~1{judgetaskid}/put/parameters/1/schema/type must be equal to one of the allowed values
  #/paths/~1api~1v4~1judgehosts~1update-judging~1{hostname}~1{judgetaskid}/put/parameters/1/schema must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1update-judging~1{hostname}~1{judgetaskid}/put/parameters/1/schema must match exactly one schema in oneOf
  #/paths/~1api~1v4~1judgehosts~1update-judging~1{hostname}~1{judgetaskid}/put/parameters/1 must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1update-judging~1{hostname}~1{judgetaskid}/put/parameters/1 must match exactly one schema in oneOf
  #/paths/~1api~1v4~1judgehosts~1add-debug-info~1{hostname}~1{judgeTaskId}/post/parameters/1/schema/type must be equal to one of the allowed values
  #/paths/~1api~1v4~1judgehosts~1add-debug-info~1{hostname}~1{judgeTaskId}/post/parameters/1/schema must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1add-debug-info~1{hostname}~1{judgeTaskId}/post/parameters/1/schema must match exactly one schema in oneOf
  #/paths/~1api~1v4~1judgehosts~1add-debug-info~1{hostname}~1{judgeTaskId}/post/parameters/1 must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1add-debug-info~1{hostname}~1{judgeTaskId}/post/parameters/1 must match exactly one schema in oneOf
  #/paths/~1api~1v4~1judgehosts~1add-judging-run~1{hostname}~1{judgeTaskId}/post/parameters/1/schema/type must be equal to one of the allowed values
  #/paths/~1api~1v4~1judgehosts~1add-judging-run~1{hostname}~1{judgeTaskId}/post/parameters/1/schema must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1add-judging-run~1{hostname}~1{judgeTaskId}/post/parameters/1/schema must match exactly one schema in oneOf
  #/paths/~1api~1v4~1judgehosts~1add-judging-run~1{hostname}~1{judgeTaskId}/post/parameters/1 must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1add-judging-run~1{hostname}~1{judgeTaskId}/post/parameters/1 must match exactly one schema in oneOf

Error: Swagger schema validation failed.
  #/paths/~1api~1v4~1judgehosts~1update-judging~1{hostname}~1{judgetaskid}/put/parameters/1/schema/type must be equal to one of the allowed values
  #/paths/~1api~1v4~1judgehosts~1update-judging~1{hostname}~1{judgetaskid}/put/parameters/1/schema must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1update-judging~1{hostname}~1{judgetaskid}/put/parameters/1/schema must match exactly one schema in oneOf
  #/paths/~1api~1v4~1judgehosts~1update-judging~1{hostname}~1{judgetaskid}/put/parameters/1 must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1update-judging~1{hostname}~1{judgetaskid}/put/parameters/1 must match exactly one schema in oneOf
  #/paths/~1api~1v4~1judgehosts~1add-debug-info~1{hostname}~1{judgeTaskId}/post/parameters/1/schema/type must be equal to one of the allowed values
  #/paths/~1api~1v4~1judgehosts~1add-debug-info~1{hostname}~1{judgeTaskId}/post/parameters/1/schema must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1add-debug-info~1{hostname}~1{judgeTaskId}/post/parameters/1/schema must match exactly one schema in oneOf
  #/paths/~1api~1v4~1judgehosts~1add-debug-info~1{hostname}~1{judgeTaskId}/post/parameters/1 must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1add-debug-info~1{hostname}~1{judgeTaskId}/post/parameters/1 must match exactly one schema in oneOf
  #/paths/~1api~1v4~1judgehosts~1add-judging-run~1{hostname}~1{judgeTaskId}/post/parameters/1/schema/type must be equal to one of the allowed values
  #/paths/~1api~1v4~1judgehosts~1add-judging-run~1{hostname}~1{judgeTaskId}/post/parameters/1/schema must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1add-judging-run~1{hostname}~1{judgeTaskId}/post/parameters/1/schema must match exactly one schema in oneOf
  #/paths/~1api~1v4~1judgehosts~1add-judging-run~1{hostname}~1{judgeTaskId}/post/parameters/1 must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1add-judging-run~1{hostname}~1{judgeTaskId}/post/parameters/1 must match exactly one schema in oneOf

    at o (https://apitools.dev/swagger-parser/online/js/bundle.min.js:1:95564)
    at https://apitools.dev/swagger-parser/online/js/bundle.min.js:29:45042

SyntaxError: Swagger schema validation failed.
  #/paths/~1api~1v4~1judgehosts~1update-judging~1{hostname}~1{judgetaskid}/put/parameters/1/schema/type must be equal to one of the allowed values
  #/paths/~1api~1v4~1judgehosts~1update-judging~1{hostname}~1{judgetaskid}/put/parameters/1/schema must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1update-judging~1{hostname}~1{judgetaskid}/put/parameters/1/schema must match exactly one schema in oneOf
  #/paths/~1api~1v4~1judgehosts~1update-judging~1{hostname}~1{judgetaskid}/put/parameters/1 must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1update-judging~1{hostname}~1{judgetaskid}/put/parameters/1 must match exactly one schema in oneOf
  #/paths/~1api~1v4~1judgehosts~1add-debug-info~1{hostname}~1{judgeTaskId}/post/parameters/1/schema/type must be equal to one of the allowed values
  #/paths/~1api~1v4~1judgehosts~1add-debug-info~1{hostname}~1{judgeTaskId}/post/parameters/1/schema must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1add-debug-info~1{hostname}~1{judgeTaskId}/post/parameters/1/schema must match exactly one schema in oneOf
  #/paths/~1api~1v4~1judgehosts~1add-debug-info~1{hostname}~1{judgeTaskId}/post/parameters/1 must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1add-debug-info~1{hostname}~1{judgeTaskId}/post/parameters/1 must match exactly one schema in oneOf
  #/paths/~1api~1v4~1judgehosts~1add-judging-run~1{hostname}~1{judgeTaskId}/post/parameters/1/schema/type must be equal to one of the allowed values
  #/paths/~1api~1v4~1judgehosts~1add-judging-run~1{hostname}~1{judgeTaskId}/post/parameters/1/schema must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1add-judging-run~1{hostname}~1{judgeTaskId}/post/parameters/1/schema must match exactly one schema in oneOf
  #/paths/~1api~1v4~1judgehosts~1add-judging-run~1{hostname}~1{judgeTaskId}/post/parameters/1 must have required property '$ref'
  #/paths/~1api~1v4~1judgehosts~1add-judging-run~1{hostname}~1{judgeTaskId}/post/parameters/1 must match exactly one schema in oneOf

    at Function.o [as syntax] (https://apitools.dev/swagger-parser/online/js/bundle.min.js:1:95564)
    at validateSchema (https://apitools.dev/swagger-parser/online/js/bundle.min.js:1:6322)
    at SwaggerParser.validate (https://apitools.dev/swagger-parser/online/js/bundle.min.js:1:3391)
nickygerritsen commented 6 months ago

Thanks for reporting, that tool is useful and helped me to quickly fix this.