Skip to content

Commit 796d49c

Browse files
committed
chore: revert changes
1 parent 0921b0d commit 796d49c

27 files changed

+87
-391
lines changed

src/Microsoft.OpenApi/Models/OpenApiCallback.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,17 @@ namespace Microsoft.OpenApi.Models
1313
/// <summary>
1414
/// Callback Object: A map of possible out-of band callbacks related to the parent operation.
1515
/// </summary>
16-
public class OpenApiCallback : IOpenApiExtensible, IOpenApiCallback
16+
public class OpenApiCallback : IOpenApiReferenceable, IOpenApiExtensible, IOpenApiCallback
1717
{
18-
private Lazy<Dictionary<RuntimeExpression, IOpenApiPathItem>>? _pathItems = new(() => []);
1918
/// <inheritdoc/>
20-
public Dictionary<RuntimeExpression, IOpenApiPathItem>? PathItems
21-
{
22-
get => _pathItems?.Value;
23-
set => _pathItems = value is null ? null : new(() => value);
24-
}
19+
public Dictionary<RuntimeExpression, IOpenApiPathItem>? PathItems { get; set; }
20+
= [];
2521

26-
private Lazy<IDictionary<string, IOpenApiExtension>>? _extensions = new(() => new Dictionary<string, IOpenApiExtension>(StringComparer.Ordinal));
2722

2823
/// <summary>
2924
/// This object MAY be extended with Specification Extensions.
3025
/// </summary>
31-
public IDictionary<string, IOpenApiExtension>? Extensions
32-
{
33-
get => _extensions?.Value;
34-
set => _extensions = value is null ? null : new(() => value);
35-
}
26+
public IDictionary<string, IOpenApiExtension>? Extensions { get; set; } = new Dictionary<string, IOpenApiExtension>();
3627

3728
/// <summary>
3829
/// Parameter-less constructor

src/Microsoft.OpenApi/Models/OpenApiComponents.cs

Lines changed: 14 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -18,115 +18,63 @@ namespace Microsoft.OpenApi.Models
1818
/// </summary>
1919
public class OpenApiComponents : IOpenApiSerializable, IOpenApiExtensible
2020
{
21-
private Lazy<IDictionary<string, IOpenApiSchema>>? _schemas = new(() => new Dictionary<string, IOpenApiSchema>(StringComparer.Ordinal));
2221
/// <summary>
2322
/// An object to hold reusable <see cref="IOpenApiSchema"/> Objects.
2423
/// </summary>
25-
public IDictionary<string, IOpenApiSchema>? Schemas
26-
{
27-
get => _schemas?.Value;
28-
set => _schemas = value is null ? null : new(() => value);
29-
}
24+
public IDictionary<string, IOpenApiSchema>? Schemas { get; set; } = new Dictionary<string, IOpenApiSchema>();
3025

31-
private Lazy<IDictionary<string, IOpenApiResponse>>? _responses = new(() => new Dictionary<string, IOpenApiResponse>(StringComparer.Ordinal));
3226
/// <summary>
3327
/// An object to hold reusable <see cref="IOpenApiResponse"/> Objects.
3428
/// </summary>
35-
public IDictionary<string, IOpenApiResponse>? Responses
36-
{
37-
get => _responses?.Value;
38-
set => _responses = value is null ? null : new(() => value);
39-
}
29+
public IDictionary<string, IOpenApiResponse>? Responses { get; set; } = new Dictionary<string, IOpenApiResponse>();
4030

41-
private Lazy<IDictionary<string, IOpenApiParameter>>? _parameters = new(() => new Dictionary<string, IOpenApiParameter>(StringComparer.Ordinal));
4231
/// <summary>
4332
/// An object to hold reusable <see cref="IOpenApiParameter"/> Objects.
4433
/// </summary>
45-
public IDictionary<string, IOpenApiParameter>? Parameters
46-
{
47-
get => _parameters?.Value;
48-
set => _parameters = value is null ? null : new(() => value);
49-
}
34+
public IDictionary<string, IOpenApiParameter>? Parameters { get; set; } =
35+
new Dictionary<string, IOpenApiParameter>();
5036

51-
private Lazy<IDictionary<string, IOpenApiExample>>? _examples = new(() => new Dictionary<string, IOpenApiExample>(StringComparer.Ordinal));
5237
/// <summary>
5338
/// An object to hold reusable <see cref="OpenApiExample"/> Objects.
5439
/// </summary>
55-
public IDictionary<string, IOpenApiExample>? Examples
56-
{
57-
get => _examples?.Value;
58-
set => _examples = value is null ? null : new(() => value);
59-
}
40+
public IDictionary<string, IOpenApiExample>? Examples { get; set; } = new Dictionary<string, IOpenApiExample>();
6041

61-
private Lazy<IDictionary<string, IOpenApiRequestBody>>? _requestBodies = new(() => new Dictionary<string, IOpenApiRequestBody>(StringComparer.Ordinal));
6242
/// <summary>
6343
/// An object to hold reusable <see cref="IOpenApiRequestBody"/> Objects.
6444
/// </summary>
65-
public IDictionary<string, IOpenApiRequestBody>? RequestBodies
66-
{
67-
get => _requestBodies?.Value;
68-
set => _requestBodies = value is null ? null : new(() => value);
69-
}
45+
public IDictionary<string, IOpenApiRequestBody>? RequestBodies { get; set; } =
46+
new Dictionary<string, IOpenApiRequestBody>();
7047

71-
private Lazy<IDictionary<string, IOpenApiHeader>>? _headers = new(() => new Dictionary<string, IOpenApiHeader>(StringComparer.Ordinal));
7248
/// <summary>
7349
/// An object to hold reusable <see cref="IOpenApiHeader"/> Objects.
7450
/// </summary>
75-
public IDictionary<string, IOpenApiHeader>? Headers
76-
{
77-
get => _headers?.Value;
78-
set => _headers = value is null ? null : new(() => value);
79-
}
51+
public IDictionary<string, IOpenApiHeader>? Headers { get; set; } = new Dictionary<string, IOpenApiHeader>();
8052

81-
private Lazy<IDictionary<string, IOpenApiSecurityScheme>>? _securitySchemes = new(() => new Dictionary<string, IOpenApiSecurityScheme>(StringComparer.Ordinal));
8253
/// <summary>
8354
/// An object to hold reusable <see cref="IOpenApiSecurityScheme"/> Objects.
8455
/// </summary>
85-
public IDictionary<string, IOpenApiSecurityScheme>? SecuritySchemes
86-
{
87-
get => _securitySchemes?.Value;
88-
set => _securitySchemes = value is null ? null : new(() => value);
89-
}
56+
public IDictionary<string, IOpenApiSecurityScheme>? SecuritySchemes { get; set; } =
57+
new Dictionary<string, IOpenApiSecurityScheme>();
9058

91-
private Lazy<IDictionary<string, IOpenApiLink>>? _links = new(() => new Dictionary<string, IOpenApiLink>(StringComparer.Ordinal));
9259
/// <summary>
9360
/// An object to hold reusable <see cref="IOpenApiLink"/> Objects.
9461
/// </summary>
95-
public IDictionary<string, IOpenApiLink>? Links
96-
{
97-
get => _links?.Value;
98-
set => _links = value is null ? null : new(() => value);
99-
}
62+
public IDictionary<string, IOpenApiLink>? Links { get; set; } = new Dictionary<string, IOpenApiLink>();
10063

101-
private Lazy<IDictionary<string, IOpenApiCallback>>? _callbacks = new(() => new Dictionary<string, IOpenApiCallback>(StringComparer.Ordinal));
10264
/// <summary>
10365
/// An object to hold reusable <see cref="OpenApiCallback"/> Objects.
10466
/// </summary>
105-
public IDictionary<string, IOpenApiCallback>? Callbacks
106-
{
107-
get => _callbacks?.Value;
108-
set => _callbacks = value is null ? null : new(() => value);
109-
}
67+
public IDictionary<string, IOpenApiCallback>? Callbacks { get; set; } = new Dictionary<string, IOpenApiCallback>();
11068

111-
private Lazy<IDictionary<string, IOpenApiPathItem>>? _pathItems = new(() => new Dictionary<string, IOpenApiPathItem>(StringComparer.Ordinal));
11269
/// <summary>
11370
/// An object to hold reusable <see cref="IOpenApiPathItem"/> Object.
11471
/// </summary>
115-
public IDictionary<string, IOpenApiPathItem>? PathItems
116-
{
117-
get => _pathItems?.Value;
118-
set => _pathItems = value is null ? null : new(() => value);
119-
}
72+
public IDictionary<string, IOpenApiPathItem>? PathItems { get; set; } = new Dictionary<string, IOpenApiPathItem>();
12073

121-
private Lazy<IDictionary<string, IOpenApiExtension>>? _extensions = new(() => new Dictionary<string, IOpenApiExtension>(StringComparer.Ordinal));
12274
/// <summary>
12375
/// This object MAY be extended with Specification Extensions.
12476
/// </summary>
125-
public IDictionary<string, IOpenApiExtension>? Extensions
126-
{
127-
get => _extensions?.Value;
128-
set => _extensions = value is null ? null : new(() => value);
129-
}
77+
public IDictionary<string, IOpenApiExtension>? Extensions { get; set; } = new Dictionary<string, IOpenApiExtension>();
13078

13179
/// <summary>
13280
/// Parameter-less constructor

src/Microsoft.OpenApi/Models/OpenApiContact.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,10 @@ public class OpenApiContact : IOpenApiSerializable, IOpenApiExtensible
2929
/// </summary>
3030
public string? Email { get; set; }
3131

32-
private Lazy<IDictionary<string, IOpenApiExtension>>? _extensions = new(() => new Dictionary<string, IOpenApiExtension>(StringComparer.Ordinal));
3332
/// <summary>
3433
/// This object MAY be extended with Specification Extensions.
3534
/// </summary>
36-
public IDictionary<string, IOpenApiExtension>? Extensions
37-
{
38-
get => _extensions?.Value;
39-
set => _extensions = value is null ? null : new(() => value);
40-
}
35+
public IDictionary<string, IOpenApiExtension>? Extensions { get; set; } = new Dictionary<string, IOpenApiExtension>();
4136

4237
/// <summary>
4338
/// Parameter-less constructor

src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4-
using System;
54
using System.Collections.Generic;
65
using Microsoft.OpenApi.Interfaces;
76
using Microsoft.OpenApi.Writers;
@@ -18,25 +17,15 @@ public class OpenApiDiscriminator : IOpenApiSerializable, IOpenApiExtensible
1817
/// </summary>
1918
public string? PropertyName { get; set; }
2019

21-
private Lazy<IDictionary<string, string>>? _mapping = new(() => new Dictionary<string, string>(StringComparer.Ordinal));
2220
/// <summary>
2321
/// An object to hold mappings between payload values and schema names or references.
2422
/// </summary>
25-
public IDictionary<string, string>? Mapping
26-
{
27-
get => _mapping?.Value;
28-
set => _mapping = value is null ? null : new(() => value);
29-
}
23+
public IDictionary<string, string>? Mapping { get; set; } = new Dictionary<string, string>();
3024

31-
private Lazy<IDictionary<string, IOpenApiExtension>>? _extensions = new(() => new Dictionary<string, IOpenApiExtension>(StringComparer.Ordinal));
3225
/// <summary>
3326
/// This object MAY be extended with Specification Extensions.
3427
/// </summary>
35-
public IDictionary<string, IOpenApiExtension>? Extensions
36-
{
37-
get => _extensions?.Value;
38-
set => _extensions = value is null ? null : new(() => value);
39-
}
28+
public IDictionary<string, IOpenApiExtension>? Extensions { get; set; } = new Dictionary<string, IOpenApiExtension>();
4029

4130
/// <summary>
4231
/// Parameter-less constructor

src/Microsoft.OpenApi/Models/OpenApiDocument.cs

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,47 +48,33 @@ public void RegisterComponents()
4848
/// </summary>
4949
public Uri? JsonSchemaDialect { get; set; }
5050

51-
private Lazy<IList<OpenApiServer>>? _servers = new(() => []);
5251
/// <summary>
5352
/// An array of Server Objects, which provide connectivity information to a target server.
5453
/// </summary>
55-
public IList<OpenApiServer>? Servers
56-
{
57-
get => _servers?.Value;
58-
set => _servers = value is null ? null : new(() => value);
59-
}
54+
public IList<OpenApiServer>? Servers { get; set; } = new List<OpenApiServer>();
6055

6156
/// <summary>
6257
/// REQUIRED. The available paths and operations for the API.
6358
/// </summary>
6459
public OpenApiPaths Paths { get; set; }
6560

66-
private Lazy<IDictionary<string, IOpenApiPathItem>>? _webhooks = new(() => new Dictionary<string, IOpenApiPathItem>(StringComparer.Ordinal));
6761
/// <summary>
6862
/// The incoming webhooks that MAY be received as part of this API and that the API consumer MAY choose to implement.
6963
/// A map of requests initiated other than by an API call, for example by an out of band registration.
7064
/// The key name is a unique string to refer to each webhook, while the (optionally referenced) Path Item Object describes a request that may be initiated by the API provider and the expected responses
7165
/// </summary>
72-
public IDictionary<string, IOpenApiPathItem>? Webhooks
73-
{
74-
get => _webhooks?.Value;
75-
set => _webhooks = value is null ? null : new(() => value);
76-
}
66+
public IDictionary<string, IOpenApiPathItem>? Webhooks { get; set; } = new Dictionary<string, IOpenApiPathItem>();
7767

7868
/// <summary>
7969
/// An element to hold various schemas for the specification.
8070
/// </summary>
8171
public OpenApiComponents? Components { get; set; }
8272

83-
private Lazy<IList<OpenApiSecurityRequirement>>? _security = new(() => []);
8473
/// <summary>
8574
/// A declaration of which security mechanisms can be used across the API.
8675
/// </summary>
87-
public IList<OpenApiSecurityRequirement>? Security
88-
{
89-
get => _security?.Value;
90-
set => _security = value is null ? null : new(() => value);
91-
}
76+
public IList<OpenApiSecurityRequirement>? Security { get; set; } =
77+
new List<OpenApiSecurityRequirement>();
9278

9379
private HashSet<OpenApiTag>? _tags;
9480
/// <summary>
@@ -117,15 +103,10 @@ public ISet<OpenApiTag>? Tags
117103
/// </summary>
118104
public OpenApiExternalDocs? ExternalDocs { get; set; }
119105

120-
private Lazy<IDictionary<string, IOpenApiExtension>>? _extensions = new(() => new Dictionary<string, IOpenApiExtension>(StringComparer.Ordinal));
121106
/// <summary>
122107
/// This object MAY be extended with Specification Extensions.
123108
/// </summary>
124-
public IDictionary<string, IOpenApiExtension>? Extensions
125-
{
126-
get => _extensions?.Value;
127-
set => _extensions = value is null ? null : new(() => value);
128-
}
109+
public IDictionary<string, IOpenApiExtension>? Extensions { get; set; } = new Dictionary<string, IOpenApiExtension>();
129110

130111
/// <inheritdoc />
131112
public IDictionary<string, object>? Metadata { get; set; }

src/Microsoft.OpenApi/Models/OpenApiEncoding.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,10 @@ public class OpenApiEncoding : IOpenApiSerializable, IOpenApiExtensible
2222
/// </summary>
2323
public string? ContentType { get; set; }
2424

25-
private Lazy<IDictionary<string, IOpenApiHeader>>? _headers = new(() => new Dictionary<string, IOpenApiHeader>());
2625
/// <summary>
2726
/// A map allowing additional information to be provided as headers.
2827
/// </summary>
29-
public IDictionary<string, IOpenApiHeader>? Headers
30-
{
31-
get => _headers?.Value;
32-
set => _headers = value is null ? null : new(() => value);
33-
}
28+
public IDictionary<string, IOpenApiHeader>? Headers { get; set; } = new Dictionary<string, IOpenApiHeader>();
3429

3530
/// <summary>
3631
/// Describes how a specific property value will be serialized depending on its type.
@@ -54,15 +49,10 @@ public IDictionary<string, IOpenApiHeader>? Headers
5449
/// </summary>
5550
public bool? AllowReserved { get; set; }
5651

57-
private Lazy<IDictionary<string, IOpenApiExtension>>? _extensions = new(() => new Dictionary<string, IOpenApiExtension>(StringComparer.Ordinal));
5852
/// <summary>
5953
/// This object MAY be extended with Specification Extensions.
6054
/// </summary>
61-
public IDictionary<string, IOpenApiExtension>? Extensions
62-
{
63-
get => _extensions?.Value;
64-
set => _extensions = value is null ? null : new(() => value);
65-
}
55+
public IDictionary<string, IOpenApiExtension>? Extensions { get; set; } = new Dictionary<string, IOpenApiExtension>();
6656

6757
/// <summary>
6858
/// Parameter-less constructor

src/Microsoft.OpenApi/Models/OpenApiExample.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4-
using System;
54
using System.Collections.Generic;
65
using System.Text.Json.Nodes;
76
using Microsoft.OpenApi.Helpers;
@@ -14,7 +13,7 @@ namespace Microsoft.OpenApi.Models
1413
/// <summary>
1514
/// Example Object.
1615
/// </summary>
17-
public class OpenApiExample : IOpenApiExtensible, IOpenApiExample
16+
public class OpenApiExample : IOpenApiReferenceable, IOpenApiExtensible, IOpenApiExample
1817
{
1918
/// <inheritdoc/>
2019
public string? Summary { get; set; }
@@ -28,13 +27,8 @@ public class OpenApiExample : IOpenApiExtensible, IOpenApiExample
2827
/// <inheritdoc/>
2928
public JsonNode? Value { get; set; }
3029

31-
private Lazy<IDictionary<string, IOpenApiExtension>>? _extensions = new(() => new Dictionary<string, IOpenApiExtension>(StringComparer.Ordinal));
3230
/// <inheritdoc/>
33-
public IDictionary<string, IOpenApiExtension>? Extensions
34-
{
35-
get => _extensions?.Value;
36-
set => _extensions = value is null ? null : new(() => value);
37-
}
31+
public IDictionary<string, IOpenApiExtension>? Extensions { get; set; } = new Dictionary<string, IOpenApiExtension>();
3832

3933
/// <summary>
4034
/// Parameter-less constructor

src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,10 @@ public class OpenApiExternalDocs : IOpenApiSerializable, IOpenApiExtensible
2323
/// </summary>
2424
public Uri? Url { get; set; }
2525

26-
private Lazy<IDictionary<string, IOpenApiExtension>>? _extensions = new(() => new Dictionary<string, IOpenApiExtension>(StringComparer.Ordinal));
2726
/// <summary>
2827
/// This object MAY be extended with Specification Extensions.
2928
/// </summary>
30-
public IDictionary<string, IOpenApiExtension>? Extensions
31-
{
32-
get => _extensions?.Value;
33-
set => _extensions = value is null ? null : new(() => value);
34-
}
29+
public IDictionary<string, IOpenApiExtension>? Extensions { get; set; } = new Dictionary<string, IOpenApiExtension>();
3530

3631
/// <summary>
3732
/// Parameter-less constructor

src/Microsoft.OpenApi/Models/OpenApiHeader.cs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,14 @@ public class OpenApiHeader : IOpenApiHeader, IOpenApiExtensible
4646
/// <inheritdoc/>
4747
public JsonNode? Example { get; set; }
4848

49-
private Lazy<IDictionary<string, IOpenApiExample>>? _examples = new(() => new Dictionary<string, IOpenApiExample>(StringComparer.Ordinal));
5049
/// <inheritdoc/>
51-
public IDictionary<string, IOpenApiExample>? Examples
52-
{
53-
get => _examples?.Value;
54-
set => _examples = value is null ? null : new(() => value);
55-
}
50+
public IDictionary<string, IOpenApiExample>? Examples { get; set; } = new Dictionary<string, IOpenApiExample>();
5651

57-
private Lazy<IDictionary<string, OpenApiMediaType>>? _content = new(() => new Dictionary<string, OpenApiMediaType>(StringComparer.Ordinal));
5852
/// <inheritdoc/>
59-
public IDictionary<string, OpenApiMediaType>? Content
60-
{
61-
get => _content?.Value;
62-
set => _content = value is null ? null : new(() => value);
63-
}
53+
public IDictionary<string, OpenApiMediaType>? Content { get; set; } = new Dictionary<string, OpenApiMediaType>();
6454

65-
private Lazy<IDictionary<string, IOpenApiExtension>>? _extensions = new(() => new Dictionary<string, IOpenApiExtension>(StringComparer.Ordinal));
6655
/// <inheritdoc/>
67-
public IDictionary<string, IOpenApiExtension>? Extensions
68-
{
69-
get => _extensions?.Value;
70-
set => _extensions = value is null ? null : new(() => value);
71-
}
56+
public IDictionary<string, IOpenApiExtension>? Extensions { get; set; } = new Dictionary<string, IOpenApiExtension>();
7257

7358
/// <summary>
7459
/// Parameter-less constructor

0 commit comments

Comments
 (0)