open-api-spex / open_api_spex

Open API Specifications for Elixir Plug applications
Mozilla Public License 2.0
706 stars 183 forks source link

Accept read_write_scope from opts when calling cast functions directly #572

Closed albertored closed 4 months ago

albertored commented 10 months ago

read_write_scope is needed fort correctly handling readOnly and writeOnly required properties but it is non populated when calling directly cast functions. This adds that option.

There was also a problem when the property marked as readOnly or writeOnly is inside a reference. Before this change the check_required_fields function took as input the original ctx with properties not yet resolved. Now the ctx is updated with resolved properties and the required check works as expected. In doing so I also changed a little bit the Object module to make all functions modify and accept the same ctx making the code much more readable.

Fixes #499 and supersedes #513