@@ -73,34 +73,47 @@ private static void ProcessProduces(MapNode mapNode, OpenApiResponse response, P
7373 }
7474
7575 var produces = context . GetFromTempStorage < List < string > > ( TempStorageKeys . OperationProduces )
76- ?? new List < string > { "application/octet-stream" } ;
76+ ?? context . GetFromTempStorage < List < string > > ( TempStorageKeys . GlobalProduces ) ;
7777
78- var schema = context . GetFromTempStorage < OpenApiSchema > ( TempStorageKeys . ResponseSchema , response ) ;
79-
80- foreach ( var produce in produces )
78+ if ( produces != null )
8179 {
80+ var schema = context . GetFromTempStorage < OpenApiSchema > ( TempStorageKeys . ResponseSchema , response ) ;
8281
83- if ( response . Content . ContainsKey ( produce ) && response . Content [ produce ] != null )
84- {
85- if ( schema != null )
86- {
87- response . Content [ produce ] . Schema = schema ;
88- ProcessAnyFields ( mapNode , response . Content [ produce ] , _mediaTypeAnyFields ) ;
89- }
90- }
91- else
82+ if ( produces . Count == 0 && schema != null )
9283 {
9384 var mediaType = new OpenApiMediaType
9485 {
9586 Schema = schema
9687 } ;
9788
98- response . Content . Add ( produce , mediaType ) ;
89+ response . Content . Add ( string . Empty , mediaType ) ;
9990 }
100- }
10191
102- context . SetTempStorage ( TempStorageKeys . ResponseSchema , null , response ) ;
103- context . SetTempStorage ( TempStorageKeys . ResponseProducesSet , true , response ) ;
92+ foreach ( var produce in produces )
93+ {
94+
95+ if ( response . Content . ContainsKey ( produce ) && response . Content [ produce ] != null )
96+ {
97+ if ( schema != null )
98+ {
99+ response . Content [ produce ] . Schema = schema ;
100+ ProcessAnyFields ( mapNode , response . Content [ produce ] , _mediaTypeAnyFields ) ;
101+ }
102+ }
103+ else
104+ {
105+ var mediaType = new OpenApiMediaType
106+ {
107+ Schema = schema
108+ } ;
109+
110+ response . Content . Add ( produce , mediaType ) ;
111+ }
112+ }
113+
114+ context . SetTempStorage ( TempStorageKeys . ResponseSchema , null , response ) ;
115+ context . SetTempStorage ( TempStorageKeys . ResponseProducesSet , true , response ) ;
116+ }
104117 }
105118
106119 private static void LoadExamples ( OpenApiResponse response , ParseNode node )
0 commit comments