Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwaggerUI not displaying Model Schema

I have a C# Web.API project with Swagger and Swashbuckle.

I have a model:

    public class TimeZoneName
    {
        public string zoneName { get; }
    }

I have a controller with methods:

public string GetLocalTimeByTimeZone(TimeZoneName timezone)
{
     //Stuff Happens here
     return "12:00";
}

During a build I was expecting Swashbuckle to generate a SwaggerUI that shows a JSON representation of the TimeZoneName type in the UI.

That didn't occur.

How do I set up my methods and models so that the Model Schema is shown in the SwaggerUI?

like image 207
Richard210363 Avatar asked Oct 24 '25 08:10

Richard210363


1 Answers

If you have a created a new Model, try placing getter and setter methods.

public class MyNewModel
{
  public string Member1 {get; set;}
}

Without them the schema is not automatically detected

like image 77
Ashique razak Avatar answered Oct 27 '25 02:10

Ashique razak