We use swagger to test our rest APIs. I have a json object that comes back with the following value:
...
"MyValue" : 243400.000000
}
However when it is displayed thru swagger it shows as this:
...
"MyValue" : 243400
}
In my controller I put a break point on the return statement and I can verify that in dResult that "MyValue" is 243400.000000, but swagger display does not reflect this. The controller code is below:
...
var dresult = JSON.JsonConvert.DeserializeObject(result, new JSON.JsonSerializerSettings
{
FloatParseHandling = JSON.FloatParseHandling.Decimal
});
return Request.CreateResponse(HttpStatusCode.OK, dresult, JsonMediaTypeFormatter.DefaultMediaType);
Could this be a swagger configuration issue? I have not found anything yet to point to it. Any help would be appreciated.
Original swagger config:
using System.Web.Http;
using WebActivatorEx;
using MyService.WebApi;
using Swashbuckle.Application;
using Swashbuckle.Swagger;
[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]
namespace MyService.WebApi
{
public class SwaggerConfig
{
public static void Register()
{
var thisAssembly = typeof(SwaggerConfig).Assembly;
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "MyService.WebApi");
c.IncludeXmlComments(string.Format(@"{0}\bin\MyService.WebApi.XML", System.AppDomain.CurrentDomain.BaseDirectory));
c.UseFullTypeNameInSchemaIds();
c.DescribeAllEnumsAsStrings();
})
.EnableSwaggerUi(c =>
{
c.DisableValidator();
});
}
}
}