@@ -13,6 +13,10 @@ namespace Microsoft.OpenApi.Models
13
13
/// </summary>
14
14
public class OpenApiEncoding : IOpenApiSerializable , IOpenApiExtensible
15
15
{
16
+ /// <summary>
17
+ /// Explode backing variable
18
+ /// </summary>
19
+ private bool ? _explode ;
16
20
/// <summary>
17
21
/// The Content-Type for encoding a specific property.
18
22
/// The value can be a specific media type (e.g. application/json),
@@ -37,7 +41,11 @@ public class OpenApiEncoding : IOpenApiSerializable, IOpenApiExtensible
37
41
/// For all other styles, the default value is false.
38
42
/// This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded.
39
43
/// </summary>
40
- public bool ? Explode { get ; set ; }
44
+ public bool ? Explode
45
+ {
46
+ get => _explode ?? Style == ParameterStyle . Form ;
47
+ set => _explode = value ;
48
+ }
41
49
42
50
/// <summary>
43
51
/// Determines whether the parameter value SHOULD allow reserved characters,
@@ -65,7 +73,7 @@ public OpenApiEncoding(OpenApiEncoding encoding)
65
73
ContentType = encoding ? . ContentType ?? ContentType ;
66
74
Headers = encoding ? . Headers != null ? new Dictionary < string , OpenApiHeader > ( encoding . Headers ) : null ;
67
75
Style = encoding ? . Style ?? Style ;
68
- Explode = encoding ? . Explode ?? Explode ;
76
+ Explode = encoding ? . _explode ;
69
77
AllowReserved = encoding ? . AllowReserved ?? AllowReserved ;
70
78
Extensions = encoding ? . Extensions != null ? new Dictionary < string , IOpenApiExtension > ( encoding . Extensions ) : null ;
71
79
}
@@ -89,7 +97,10 @@ public void SerializeAsV3(IOpenApiWriter writer)
89
97
writer . WriteProperty ( OpenApiConstants . Style , Style ? . GetDisplayName ( ) ) ;
90
98
91
99
// explode
92
- writer . WriteProperty ( OpenApiConstants . Explode , Explode , false ) ;
100
+ if ( _explode . HasValue )
101
+ {
102
+ writer . WriteProperty ( OpenApiConstants . Explode , Explode ) ;
103
+ }
93
104
94
105
// allowReserved
95
106
writer . WriteProperty ( OpenApiConstants . AllowReserved , AllowReserved , false ) ;
0 commit comments