Hello, I have my own controllers defined in Ocelot ApiGateway and faced problem described in issue title. I encounter this problem only when I use the controller methods that are defined in Ocelot APIGateway project. Models from proxied services return values for enum as strings. The enum values on the swagger specification page for the Ocelot Api Gateway also have string values.
Is there any way to correct this behavior?
Startup.cs
services.AddControllers()
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase));
});
services.AddOcelot(Configuration).AddPolly();
services.AddSwaggerForOcelot(Configuration);
services.AddSwaggerGen(c =>
{
c.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme
{
Description = "JWT Authorization header using the Bearer scheme. Example: Bearer \"{token}\"",
In = ParameterLocation.Header,
Name = HeaderNames.Authorization,
Type = SecuritySchemeType.Http,
Scheme = JwtBearerDefaults.AuthenticationScheme
});
c.OperationFilter<SecurityRequirementsOperationFilter>();
c.DescribeAllParametersInCamelCase();
c.SupportNonNullableReferenceTypes();
c.UseAllOfToExtendReferenceSchemas();
c.EnableAnnotations();
c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "ApiGateway.Server.xml"), true);
c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "ApiGateway.DataTransfer.Http.xml"));
});
Hello, I have my own controllers defined in Ocelot ApiGateway and faced problem described in issue title. I encounter this problem only when I use the controller methods that are defined in Ocelot APIGateway project. Models from proxied services return values for enum as strings. The enum values on the swagger specification page for the Ocelot Api Gateway also have string values.
Is there any way to correct this behavior?
Startup.cs
Routes/ocelot.SwaggerEndPoints.json
Values for enum in the swagger specification.
The result of executing the endpoint in Swagger As you can see in Reponse Body enum value is integer, but in Example Value is string.