You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I'm having problems with the generated types against an API that uses readOnly=true, especially in conjunction with required=true.
The API publishes schemas like:
This schema is used as both RequestBody and RespondeBody in operations.
According to OpenAPI spec (AFAIU) readOnly=true means a client does not have to provide a property in a RequestBody, but it will be present in the ResponseBody.
typescript-angular generator produces a type like:
This type is great when a client handles the response from the server.
But if the client has to produce an instance of this type to create a request he has to fill redundant values:
constrequestBody: MyResource={inputField: 'A sensible value that the server will receive',outputField: 'A redundant value the server will ignore',}
Is your feature request related to a problem? Please describe.
I'm having problems with the generated types against an API that uses
readOnly=true
, especially in conjunction withrequired=true
.The API publishes schemas like:
This schema is used as both RequestBody and RespondeBody in operations.
According to OpenAPI spec (AFAIU)
readOnly=true
means a client does not have to provide a property in a RequestBody, but it will be present in the ResponseBody.typescript-angular
generator produces a type like:This type is great when a client handles the response from the server.
But if the client has to produce an instance of this type to create a request he has to fill redundant values:
Describe the solution you'd like
IMO the generator should produce two types:
MyResourceRequest
should be used as parameter in the corresponding service implementations instead ofMyResource
....of course this would be a breaking change. So maybe it would need a dedicated flag to activate this.
Describe alternatives you've considered
ATM I am circumventing the typescript compiler with hacky casts to get it done.
The text was updated successfully, but these errors were encountered: