Skip to content

Commit 54008a4

Browse files
committed
porting test cases of domaindrivendev#2546 for #1 records are supported credits @pixellos
1 parent 1b6fef9 commit 54008a4

File tree

3 files changed

+109
-2
lines changed

3 files changed

+109
-2
lines changed

test/DotSwashbuckle.AspNetCore.SwaggerGen.Test/DotSwashbuckle.AspNetCore.SwaggerGen.Test.xml

Lines changed: 65 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using DotSwashbuckle.AspNetCore.TestSupport;
3+
4+
namespace DotSwashbuckle.AspNetCore.SwaggerGen.Test.Fixtures
5+
{
6+
/// <summary>
7+
/// Summary for XmlAnnotatedType
8+
/// </summary>
9+
/// <param name="BoolProperty" example="true">Summary for BoolProperty</param>
10+
/// <param name="IntProperty" example="10">Summary for IntProperty</param>
11+
/// <param name="LongProperty" example="4294967295">Summary for LongProperty</param>
12+
/// <param name="FloatProperty" example="1.2">Summary for FloatProperty</param>
13+
/// <param name="DoubleProperty" example="1.25">Summary for DoubleProperty</param>
14+
/// <param name="EnumProperty" example="2">Summary for EnumProperty</param>
15+
/// <param name="GuidProperty" example="d3966535-2637-48fa-b911-e3c27405ee09">Summary for GuidProperty</param>
16+
/// <param name="StringPropertyWithNullExample" example="null">Summary for Nullable StringPropertyWithNullExample</param>
17+
/// <param name="StringProperty" example="Example for StringProperty">Summary for StringProperty</param>
18+
/// <param name="StringPropertyWithUri" example="https://test.com/a?b=1&amp;c=2">Summary for StringPropertyWithUri</param>
19+
/// <param name="ObjectProperty" example="{&quot;prop1&quot;: 1, &quot;prop2&quot;: &quot;foobar&quot;}">Summary for ObjectProperty</param>
20+
public record XmlAnnotatedRecord(
21+
bool BoolProperty,
22+
int IntProperty,
23+
long LongProperty,
24+
float FloatProperty,
25+
double DoubleProperty,
26+
IntEnum EnumProperty,
27+
Guid GuidProperty,
28+
string StringPropertyWithNullExample,
29+
string StringProperty,
30+
string StringPropertyWithUri,
31+
object ObjectProperty
32+
);
33+
}

test/DotSwashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsSchemaFilterTests.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Globalization;
3-
using System.Xml.XPath;
4-
using System.IO;
53
using DotSwashbuckle.AspNetCore.SwaggerGen.Test.Fixtures;
64
using Microsoft.OpenApi.Models;
75
using Xunit;
@@ -76,6 +74,17 @@ public void Apply_SetsDescription_FromPropertySummaryTag(
7674
[InlineData(typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.StringPropertyWithNullExample), "string", "null")]
7775
[InlineData(typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.StringPropertyWithUri), "string", "\"https://test.com/a?b=1&c=2\"")]
7876
[InlineData(typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.MultiLineSummaryExample), "string", "\"When Number equals 2023/S 106-333284 Then Publication = 333284-2023\"")]
77+
[InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.BoolProperty), "boolean", "true")]
78+
[InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.IntProperty), "integer", "10")]
79+
[InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.LongProperty), "integer", "4294967295")]
80+
[InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.FloatProperty), "number", "1.2")]
81+
[InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.DoubleProperty), "number", "1.25")]
82+
[InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.EnumProperty), "integer", "2")]
83+
[InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.GuidProperty), "string", "\"d3966535-2637-48fa-b911-e3c27405ee09\"")]
84+
[InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.StringProperty), "string", "\"Example for StringProperty\"")]
85+
[InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.ObjectProperty), "object", "{\n \"prop1\": 1,\n \"prop2\": \"foobar\"\n}")]
86+
[InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.StringPropertyWithNullExample), "string", "null")]
87+
[InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.StringPropertyWithUri), "string", "\"https://test.com/a?b=1&c=2\"")]
7988
[UseInvariantCulture]
8089
public void Apply_SetsExample_FromPropertyExampleTag(
8190
Type declaringType,

0 commit comments

Comments
 (0)