Skip to content

Commit f91659b

Browse files
committed
Fix tests and lint errors
1 parent cfc70d0 commit f91659b

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/OpenApi/src/Services/Schemas/OpenApiSchemaService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Collections.Concurrent;
5-
using System.ComponentModel;
65
using System.ComponentModel.DataAnnotations;
76
using System.Diagnostics;
87
using System.IO.Pipelines;

src/OpenApi/src/Services/Schemas/Transformers/DescriptionDataAnnotationsSchemaTransformer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
54
using System.ComponentModel;
65
using System.Linq;
76
using System.Text.Json;

src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/OpenApiOptionsTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public void AddDocumentTransformer_WithDocumentTransformerDelegate()
1010
{
1111
// Arrange
1212
var options = new OpenApiOptions();
13+
RemoveBuiltInTransformers(options);
14+
1315
var transformer = new Func<OpenApiDocument, OpenApiDocumentTransformerContext, CancellationToken, Task>((document, context, cancellationToken) =>
1416
{
1517
document.Info.Title = "New Title";
@@ -32,6 +34,8 @@ public void AddDocumentTransformer_WithDocumentTransformerInstance()
3234
{
3335
// Arrange
3436
var options = new OpenApiOptions();
37+
RemoveBuiltInTransformers(options);
38+
3539
var transformer = new TestOpenApiDocumentTransformer();
3640

3741
// Act
@@ -50,6 +54,7 @@ public void AddDocumentTransformer_WithDocumentTransformerType()
5054
{
5155
// Arrange
5256
var options = new OpenApiOptions();
57+
RemoveBuiltInTransformers(options);
5358

5459
// Act
5560
var result = options.AddDocumentTransformer<TestOpenApiDocumentTransformer>();
@@ -67,6 +72,8 @@ public void AddOperationTransformer_WithOperationTransformerDelegate()
6772
{
6873
// Arrange
6974
var options = new OpenApiOptions();
75+
RemoveBuiltInTransformers(options);
76+
7077
var transformer = new Func<OpenApiOperation, OpenApiOperationTransformerContext, CancellationToken, Task>((operation, context, cancellationToken) =>
7178
{
7279
operation.Description = "New Description";
@@ -89,6 +96,8 @@ public void AddOperationTransformer_WithOperationTransformerInstance()
8996
{
9097
// Arrange
9198
var options = new OpenApiOptions();
99+
RemoveBuiltInTransformers(options);
100+
92101
var transformer = new TestOpenApiOperationTransformer();
93102

94103
// Act
@@ -107,6 +116,7 @@ public void AddOperationTransformer_WithOperationTransformerType()
107116
{
108117
// Arrange
109118
var options = new OpenApiOptions();
119+
RemoveBuiltInTransformers(options);
110120

111121
// Act
112122
var result = options.AddOperationTransformer<TestOpenApiOperationTransformer>();
@@ -124,6 +134,8 @@ public void AddSchemaTransformer_WithSchemaTransformerDelegate()
124134
{
125135
// Arrange
126136
var options = new OpenApiOptions();
137+
RemoveBuiltInTransformers(options);
138+
127139
var transformer = new Func<OpenApiSchema, OpenApiSchemaTransformerContext, CancellationToken, Task>((schema, context, cancellationToken) =>
128140
{
129141
schema.Description = "New Description";
@@ -146,6 +158,8 @@ public void AddSchemaTransformer_WithSchemaTransformerInstance()
146158
{
147159
// Arrange
148160
var options = new OpenApiOptions();
161+
RemoveBuiltInTransformers(options);
162+
149163
var transformer = new TestOpenApiSchemaTransformer();
150164

151165
// Act
@@ -164,6 +178,7 @@ public void AddSchemaTransformer_WithSchemaTransformerType()
164178
{
165179
// Arrange
166180
var options = new OpenApiOptions();
181+
RemoveBuiltInTransformers(options);
167182

168183
// Act
169184
var result = options.AddSchemaTransformer<TestOpenApiSchemaTransformer>();
@@ -176,6 +191,13 @@ public void AddSchemaTransformer_WithSchemaTransformerType()
176191
Assert.Empty(options.OperationTransformers);
177192
}
178193

194+
private static void RemoveBuiltInTransformers(OpenApiOptions options)
195+
{
196+
options.DocumentTransformers.Clear();
197+
options.OperationTransformers.Clear();
198+
options.SchemaTransformers.Clear();
199+
}
200+
179201
private class TestOpenApiDocumentTransformer : IOpenApiDocumentTransformer
180202
{
181203
public Task TransformAsync(OpenApiDocument document, OpenApiDocumentTransformerContext context, CancellationToken cancellationToken)

0 commit comments

Comments
 (0)