Skip to content

Commit 281fc85

Browse files
Always emitting description property for response object. It's required
1 parent 578e587 commit 281fc85

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/Microsoft.OpenApi/Models/OpenApiResponse.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.Collections.Generic;
55
using System.Linq;
6-
using Microsoft.OpenApi.Any;
76
using Microsoft.OpenApi.Interfaces;
87
using Microsoft.OpenApi.Writers;
98

@@ -45,7 +44,7 @@ public class OpenApiResponse : IOpenApiSerializable, IOpenApiReferenceable, IOpe
4544
/// <summary>
4645
/// Indicates if object is populated with data or is just a reference to the data
4746
/// </summary>
48-
public bool UnresolvedReference { get; set;}
47+
public bool UnresolvedReference { get; set; }
4948

5049
/// <summary>
5150
/// Reference pointer.
@@ -79,7 +78,7 @@ public void SerializeAsV3WithoutReference(IOpenApiWriter writer)
7978
writer.WriteStartObject();
8079

8180
// description
82-
writer.WriteProperty(OpenApiConstants.Description, Description);
81+
writer.WriteRequiredProperty(OpenApiConstants.Description, Description);
8382

8483
// headers
8584
writer.WriteOptionalMap(OpenApiConstants.Headers, Headers, (w, h) => h.SerializeAsV3(w));
@@ -123,7 +122,7 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
123122
writer.WriteStartObject();
124123

125124
// description
126-
writer.WriteProperty(OpenApiConstants.Description, Description);
125+
writer.WriteRequiredProperty(OpenApiConstants.Description, Description);
127126
if (Content != null)
128127
{
129128
var mediatype = Content.FirstOrDefault();

src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ public static void WriteProperty(this IOpenApiWriter writer, string name, string
3232
writer.WriteValue(value);
3333
}
3434

35+
/// <summary>
36+
/// Write required string property.
37+
/// </summary>
38+
/// <param name="writer">The writer.</param>
39+
/// <param name="name">The property name.</param>
40+
/// <param name="value">The property value.</param>
41+
public static void WriteRequiredProperty(this IOpenApiWriter writer, string name, string value)
42+
{
43+
CheckArguments(writer, name);
44+
writer.WritePropertyName(name);
45+
writer.WriteValue(value);
46+
}
47+
3548
/// <summary>
3649
/// Write a boolean property.
3750
/// </summary>

0 commit comments

Comments
 (0)