Skip to content
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

Generation of nullable required property #39

Open
christoph-feb22 opened this issue Jun 28, 2022 · 1 comment
Open

Generation of nullable required property #39

christoph-feb22 opened this issue Jun 28, 2022 · 1 comment

Comments

@christoph-feb22
Copy link

Hi Zaid,

I have an API definition which contains a model with an required property with the datatype nullable string.
Hawaii generates the type as string. I expect it to be a string option.

required = parameter.Required || not nullable

As I understand it correct, this line is responsible if a type is optional or not.
Maybe the following replacement is an option?

parameter.Required && not nullable

Maybe there is an reason for only checking the required property?

Thanks in advance.

@Zaid-Ajaj
Copy link
Owner

Hi there @christoph-feb22, thanks for filing the issue!

I believe the reason the generated type is string and not string option is because when you use None as the value for your property, Fable generates undefined which is then removed from the serialized JSON AFAIK but I would need to double check this.

If the generated type is string and it is nullable, you can simply use null for the value at runtime, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants