camaraproject / QualityOnDemand

Repository to describe, develop, document and test the QualityOnDemand API family
https://wiki.camaraproject.org/x/zwOeAQ
Apache License 2.0
38 stars 60 forks source link

Align error format with Commonalities guidelines #104

Closed jlurien closed 1 year ago

jlurien commented 1 year ago

As discussed in issue #97, we have to align current error model and examples to the guidelines:

hdamker commented 1 year ago

@jlurien Short question: is this PR intended for the minor fix release (which I want to close "now") or already for v0.9? As status is a required field, it might fit better into v0.9.0?

jlurien commented 1 year ago

@jlurien Short question: is this PR intended for the minor fix release (which I want to close "now") or already for v0.9? As status is a required field, it might fit better into v0.9.0?

0.9 definitely

hdamker commented 1 year ago

Added rewievers @eric-murray @patrice-conil as discussed within our call. @SfnUser please renew your review as well. Thanks!

patrice-conil commented 1 year ago

Hi @jlurien, Just a sample to illustrate my review ErrorInfo definition may look like this:

ErrorInfo: discriminator: type type: object required:

jlurien commented 1 year ago

Hi @jlurien, Just a sample to illustrate my review ErrorInfo definition may look like this:

ErrorInfo: discriminator: type type: object required: - type - status - code - message properties: type: description: The error class name type: "string" status: type: string pattern: "^[4-5][0-9]{2}$" description: HTTP status code returned along with this error response code: type: string description: Code given to this error message: type: string description: Detailed error description

Hi @patrice-conil, have you commented in the file? I guess this is about the problem you mentioned in the meeting with allOf for some openapi generator. ErrorModel is defined in the commonalities so any change should be aligned there. But in case we decide to define a discriminator to the base class, we could use the existent status or code for this, along with a mapping. Adding a new required property type is would repeat the same information.

Another alternative, as we are not reusing that much of the base ErrorModel, it is just to add the message property to all GenericXXXResponses and remove the allOf. I would not be surprised if some tool has problems as well with OAS3 mapping as that is not supported in legacy Swagger 2.

patrice-conil commented 1 year ago

Hi @jlurien, yes I commented in the file. and it is indeed linked to the problem that I mentioned last Friday. I agree with you, this mapping should do the trick... but it's quite new and probably not so well supported by generators. I think simplifying the generation of client side is one way to have a usable API. Perhaps we should spend more time documenting our validation rules than documenting sample responses to describe the behaviour of our proposal.

jlurien commented 1 year ago

Hi @jlurien, yes I commented in the file. and it is indeed linked to the problem that I mentioned last Friday. I agree with you, this mapping should do the trick... but it's quite new and probably not so well supported by generators. I think simplifying the generation of client side is one way to have a usable API. Perhaps we should spend more time documenting our validation rules than documenting sample responses to describe the behaviour of our proposal.

I only see the latest comment about Generic404. If mapping is not well supported, I prefer to remove the allOf that adding an additional property @type in the API spec for all errors to overcome the limitation, as that would add too much redundancy in the response:

HTTP 404
{ 
  "@type": "Generic404",
  "status": "404"
  "code": "NOT_FOUND",
  "message": "Session not found"
}
jlurien commented 1 year ago

Please review the latest version. Some comments:

hdamker commented 1 year ago

LGTM, just asking @patrice-conil @maxl2287 @eric-murray for a final review (and closing remarks for the open conversations).

eric-murray commented 1 year ago

Is it intended to approve and merge this PR before Commonalities Issue #151 is resolved?

jlurien commented 1 year ago

Is it intended to approve and merge this PR before Commonalities Issue #151 is resolved?

We could merge it as it is now and later update the $refs to the right schemas, and remove the unused ones. Indeed I have intentionally left the ErrorInfo schema even if it is currently unused.