Skip to content
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

Remove read only and write only fields #895

Merged
merged 2 commits into from Jan 31, 2024

Conversation

pilerou
Copy link
Contributor

@pilerou pilerou commented Jan 30, 2024

To meet the requirements of ticket #627, the following is proposed:

  • If validateRequest.removeAdditional is equal to true or 'all or 'failing then the fields received in request which are noted as readonly are removed before entering the route
  • If validateResponse.removeAdditional is equal to true or all or failing then the writeonly fields present in the response object are removed from the return flow before sending the response to the client.

ajv/index.ts had been modified to do this behaviour.
2 unit tests had been created in order to check the behaviour when removeAdditional : true
Previous unit tests still works as before.

- requests if ``validateRequest.removeAdditional`` configuration equals ``true`` or ```'all'`` or ``'failing'``
- responses if ``validateResponse.removeAdditional`` configuration equals ``true`` or ```'all'`` or ``'failing'``
No changes if ``validateRequest = true``, ``validateResponse = true``, ``validateRequest.removeAdditional : false``, ``validateResponse.removeAdditional : false``

Unit tests added to check the behaviour with removeAdditional : true. Fields removed and no error in response.
Copy link
Owner

@cdimascio cdimascio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fantastic. thank you @pilerou !

@cdimascio cdimascio merged commit 97617fd into cdimascio:master Jan 31, 2024
5 checks passed
@cdimascio
Copy link
Owner

cdimascio commented Feb 1, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants