Sage-Bionetworks / rocc-schemas

OpenAPI specification of the Registry of Open Community Challenges
Apache License 2.0
0 stars 0 forks source link

Make requestBody required #91

Closed tschaffter closed 3 years ago

tschaffter commented 3 years ago

Fix issue raised here.

tschaffter commented 3 years ago

There are several solutions:

  1. Modify the schema to mention that the requestBody of paths is required. The OpenAPI Generator will likely use this information when generating the clients and inform the user that a request body object must be specified, even if it's an empty object.
  2. Keep the schema as it is but modify the ROCC API service implementation so that it basically comply with optional request body, i.e. the API service must not return an error if the request body is missing for endpoint that have an optional request body.

My preference goes to Option 1. This solution increases the consistency of the API as both the user and the developer know that a request body object must always be specified. The developer can then validate this object against a model. The alternative is more complicated: first the developer has to look at the schema to check if the request body is required or not, and based on the answer implement an if condition in the controller of the API service.

Note that Option 1 is the solution adopted by Google Healthcare API. Moreover, we had a similar discussion a couple of months ago with @vpchung and @thomasyu888 about the returned object of DELETE operations. We decided to always return an empty object rather than nothing. The logic was the same and the alternative would have been that both the user and the developer would have to look closer at the schema to know if a given endpoint should return an object or not. Always returning an object makes our API more consistent.

Tagging @rrchai

Action item

tschaffter commented 3 years ago

Done