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
Sometimes it happens that the swagger / open api schemes that are generated by the backend do not quite correspond to what the backend actually sends as a response.
Because of this, sometimes you need to help the typescript plugin correctly define/override types for models/operations, etc.
Changing the schema file itself is not an option because it itself is automatically generated on the backend side and is dynamically generated.
For example, after running Kubb generation with pluginTs I take this type:
type Generated = {
fieldA: number | string;
fieldB: string;
}
And I want to have override the type definition that will be generated for this type Generated.
For example, I want fieldA to be a string and not a number | string.
As I know, the Kubb already has this possibility for Zod plugin by mapping field inside plugin configurator, something like this:
@vlanemcev I added the following pr: #1075. The big difference with the Zod and Faker plugin is that you need to use the Factory functionality of TypeScript instead of returning string.
@vlanemcev Hi, that is on purpose right now because the API is still incomplete. I will probably make some changes before v3 and then make it an official feature.
What is the problem this feature would solve?
Sometimes it happens that the swagger / open api schemes that are generated by the backend do not quite correspond to what the backend actually sends as a response.
Because of this, sometimes you need to help the typescript plugin correctly define/override types for models/operations, etc.
Changing the schema file itself is not an option because it itself is automatically generated on the backend side and is dynamically generated.
For example, after running Kubb generation with pluginTs I take this type:
And I want to have override the type definition that will be generated for this type
Generated
.For example, I want
fieldA
to be astring
and not anumber | string
.As I know, the Kubb already has this possibility for Zod plugin by mapping field inside plugin configurator, something like this:
According to my feeling and already using generation in projects, I can say that this is the most requested feature.
External documents/projects?
No response
What is the feature you are proposing to solve the problem?
Add some mappers (similar to the Zod plugin) to be able to override generated typescript definitions.
What alternatives have you considered?
I have not found any alternative solutions to solve this other than defining the type on my side and using it.
The text was updated successfully, but these errors were encountered: