Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions src/Microsoft.OpenApi/Models/OpenApiDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void RegisterComponents()
/// <summary>
/// A declaration of which security mechanisms can be used across the API.
/// </summary>
public IList<OpenApiSecurityRequirement>? SecurityRequirements { get; set; } =
public IList<OpenApiSecurityRequirement>? Security { get; set; } =
new List<OpenApiSecurityRequirement>();

private HashSet<OpenApiTag>? _tags;
Expand Down Expand Up @@ -139,7 +139,7 @@ public OpenApiDocument(OpenApiDocument? document)
Paths = document?.Paths != null ? new(document?.Paths) : new OpenApiPaths();
Webhooks = document?.Webhooks != null ? new Dictionary<string, IOpenApiPathItem>(document.Webhooks) : null;
Components = document?.Components != null ? new(document?.Components) : null;
SecurityRequirements = document?.SecurityRequirements != null ? new List<OpenApiSecurityRequirement>(document.SecurityRequirements) : null;
Security = document?.Security != null ? new List<OpenApiSecurityRequirement>(document.Security) : null;
Tags = document?.Tags != null ? new HashSet<OpenApiTag>(document.Tags, OpenApiTagComparer.Instance) : null;
ExternalDocs = document?.ExternalDocs != null ? new(document?.ExternalDocs) : null;
Extensions = document?.Extensions != null ? new Dictionary<string, IOpenApiExtension>(document.Extensions) : null;
Expand Down Expand Up @@ -223,7 +223,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version
// security
writer.WriteOptionalCollection(
OpenApiConstants.Security,
SecurityRequirements,
Security,
callback);

// tags
Expand Down Expand Up @@ -361,7 +361,7 @@ public void SerializeAsV2(IOpenApiWriter writer)
// security
writer.WriteOptionalCollection(
OpenApiConstants.Security,
SecurityRequirements,
Security,
(w, s) => s.SerializeAsV2(w));

// tags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ internal static partial class OpenApiV2Deserializer
o.Components.SecuritySchemes = n.CreateMap(LoadSecurityScheme, o);
}
},
{"security", (o, n, _) => o.SecurityRequirements = n.CreateList(LoadSecurityRequirement, o)},
{"security", (o, n, _) => o.Security = n.CreateList(LoadSecurityRequirement, o)},
{"tags", (o, n, _) => { if (n.CreateList(LoadTag, o) is {Count:> 0} tags) {o.Tags = new HashSet<OpenApiTag>(tags, OpenApiTagComparer.Instance); } } },
{"externalDocs", (o, n, _) => o.ExternalDocs = LoadExternalDocs(n, o)}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal static partial class OpenApiV3Deserializer
{"components", (o, n, _) => o.Components = LoadComponents(n, o)},
{"tags", (o, n, _) => { if (n.CreateList(LoadTag, o) is {Count:> 0} tags) {o.Tags = new HashSet<OpenApiTag>(tags, OpenApiTagComparer.Instance); } } },
{"externalDocs", (o, n, _) => o.ExternalDocs = LoadExternalDocs(n, o)},
{"security", (o, n, _) => o.SecurityRequirements = n.CreateList(LoadSecurityRequirement, o)}
{"security", (o, n, _) => o.Security = n.CreateList(LoadSecurityRequirement, o)}
};

private static readonly PatternFieldMap<OpenApiDocument> _openApiPatternFields = new PatternFieldMap<OpenApiDocument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal static partial class OpenApiV31Deserializer
{"components", (o, n, _) => o.Components = LoadComponents(n, o)},
{"tags", (o, n, _) => { if (n.CreateList(LoadTag, o) is {Count:> 0} tags) {o.Tags = new HashSet<OpenApiTag>(tags, OpenApiTagComparer.Instance); } } },
{"externalDocs", (o, n, _) => o.ExternalDocs = LoadExternalDocs(n, o)},
{"security", (o, n, _) => o.SecurityRequirements = n.CreateList(LoadSecurityRequirement, o)}
{"security", (o, n, _) => o.Security = n.CreateList(LoadSecurityRequirement, o)}
};

private static readonly PatternFieldMap<OpenApiDocument> _openApiPatternFields = new()
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Services/OpenApiFilterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun
},

Components = components,
SecurityRequirements = source.SecurityRequirements,
Security = source.Security,
Servers = source.Servers
};

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Services/OpenApiWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void Walk(OpenApiDocument doc)
Walk(OpenApiConstants.Paths, () => Walk(doc.Paths));
Walk(OpenApiConstants.Webhooks, () => Walk(doc.Webhooks));
Walk(OpenApiConstants.Components, () => Walk(doc.Components));
Walk(OpenApiConstants.Security, () => Walk(doc.SecurityRequirements));
Walk(OpenApiConstants.Security, () => Walk(doc.Security));
Walk(OpenApiConstants.ExternalDocs, () => Walk(doc.ExternalDocs));
Walk(OpenApiConstants.Tags, () => Walk(doc.Tags));
Walk(doc as IOpenApiExtensible);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed()
Description = "tagDescription2"
}
},
SecurityRequirements = new List<OpenApiSecurityRequirement>
Security = new List<OpenApiSecurityRequirement>
{
new OpenApiSecurityRequirement
{
Expand Down Expand Up @@ -1052,7 +1052,7 @@ public async Task GlobalSecurityRequirementShouldReferenceSecurityScheme()
{
var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "securedApi.yaml"), SettingsFixture.ReaderSettings);

var securityRequirement = result.Document.SecurityRequirements[0];
var securityRequirement = result.Document.Security[0];

Assert.Equivalent(result.Document.Components.SecuritySchemes.First().Value, securityRequirement.Keys.First());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ namespace Microsoft.OpenApi.Models
public Microsoft.OpenApi.Models.OpenApiInfo Info { get; set; }
public string? JsonSchemaDialect { get; set; }
public Microsoft.OpenApi.Models.OpenApiPaths Paths { get; set; }
public System.Collections.Generic.IList<Microsoft.OpenApi.Models.OpenApiSecurityRequirement>? SecurityRequirements { get; set; }
public System.Collections.Generic.IList<Microsoft.OpenApi.Models.OpenApiSecurityRequirement>? Security { get; set; }
public System.Collections.Generic.IList<Microsoft.OpenApi.Models.OpenApiServer>? Servers { get; set; }
public System.Collections.Generic.ISet<Microsoft.OpenApi.Models.OpenApiTag>? Tags { get; set; }
public System.Collections.Generic.IDictionary<string, Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem>? Webhooks { get; set; }
Expand Down