1

I'm using a fairly standard ASP.NET API MVC template with Swashbuckle, which has been working well to produce Swagger UI documentation.

The API in question already had a few parameters specified as string types rather than a stronger built-in type.

E.g., in a model for Thing, a person is identified with

public string PersonId { get; set; }

In some cases, the base type works fine. In others I'm able to use an applicable DataType annotation to get the example to work well.

In the case of data types that aren't included among the DataType enum options, is there a good way to get Swashbuckle to tell Swagger UI to display something like "a6ba7a43-090d-4945-9be0-dc0bb2211dc0" instead of "string" in the "Example Value" for REST resources using Thing?

  • In OpenAPI, [UUIDs can be defined](https://stackoverflow.com/q/50204588/113116) as `type: string` + `format: uuid`. See if there's an annotation to specify the `format`. – Helen Dec 24 '20 at 07:08
  • Thanks, Helen. I found [this](https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.displayformatattribute?view=net-5.0), but it didn't seem to trigger any of the OpenAPI definitions. – Freddie O'Connell Dec 31 '20 at 03:55

0 Answers0