-
-
Notifications
You must be signed in to change notification settings - Fork 533
readOnly
and writeOnly
properties
#621
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
readOnly
and writeOnly
properties
#621
Conversation
Codecov Report
@@ Coverage Diff @@
## main #621 +/- ##
==========================================
- Coverage 93.52% 88.37% -5.16%
==========================================
Files 11 10 -1
Lines 510 413 -97
Branches 183 153 -30
==========================================
- Hits 477 365 -112
- Misses 32 48 +16
+ Partials 1 0 -1
Continue to review full report at Codecov.
|
This is really clever! I like your implementation. And the usage of a flag is great. I don’t see any conflict that could happen, since technically Bikeshedding a little, I was seeing if the OpenAPI spec allows unknown fields in the
What do you think about |
Adding the |
readOnly
and writeOnly
properties
Hi! What is the status of this PR? 😃 This is something that i'm looking for currently 🥇 |
It was all ready to merge and then nothing happened - I've moved on to other things but anyone is welcome to take over the work on it! |
May I ask is there any update on this PR? It's created almost one year ago... |
Waiting too((( |
Hi, Would it be possible to have updates on that great feature ? Is a merge planned soon ? :) Thanks all for your terrific work |
This is a basic implementation for #604
Globally this adds a comment to the end of fields that only exist in
readOnly
orwriteOnly
form, but it also adds an optional-s
/--splitSchema
flag that will instead create a slightly different structure.Data -
Without the flag -
With
-s
/--splitSchema
Not shown, but with the flag any request or response fields with a $ref will point at the correct interface (and anything outside of there will point at the base
schemas
) - Typescript will understand what to do if you point at those rather than the baseschemas
data (which can be used with typeguards for simpler source).There are minimal tests just to check it is working in general (something testing the cli flag would be far better).
There is also no checking of if it is required - that is fully up to the user.
Ideally a better solution would check if it is needed anywhere in the data tree, and then only use the split schema in that case, and keep it in the main
schemas
structure otherwise, however given the simple structure of the code this would add a lot of overhead, and would be best with a rewrite of the logic being used (not something I really want to think about given the amount of time it could take).Technically
readOnly
is supported in both v2 & v3, howeverwriteOnly
is only supported in v3 (similar to howadditionalProperties
gets a slightly different meaning between the versions) - yet another reasons to leave this behind a flag rather than as a default.