Skip to content

Commit e7d874f

Browse files
committed
Merge remote-tracking branch 'origin/master' into dm/smoketests2
2 parents 092af51 + 47e5cfd commit e7d874f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/Microsoft.OpenApi/Models/OpenApiResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
141141
writer.WritePropertyName(OpenApiConstants.Examples);
142142
writer.WriteStartObject();
143143
writer.WritePropertyName(mediatype.Key);
144-
writer.WriteValue(mediatype.Value.Example);
144+
writer.WriteAny(mediatype.Value.Example);
145145
writer.WriteEndObject();
146146
}
147147
}

test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs

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

44
using System.IO;
55
using FluentAssertions;
6+
using Microsoft.OpenApi.Any;
67
using Microsoft.OpenApi.Extensions;
78
using Microsoft.OpenApi.Models;
89
using Microsoft.OpenApi.Writers;
@@ -30,7 +31,8 @@ public class OpenApiResponseTests
3031
{
3132
Reference = new OpenApiReference {Type = ReferenceType.Schema, Id = "customType"}
3233
}
33-
}
34+
},
35+
Example = new OpenApiString("Blabla")
3436
}
3537
},
3638
Headers =
@@ -147,7 +149,8 @@ public void SerializeAdvancedResponseAsV3JsonWorks()
147149
""items"": {
148150
""$ref"": ""#/components/schemas/customType""
149151
}
150-
}
152+
},
153+
""example"": ""Blabla""
151154
}
152155
}
153156
}";
@@ -181,7 +184,8 @@ public void SerializeAdvancedResponseAsV3YamlWorks()
181184
schema:
182185
type: array
183186
items:
184-
$ref: '#/components/schemas/customType'";
187+
$ref: '#/components/schemas/customType'
188+
example: Blabla";
185189

186190
// Act
187191
var actual = AdvancedResponse.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);
@@ -204,6 +208,9 @@ public void SerializeAdvancedResponseAsV2JsonWorks()
204208
""$ref"": ""#/definitions/customType""
205209
}
206210
},
211+
""examples"": {
212+
""text/plain"": ""Blabla""
213+
},
207214
""headers"": {
208215
""X-Rate-Limit-Limit"": {
209216
""description"": ""The number of allowed requests in the current period"",
@@ -239,6 +246,8 @@ public void SerializeAdvancedResponseAsV2YamlWorks()
239246
type: array
240247
items:
241248
$ref: '#/definitions/customType'
249+
examples:
250+
text/plain: Blabla
242251
headers:
243252
X-Rate-Limit-Limit:
244253
description: The number of allowed requests in the current period

0 commit comments

Comments
 (0)