@@ -11,6 +11,10 @@ namespace Microsoft.OpenApi
11
11
/// </summary>
12
12
public class OpenApiEncoding : IOpenApiSerializable , IOpenApiExtensible
13
13
{
14
+ /// <summary>
15
+ /// Explode backing variable
16
+ /// </summary>
17
+ private bool ? _explode ;
14
18
/// <summary>
15
19
/// The Content-Type for encoding a specific property.
16
20
/// The value can be a specific media type (e.g. application/json),
@@ -35,7 +39,11 @@ public class OpenApiEncoding : IOpenApiSerializable, IOpenApiExtensible
35
39
/// For all other styles, the default value is false.
36
40
/// This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded.
37
41
/// </summary>
38
- public bool ? Explode { get ; set ; }
42
+ public bool ? Explode
43
+ {
44
+ get => _explode ?? Style == ParameterStyle . Form ;
45
+ set => _explode = value ;
46
+ }
39
47
40
48
/// <summary>
41
49
/// Determines whether the parameter value SHOULD allow reserved characters,
@@ -63,7 +71,7 @@ public OpenApiEncoding(OpenApiEncoding encoding)
63
71
ContentType = encoding ? . ContentType ?? ContentType ;
64
72
Headers = encoding ? . Headers != null ? new Dictionary < string , IOpenApiHeader > ( encoding . Headers ) : null ;
65
73
Style = encoding ? . Style ?? Style ;
66
- Explode = encoding ? . Explode ?? Explode ;
74
+ Explode = encoding ? . _explode ;
67
75
AllowReserved = encoding ? . AllowReserved ?? AllowReserved ;
68
76
Extensions = encoding ? . Extensions != null ? new Dictionary < string , IOpenApiExtension > ( encoding . Extensions ) : null ;
69
77
}
@@ -106,7 +114,10 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version
106
114
writer . WriteProperty ( OpenApiConstants . Style , Style ? . GetDisplayName ( ) ) ;
107
115
108
116
// explode
109
- writer . WriteProperty ( OpenApiConstants . Explode , Explode , false ) ;
117
+ if ( _explode . HasValue )
118
+ {
119
+ writer . WriteProperty ( OpenApiConstants . Explode , Explode ) ;
120
+ }
110
121
111
122
// allowReserved
112
123
writer . WriteProperty ( OpenApiConstants . AllowReserved , AllowReserved , false ) ;
0 commit comments