TypeScript Axios Output Does Not Reflect Server-Side DTO Attributes #5136
sensation61
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using NSwag to generate TypeScript (Axios) client code from a Swagger/OpenAPI specification. On the server side, I have Data Transfer Objects (DTOs) with attributes such as [StringLength], [Required], or custom attributes like [Transform]. However, these attributes are not reflected in the generated TypeScript code.
For example, consider the following server-side DTO:
C#
When generating TypeScript code, the attributes ([Required], [StringLength], [Transform]) are ignored, and the generated TypeScript class does not include any corresponding decorators or metadata:
Typescript
This lack of reflection makes it difficult to enforce validation rules or apply custom transformations on the client side.
Expected Behavior:
The attributes defined on the server-side DTOs should be reflected in the generated TypeScript code. For example:
Validation Attributes: Attributes like [Required] or [StringLength] should generate corresponding TypeScript decorators or comments.
Custom Attributes: Custom attributes like [Transform] should be included as metadata or decorators in the generated TypeScript code.
Example of expected output:
Beta Was this translation helpful? Give feedback.
All reactions