Open uniqueg opened 3 years ago
I'm of course aware that all of the proposed solutions constitute breaking changes that would require any existing implementations to update their code, so I am not hoping for an immediate fix. But as I had to switch off automatic response validation in my framework for that reason (was too lazy to implement a custom validator), I thought I'd put it out there to be taken care with the next bunch of breaking changes.
Perhaps related: https://github.com/ga4gh/workflow-execution-service-schemas/pull/172
Description
There is a minor inconsistency in the definition of the
GET /tasks
endpoint: theresponses
section for a200
response expects atesListTasksResponse
object, which is itself an array oftesTask
objects. Now,tesTask
objects require the propertyexecutors
, an object of typetesExecutor
. But thedescription
of theview
query parameter in the same endpoint definition states that for view typeMINIMAL
only theTask.id
(should perhaps betesTask.id
) andTask.status
(tesTask.status
) are to be returned. This makes automatic schema-based validation of the response impossible for that endpoint.Proposed solution
This is perhaps not quite easy to resolve, especially in Swagger 2.0, which does not allow defining different schemas for a response body. In OpenAPI 3.0, the
anyOf
andoneOf
keywords can be used for that purpose (see here, here and here), although, unfortunately, not conditionally dependent of a request parameter (see here, bottom of page).Perhaps the cleanest thing to do will be to define different schemas for
POST
ing andGET
ting tasks, then set different requirements for the latter (e.g.,tesTaskResponse.id
andtesTaskResponse.state
, but nottesTaskResponse.executors
). This would also allow thePOST
-specific schema to get rid of theid
property, which is anyway pointless to include, as it is, according to its description, expected to be generated by the implementation. Settingid
as required in the response will allow a client or automatic validation framework in the service to ensure that the service, in fact, did generate (and store!) a task ID and avoid potentially empty entries in aMINIMAL
representation of the listed tasks (and elsewhere). Finally, once switching to OpenAPI 3.0, thetesTaskResponse
schema could be decomposed into separate subschemas for the different views.Other possible solutions:
executors
an optional parameter intes.Task
executors
part of theMINIMAL
response