-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem response for (non-schema) input validation #74
Comments
Related: also found that "422 Unprocessable Entity" is sometimes used for OpenAPI validation errors:
422 is defined in the WebDAV spec as:
|
Flanders is using a nested problem structure to represent this case, see Because the same requirements for input validation errors exist as generic problems, this would be interesting. The example from the issue description would then become: type: urn:problem-type:belgif:badRequest
href: https://belgif.be/problems/badRequest
title: Bad Request
status: 400
detail: "The input message is incorrect"
instance: urn:uuid:123456-1234-1235-4567489798
issues: #naming? currently invalidParams. Reuse as warnings in normal response?
- type: urn:problem-type:belgif:input-validation:schemaViolation #mandatory
href: https://belgif.be/problems/schemaViolation #dereferencable
title: "Input isn't valid with respect to schema" #mandatory?
# no status property for these nested problems
detail: enterpriseNumber abc should be numeric #recommended, if more detail can be provided
# following additional properties are standardized but optional
in: path
name: enterpriseNumber
value: abc
- type: urn:problem-type:cbss:input-validation:replacedSsin
href: https://api.ksz-bcss.fgov.be/problems/replacedSsin
title: "SSIN has been replaced. Use new ssin."
detail: "SSIN 12345678901 has been replaced by 23456789012"
in: body
name: parent[0].ssin
value: "12345678901"
replacedBy: "23456789012"
- type: urn:problem-type:belgif:input-validation:invalidPeriod
href: https://belgif.be/problems/invalidPeriod
title: period is invalid
detail: endDate should be after startDate
in: body
name: period
value:
startDate: "2020-12-31"
endDate: "2020-01-01"
- type: urn:problem-type:cbss:input-validation:invalidSsin
href: https://api.ksz-bcss.fgov.be/problems/invalidSsin
title: "There is no person with the given SSIN"
in: path
name: ssin
value: "12345678911" Open questions:
|
REST WG decided to:
|
Added InputValidationProblem and InputValidationIssue in PRs to openapi-problem (belgif/openapi-problem#4 - OpenAPI v3 only, I'll add Swagger once reviewed) and in the guide (#87) Notes:
|
conclusions REST WG January 2022:
|
PRs have been updated and are ready for review: |
* add type for input validation problem (belgif/rest-guide#74), * replace and deprecate InvalidParam/InvalidParamProblem
The BadRequest problem type is now specific to input schema validation in the REST guide, i.e. used when "The consumer request is not conform to the Swagger specification of the API."
There is also a need to standardize on application-level input validation errors; e.g.:
proposal
Example:
rationale
Difference with resourceNotFound
When a resource id is not found, resourceNotFound problem should be used instead of BadRequestProblem.
This also means that the invalid parameters in a resourceNotFound problem should refer to path params only . We could explicitly document this difference.
E.g.
The text was updated successfully, but these errors were encountered: