@@ -15,52 +15,31 @@ namespace Microsoft.OpenApi.Models
1515 /// <summary>
1616 /// Request Body Object
1717 /// </summary>
18- public class OpenApiRequestBody : IOpenApiReferenceable , IOpenApiExtensible
18+ public class OpenApiRequestBody : IOpenApiReferenceable , IOpenApiExtensible , IOpenApiRequestBody
1919 {
20- /// <summary>
21- /// Indicates if object is populated with data or is just a reference to the data
22- /// </summary>
23- public bool UnresolvedReference { get ; set ; }
24-
25- /// <summary>
26- /// Reference object.
27- /// </summary>
28- public OpenApiReference Reference { get ; set ; }
29-
30- /// <summary>
31- /// A brief description of the request body. This could contain examples of use.
32- /// CommonMark syntax MAY be used for rich text representation.
33- /// </summary>
34- public virtual string Description { get ; set ; }
20+ /// <inheritdoc />
21+ public string Description { get ; set ; }
3522
36- /// <summary>
37- /// Determines if the request body is required in the request. Defaults to false.
38- /// </summary>
39- public virtual bool Required { get ; set ; }
23+ /// <inheritdoc />
24+ public bool Required { get ; set ; }
4025
41- /// <summary>
42- /// REQUIRED. The content of the request body. The key is a media type or media type range and the value describes it.
43- /// For requests that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/*
44- /// </summary>
45- public virtual IDictionary < string , OpenApiMediaType > Content { get ; set ; } = new Dictionary < string , OpenApiMediaType > ( ) ;
26+ /// <inheritdoc />
27+ public IDictionary < string , OpenApiMediaType > Content { get ; set ; } = new Dictionary < string , OpenApiMediaType > ( ) ;
4628
47- /// <summary>
48- /// This object MAY be extended with Specification Extensions.
49- /// </summary>
50- public virtual IDictionary < string , IOpenApiExtension > Extensions { get ; set ; } = new Dictionary < string , IOpenApiExtension > ( ) ;
29+ /// <inheritdoc />
30+ public IDictionary < string , IOpenApiExtension > Extensions { get ; set ; } = new Dictionary < string , IOpenApiExtension > ( ) ;
5131
5232 /// <summary>
5333 /// Parameter-less constructor
5434 /// </summary>
5535 public OpenApiRequestBody ( ) { }
5636
5737 /// <summary>
58- /// Initializes a copy instance of an <see cref="OpenApiRequestBody "/> object
38+ /// Initializes a copy instance of an <see cref="IOpenApiRequestBody "/> object
5939 /// </summary>
60- public OpenApiRequestBody ( OpenApiRequestBody requestBody )
40+ public OpenApiRequestBody ( IOpenApiRequestBody requestBody )
6141 {
62- UnresolvedReference = requestBody ? . UnresolvedReference ?? UnresolvedReference ;
63- Reference = requestBody ? . Reference != null ? new ( requestBody ? . Reference ) : null ;
42+ Utils . CheckArgumentNull ( requestBody ) ;
6443 Description = requestBody ? . Description ?? Description ;
6544 Required = requestBody ? . Required ?? Required ;
6645 Content = requestBody ? . Content != null ? new Dictionary < string , OpenApiMediaType > ( requestBody . Content ) : null ;
@@ -70,20 +49,20 @@ public OpenApiRequestBody(OpenApiRequestBody requestBody)
7049 /// <summary>
7150 /// Serialize <see cref="OpenApiRequestBody"/> to Open Api v3.1
7251 /// </summary>
73- public virtual void SerializeAsV31 ( IOpenApiWriter writer )
52+ public void SerializeAsV31 ( IOpenApiWriter writer )
7453 {
7554 SerializeInternal ( writer , OpenApiSpecVersion . OpenApi3_1 , ( writer , element ) => element . SerializeAsV31 ( writer ) ) ;
7655 }
7756
7857 /// <summary>
7958 /// Serialize <see cref="OpenApiRequestBody"/> to Open Api v3.0
8059 /// </summary>
81- public virtual void SerializeAsV3 ( IOpenApiWriter writer )
60+ public void SerializeAsV3 ( IOpenApiWriter writer )
8261 {
8362 SerializeInternal ( writer , OpenApiSpecVersion . OpenApi3_0 , ( writer , element ) => element . SerializeAsV3 ( writer ) ) ;
8463 }
8564
86- internal virtual void SerializeInternal ( IOpenApiWriter writer , OpenApiSpecVersion version ,
65+ internal void SerializeInternal ( IOpenApiWriter writer , OpenApiSpecVersion version ,
8766 Action < IOpenApiWriter , IOpenApiSerializable > callback )
8867 {
8968 Utils . CheckArgumentNull ( writer ) ;
@@ -113,7 +92,8 @@ public void SerializeAsV2(IOpenApiWriter writer)
11392 // RequestBody object does not exist in V2.
11493 }
11594
116- internal virtual IOpenApiParameter ConvertToBodyParameter ( IOpenApiWriter writer )
95+ /// <inheritdoc/>
96+ public IOpenApiParameter ConvertToBodyParameter ( IOpenApiWriter writer )
11797 {
11898 var bodyParameter = new OpenApiBodyParameter
11999 {
@@ -135,22 +115,23 @@ internal virtual IOpenApiParameter ConvertToBodyParameter(IOpenApiWriter writer)
135115 return bodyParameter ;
136116 }
137117
138- internal IEnumerable < OpenApiFormDataParameter > ConvertToFormDataParameters ( )
118+ /// <inheritdoc/>
119+ public IEnumerable < IOpenApiParameter > ConvertToFormDataParameters ( IOpenApiWriter writer )
139120 {
140121 if ( Content == null || ! Content . Any ( ) )
141122 yield break ;
142123
143124 foreach ( var property in Content . First ( ) . Value . Schema . Properties )
144125 {
145126 var paramSchema = property . Value ;
146- if ( "string" . Equals ( paramSchema . Type . ToIdentifier ( ) , StringComparison . OrdinalIgnoreCase )
127+ if ( ( paramSchema . Type & JsonSchemaType . String ) == JsonSchemaType . String
147128 && ( "binary" . Equals ( paramSchema . Format , StringComparison . OrdinalIgnoreCase )
148129 || "base64" . Equals ( paramSchema . Format , StringComparison . OrdinalIgnoreCase ) ) )
149130 {
150131 paramSchema . Type = "file" . ToJsonSchemaType ( ) ;
151132 paramSchema . Format = null ;
152133 }
153- yield return new ( )
134+ yield return new OpenApiFormDataParameter ( )
154135 {
155136 Description = property . Value . Description ,
156137 Name = property . Key ,
0 commit comments