Open ghost opened 4 years ago
Are you still using the Newtonsoft.Json serializer in ASP.NET Core 3.0?
Yes. I thought that's still required if you want some control over how the JSON is serialised. Or is there a way to get the Microsoft JSON serialiser to serialise enums as string?
Ok, so the problem occurs if you apply the [Required]
attribute to the property. Without it it shows up in the example with a textual value as it should. Granted, the required attribute doesn't really work for value types anyway, but it's still odd behavior.
When I set the StringEnumConverter setting (globally or on the enum itself via an attribute) the enum field will be missing from the example (for a method that takes a type with the enum as a property as argument) in the Swagger UI. It's visible in the schema just fine (with textual values). When the StringEnumConverter is removed, the example contains the enum field again (with numeric values).
I have NSwag.AspNetCore Version="13.1.2 and .net core 3 final. This used to work with asp.net core 2.