File tree Expand file tree Collapse file tree 1 file changed +32
-6
lines changed
src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator Expand file tree Collapse file tree 1 file changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -49,9 +49,22 @@ private static IOpenApiAny CreateOpenApiArray(JsonElement jsonElement)
4949
5050 foreach ( var item in jsonElement . EnumerateArray ( ) )
5151 {
52- var json = item . ValueKind == JsonValueKind . String
53- ? $ "\" { item } \" "
54- : item . ToString ( ) ;
52+ string json ;
53+ switch ( item . ValueKind )
54+ {
55+ case JsonValueKind . String :
56+ json = $ "\" { item } \" ";
57+ break ;
58+ case JsonValueKind . True :
59+ json = "true" ;
60+ break ;
61+ case JsonValueKind . False :
62+ json = "false" ;
63+ break ;
64+ default :
65+ json = item . ToString ( ) ;
66+ break ;
67+ }
5568
5669 openApiArray . Add ( CreateFromJson ( json ) ) ;
5770 }
@@ -65,9 +78,22 @@ private static IOpenApiAny CreateOpenApiObject(JsonElement jsonElement)
6578
6679 foreach ( var property in jsonElement . EnumerateObject ( ) )
6780 {
68- var valueAsJson = ( property . Value . ValueKind == JsonValueKind . String )
69- ? $ "\" { property . Value } \" "
70- : property . Value . ToString ( ) ;
81+ string valueAsJson ;
82+ switch ( property . Value . ValueKind )
83+ {
84+ case JsonValueKind . String :
85+ valueAsJson = $ "\" { property . Value } \" ";
86+ break ;
87+ case JsonValueKind . True :
88+ valueAsJson = "true" ;
89+ break ;
90+ case JsonValueKind . False :
91+ valueAsJson = "false" ;
92+ break ;
93+ default :
94+ valueAsJson = property . Value . ToString ( ) ;
95+ break ;
96+ }
7197
7298 openApiObject . Add ( property . Name , CreateFromJson ( valueAsJson ) ) ;
7399 }
You can’t perform that action at this time.
0 commit comments