-
-
Notifications
You must be signed in to change notification settings - Fork 533
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
introducing OmitReadonly
type to resolve required + readonly/writeonly properties
#1145
base: main
Are you sure you want to change the base?
Conversation
OmitReadonly
typeOmitReadonly
type to solve required + readonly/writeonly properties
cd559d1
to
53fe4c4
Compare
OmitReadonly
type to solve required + readonly/writeonly propertiesOmitReadonly
type to resolve required + readonly/writeonly properties
- it omits readonly properties from an object - it infers the original type in case of passed type is not an `object` - it is applied to parameters for "POST", "PUT" or "PATCH" operations and only if it is a "reference" type
53fe4c4
to
b5f7181
Compare
Please change the |
We desperately need this. =) @tiholic Any chance we can get the type import fixed? I'm happy to help. Let me know if I can support in any way. |
@aaronschif @jeremyzahner import converted to a type import @ferdikoomen I believe this can be prioritised now? |
@tiholic @aaronschif @demo-exe for the time being, you can use https://www.npmjs.com/package/@jshmrtn/openapi-typescript-codegen until @ferdikoomen can have a look. |
Any chance to get this merged? |
@tiholic this is interesting. It appears that We are facing almost the opposite problem - because these |
Bumping @giopetris's request – would it be possible to get this merged? |
@tajnymag do you mind opening an issue in our repository? I'd like to solve this with write-only too, this pull request seems to work only for read-only |
as this repository is only used for our ts code gen
updated org name
resolved dependabot updates
closes #432
Pretext:
Say there are 2 properties to a model
id
andname
. Creating a model instance (POST) requires onlyname
to be posted andid
would be a readonly property. Generated type would beTo create an instance of Model for POST, we should be able to pass
{name: "john"}
Generated services look like:
createMode(model: Model) {...}
, which do not accept an object with justname
property.Solution:
This PR aims to solve this issue by adding a type modifier, so effectively generated service code looks like:
createMode(model: OmitReadOnly<Model>) {...}
which strips off any readonly properties and allows passing an object with just thename
property.More about
OmitReadonly
:object
Implementation based on #432 (comment) by @sweethuman