Skip to content

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

@dandenton

Description

@dandenton

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions