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

correctly interpret readOnly / writeOnly #157

Open
mnahkies opened this issue Apr 27, 2024 · 0 comments
Open

correctly interpret readOnly / writeOnly #157

mnahkies opened this issue Apr 27, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mnahkies
Copy link
Owner

so this is embarrassing, I've interpreted readOnly as being equivalent to the typescript readonly modifier.

however, the specification defines this, and it's friend writeOnly quite differently:

readOnly

Relevant only for Schema "properties" definitions. Declares the property as "read only". This means that it MAY be sent as part of a response but SHOULD NOT be sent as part of the request. If the property is marked as readOnly being true and is in the required list, the required will take effect on the response only. A property MUST NOT be marked as both readOnly and writeOnly being true. Default value is false.

writeOnly

Relevant only for Schema "properties" definitions. Declares the property as "write only". Therefore, it MAY be sent as part of a request but SHOULD NOT be sent as part of the response. If the property is marked as writeOnly being true and is in the required list, the required will take effect on the request only. A property MUST NOT be marked as both readOnly and writeOnly being true. Default value is false.

Eg: these serve to allow models to express a different interface for the different CRUD operations - without needing separate CreateUpdateX / X models as I've normally done...

fixing this will be a breaking change, and probably quite challenging to implement. It's unclear whether it's best to synthesis separate XWrite / XRead models, or use an Omit / Pick type approach.

note: 3.1 dropped these from the spec, deferring to the JSON schema definition. should consider whether we need to implement it differently for 3.1 vs 3.0, or just follow 3.1.

references

@mnahkies mnahkies added the bug Something isn't working label Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant