Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public void GetSwagger_GeneratesSwaggerDocument_ForApiDescriptionsWithMatchingGr
{
SwaggerDocs = new Dictionary<string, OpenApiInfo>
{
["v1"] = new OpenApiInfo { Version = "V1", Title = "Test API" }
["v1"] = new OpenApiInfo { Version = "V1", Title = "Test API" },
["v2"] = new OpenApiInfo { Version = "V2", Title = "Test API 2" },
}
}
);
Expand All @@ -55,6 +56,14 @@ public void GetSwagger_GeneratesSwaggerDocument_ForApiDescriptionsWithMatchingGr
Assert.Equal("Test API", document.Info.Title);
Assert.Equal(new[] { "/resource" }, document.Paths.Keys.ToArray());
Assert.Equal(new[] { OperationType.Post, OperationType.Get }, document.Paths["/resource"].Operations.Keys);
Assert.Equal(2, document.Paths["/resource"].Operations.Count);

var documentV2 = subject.GetSwagger("v2");
Assert.Equal("V2", documentV2.Info.Version);
Assert.Equal("Test API 2", documentV2.Info.Title);
Assert.Equal(new[] { "/resource" }, documentV2.Paths.Keys.ToArray());
Assert.Equal(new[] { OperationType.Post }, documentV2.Paths["/resource"].Operations.Keys);
Assert.Single(documentV2.Paths["/resource"].Operations);
}

[Theory]
Expand Down Expand Up @@ -1160,6 +1169,7 @@ public void GetSwagger_SupportsOption_IgnoreObsoleteActions()

Assert.Equal(new[] { "/resource" }, document.Paths.Keys.ToArray());
Assert.Equal(new[] { OperationType.Post }, document.Paths["/resource"].Operations.Keys);
Assert.Single(document.Paths["/resource"].Operations);
}

[Fact]
Expand Down Expand Up @@ -1190,6 +1200,9 @@ public void GetSwagger_SupportsOption_SortKeySelector()
var document = subject.GetSwagger("v1");

Assert.Equal(new[] { "/resource1", "/resource2", "/resource3" }, document.Paths.Keys.ToArray());
Assert.Single(document.Paths["/resource1"].Operations);
Assert.Single(document.Paths["/resource2"].Operations);
Assert.Single(document.Paths["/resource3"].Operations);
}

[Fact]
Expand Down Expand Up @@ -1316,6 +1329,7 @@ public void GetSwagger_SupportsOption_ConflictingActionsResolver()

Assert.Equal(new[] { "/resource" }, document.Paths.Keys.ToArray());
Assert.Equal(new[] { OperationType.Post }, document.Paths["/resource"].Operations.Keys);
Assert.Single(document.Paths["/resource"].Operations);
}

[Theory]
Expand Down Expand Up @@ -2050,7 +2064,7 @@ public void GetSwagger_Works_As_Expected_When_FromFormObject()
var mediaType = operation.RequestBody.Content["multipart/form-data"];
Assert.NotNull(mediaType.Schema);
Assert.NotNull(mediaType.Schema.Reference);
Assert.Equal(typeof(SwaggerIngoreAnnotatedType).Name, mediaType.Schema.Reference.Id);
Assert.Equal(nameof(SwaggerIngoreAnnotatedType), mediaType.Schema.Reference.Id);
Assert.Empty(mediaType.Encoding);
}

Expand Down Expand Up @@ -2094,7 +2108,7 @@ public void GetSwagger_Works_As_Expected_When_FromFormObject_AndString()
Assert.NotEmpty(mediaType.Schema.AllOf);
Assert.Equal(2, mediaType.Schema.AllOf.Count);
Assert.NotNull(mediaType.Schema.AllOf[0].Reference);
Assert.Equal(typeof(SwaggerIngoreAnnotatedType).Name, mediaType.Schema.AllOf[0].Reference.Id);
Assert.Equal(nameof(SwaggerIngoreAnnotatedType), mediaType.Schema.AllOf[0].Reference.Id);
Assert.NotEmpty(mediaType.Schema.AllOf[1].Properties);
Assert.Equal(["param2"], mediaType.Schema.AllOf[1].Properties.Keys);
Assert.NotEmpty(mediaType.Encoding);
Expand Down Expand Up @@ -2130,7 +2144,7 @@ public void GetSwagger_Works_As_Expected_When_TypeIsEnum_AndModelMetadataTypeIsS
Assert.Equal("param1", operation.Parameters[0].Name);
Assert.NotNull(operation.Parameters[0].Schema);
Assert.NotNull(operation.Parameters[0].Schema.Reference);
Assert.Equal(typeof(IntEnum).Name, operation.Parameters[0].Schema.Reference.Id);
Assert.Equal(nameof(IntEnum), operation.Parameters[0].Schema.Reference.Id);
}

[Fact]
Expand Down