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

Question - Should enums really generate with a default? #679

Open
dandenton opened this issue Dec 16, 2024 · 0 comments
Open

Question - Should enums really generate with a default? #679

dandenton opened this issue Dec 16, 2024 · 0 comments

Comments

@dandenton
Copy link

Why does an enum property get a default but other non-nullable types do not?

public Country? Country { get; set; }
public int Version { get; set; }

Will generate as

"country": {
  "format": "int32",
  "default": 1,
  "enum": [
	1,
	2
  ],
  "type": "integer"
},
"version": {
  "format": "int32",
  "type": "integer"
},

This resulted in a hard to detect issue once we generated an API client based on the swagger file since the client's model generated with the default specified so even if the API returned a null value the model would still have a value.

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

1 participant