-
Notifications
You must be signed in to change notification settings - Fork 8
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
Is it possible to support Optional<string> #133
Comments
The class First, Tapper needs to support user-defined generics types. This feature could be done with time. Second, you must implement a custom JsonConverter to get the desired JSON string. And since custom JsonConverter is highly flexible, it is difficult for Tapper to support it. |
How about implement attribute, that force emit TypeScript type. Input// UpdateUserRequest.cs
[TranspilationSource]
class UpdateUserRequest
{
public int UserId { get; set; }
// [TranspilationSourceForceType(Type = TypeScriptType.String | TypeScriptType.Null | TypeScriptType.Undefined)]
[TranspilationSourceForceType(TypeString = "(string | undefined)", Nullable = true)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public Optional<string?> StatusMessage { get; set; }
} Output// UpdateUserRequest.ts
/** Transpiled from UpdateUserRequest */
export type ConfigInfo = {
/** Transpiled from uint */
userId: number;
/** Transpiled from unknown(Defined by user) */
statusMessage?: (string | undefined);
} |
It seems like a good idea. |
I would also like to be able to specify the explicit output type. I've got a struct that wraps a string, when serialized it's just turned into a string so I'd like to represent that in TS |
Server code
HTTP Request example
I want to know JSON string parameter is
null
orundefined
.For example,
{ "user_id": 1, "status_message": "I'm fine" }
I'm fine
{ "user_id": 1, "status_message": "" }
{ "user_id": 1, "status_message": null }
null
{ "user_id": 1 }
But, Tapper is not supported it.
Could you support it?
Or, do you have some other good ideas?
Ref:
The text was updated successfully, but these errors were encountered: