Skip to content

[BUG][C#] Dto properties can't be made non-nullable #2269

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

Open
sturlath opened this issue Feb 28, 2019 · 4 comments
Open

[BUG][C#] Dto properties can't be made non-nullable #2269

sturlath opened this issue Feb 28, 2019 · 4 comments

Comments

@sturlath
Copy link

sturlath commented Feb 28, 2019

Description

If I try to generate aspnetcore dto's the nullable = false is alwasy ignored and all the properties created are created nullable.

If I have nullable field in my api.yaml file (skipping allot for brevity)

        expireDateOfOffer:
          type: string
          format: date
          nullable: false (toggling/skipping this doesn't change anything! )

and then run the following

java -DdebugModels -jar openapi-generator-cli-4.0.0-20181226.105224-120.jar generate -i api.yaml -g aspnetcore -o c:\Temp -t templates\aspnetcore\controller -Dapis

I get

        /// <summary>
        /// Gets or Sets ExpireDateOfOffer
        /// </summary>
        [DataMember(Name="expireDateOfOffer")]
        public DateTime? ExpireDateOfOffer { get; set; }

I can't seem to get rid off the ? (nullable) after the DateTime.
I don't want it to be nullable!

openapi-generator version

4.0.0-20181226.105224-120

Command line used for generation

java -DdebugModels -jar openapi-generator-cli-4.0.0-20181226.105224-120.jar generate -i api.yaml -g aspnetcore -o c:\Temp -t templates\aspnetcore\dtos -Dapis

Steps to reproduce

Run the previous command line on a yaml file with property you want to have as non-nullable and see if you can make it so.

Related issues/PRs

Couldn't find anything except maybe this one

@auto-labeler
Copy link

auto-labeler bot commented Feb 28, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@sturlath sturlath changed the title [BUG][C#] [BUG][C#] Dto properties can't be made non-nullable Feb 28, 2019
@wing328
Copy link
Member

wing328 commented Mar 1, 2019

@sturlath thanks for reporting the issue.

I added nullable support to csharp before. Can you give it a try to see if it works for you? if it does, we can port the enhancement to the aspnetcore generator.

@sturlath
Copy link
Author

sturlath commented Mar 1, 2019

Ahhh in this one #1819 @wing328? I totally missed it. Thought I had the newest one. I'll try out v4.0.0-beta2 release tonight and let you know if it worked.

@wing328
Copy link
Member

wing328 commented Mar 1, 2019

Yup but I was incorrectly saying the csharp generator had the enhancement. It should be thecsharp-netcore with better nullable support.

There's also a PR to further improve the csharp-netcore: #2187. Please check it out if you've any feedback.

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

No branches or pull requests

2 participants