8
8
using Microsoft . OpenApi . Extensions ;
9
9
using Microsoft . OpenApi . Interfaces ;
10
10
using Microsoft . OpenApi . Models ;
11
+ using SharpYaml ;
11
12
using Xunit ;
12
13
13
14
namespace Microsoft . OpenApi . Tests . Models
@@ -29,6 +30,14 @@ public class OpenApiInfoTests
29
30
}
30
31
} ;
31
32
33
+ public static OpenApiInfo InfoWithSummary = new ( )
34
+ {
35
+ Title = "Sample Pet Store App" ,
36
+ Summary = "This is a sample server for a pet store." ,
37
+ Description = "This is a sample server for a pet store." ,
38
+ Version = "1.1.1" ,
39
+ } ;
40
+
32
41
public static OpenApiInfo BasicInfo = new OpenApiInfo
33
42
{
34
43
Title = "Sample Pet Store App" ,
@@ -101,6 +110,7 @@ public static IEnumerable<object[]> AdvanceInfoJsonExpect()
101
110
specVersion ,
102
111
@"{
103
112
""title"": ""Sample Pet Store App"",
113
+ ""summary"": ""This is a sample server for a pet store."",
104
114
""description"": ""This is a sample server for a pet store."",
105
115
""termsOfService"": ""http://example.com/terms/"",
106
116
""contact"": {
@@ -195,5 +205,43 @@ public void InfoVersionShouldAcceptDateStyledAsVersions()
195
205
expected = expected . MakeLineBreaksEnvironmentNeutral ( ) ;
196
206
actual . Should ( ) . Be ( expected ) ;
197
207
}
208
+
209
+ [ Fact ]
210
+ public void SerializeInfoObjectWithSummaryAsV3YamlWorks ( )
211
+ {
212
+ // Arrange
213
+ var expected = @"title: Sample Pet Store App
214
+ summary: This is a sample server for a pet store.
215
+ description: This is a sample server for a pet store.
216
+ version: '1.1.1'" ;
217
+
218
+ // Act
219
+ var actual = InfoWithSummary . SerializeAsYaml ( OpenApiSpecVersion . OpenApi3_0 ) ;
220
+
221
+ // Assert
222
+ actual = actual . MakeLineBreaksEnvironmentNeutral ( ) ;
223
+ expected = expected . MakeLineBreaksEnvironmentNeutral ( ) ;
224
+ Assert . Equal ( expected , actual ) ;
225
+ }
226
+
227
+ [ Fact ]
228
+ public void SerializeInfoObjectWithSummaryAsV3JsonWorks ( )
229
+ {
230
+ // Arrange
231
+ var expected = @"{
232
+ ""title"": ""Sample Pet Store App"",
233
+ ""summary"": ""This is a sample server for a pet store."",
234
+ ""description"": ""This is a sample server for a pet store."",
235
+ ""version"": ""1.1.1""
236
+ }" ;
237
+
238
+ // Act
239
+ var actual = InfoWithSummary . SerializeAsJson ( OpenApiSpecVersion . OpenApi3_0 ) ;
240
+
241
+ // Assert
242
+ actual = actual . MakeLineBreaksEnvironmentNeutral ( ) ;
243
+ expected = expected . MakeLineBreaksEnvironmentNeutral ( ) ;
244
+ Assert . Equal ( expected , actual ) ;
245
+ }
198
246
}
199
247
}
0 commit comments