azure-functions-openapi-extension icon indicating copy to clipboard operation
azure-functions-openapi-extension copied to clipboard

Question - Should enums really generate with a default?

Open dandenton opened this issue 10 months ago • 0 comments

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.

dandenton avatar Dec 16 '24 15:12 dandenton