Swashbuckle.AspNetCore icon indicating copy to clipboard operation
Swashbuckle.AspNetCore copied to clipboard

JObject types not represented as "object" in V2 spec

Open forteddyt opened this issue 3 years ago • 1 comments

I'm using v6.2.2 and swaggerOptions.SerializeAsV2 = true.

Consider a class

public class Foo {
  public JObject Bar { get; set; }
}

In the generated specification, I would expect the Bar property to be decorated with "type": "object", however it is not decorated with a "type" at all.

I that see #1766 removed the conversion of JObject to DataType.Object. I also see that GenerateSchema_GeneratesOpenSchema_IfDynamicJsonType explicitly tests to ensure that JObject types are not assigned a schema type. This change seems intentional... but why?

My current workaround is to include

swaggerGenOptions.MapType<JObject>(() => new OpenApiSchema { Type = "object" });

forteddyt avatar Sep 30 '21 23:09 forteddyt