rokwire / core-building-block

Building block which handles core functions for the Rokwire platform - users, accounts, profiles, organizations, authentication and authorization.
Apache License 2.0
3 stars 2 forks source link

[BUG] Ignore readOnly fields during validation #641

Closed shurwit closed 1 year ago

shurwit commented 1 year ago

Describe the bug It seems like the enforcement of the readOnly flag has changed during validation. In the past, it was not enforced that the request does not contain a field marked with readOnly, but now we get the following error:

{"message":"Error validating request: request body has an error: doesn't match schema #/components/schemas/Profile: readOnly property \"id\" in request","status":"bad-request"}

This breaks the backwards compatibility of the Core with old clients that were sending requests with these readOnly fields which were previously being ignored.

To Reproduce Steps to reproduce the behavior:

  1. Send request to PUT /services/account/profile with id field set
  2. See validation error above.

Expected behavior If a readOnly field is sent in a request, it should simply be ignored and discareded rather than failing the whole request. It seems like we can achieve this by setting the ExcludeReadOnlyValidations flag in the openapi3filter.Options in web/adapter.go:validateRequest.