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

Allow independent readOnly flag by method #2649

Closed
captnCC opened this issue Jul 12, 2021 · 2 comments
Closed

Allow independent readOnly flag by method #2649

captnCC opened this issue Jul 12, 2021 · 2 comments

Comments

@captnCC
Copy link

captnCC commented Jul 12, 2021

I'm building specs for an JSON:API compliant API. The standard requires to include the entity ID in the request itself for the PATCH/UPDATE methods. Where as the ID field needs to be absent in the POST request.
With the current implementation, it is required to create 2 different schemas for POST and PATCH/UPDATE requests, only differentiated by the missing id property.

It would be great to be able to mark a property as readOnly by the used request method.

@MikeRalphson
Copy link
Member

See also #1497 (I'm hesitant to call this a direct duplicate because that issue took a long detour into JSON Schema land).

The fundamental issue is that JSON Schema (to which OAS delegates request/response modelling) does not have any concept of the context of a schema, such as it being a request or a response, or the HTTP method in use. In OAS 3.1 readOnly and writeOnly are, by default, annotations only and do not have any effect on validation, and the interaction with the required keyword was removed.

You could extend the schemaObject (in OAS 3.1+) with additional keywords or your own vocabulary, but presumably you would be looking for some tooling support?

@captnCC
Copy link
Author

captnCC commented Jul 13, 2021

Thanks! Well that issues sums up all I was looking for.

@captnCC captnCC closed this as completed Jul 13, 2021
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

No branches or pull requests

2 participants