Skip to content

Commit

Permalink
Merge branch 'main' into feat/enable-NRT
Browse files Browse the repository at this point in the history
  • Loading branch information
baywet committed Feb 27, 2025
2 parents 07b3a2c + d8553d6 commit cd41026
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 14 deletions.
83 changes: 83 additions & 0 deletions .github/policies/OpenAPI.NET-branch-protection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# File initially created using https://github.com/MIchaelMainer/policyservicetoolkit/blob/main/branch_protection_export.ps1.

name: OpenAPI.NET-branch-protection
description: Branch protection policy for the OpenAPI.NET repository
resource: repository
configuration:
branchProtectionRules:

- branchNamePattern: main
# This branch pattern applies to the following branches as of approximately 02/27/2025 15:28:20:
# main

# Specifies whether this branch can be deleted. boolean
allowsDeletions: false
# Specifies whether forced pushes are allowed on this branch. boolean
allowsForcePushes: false
# Specifies whether new commits pushed to the matching branches dismiss pull request review approvals. boolean
dismissStaleReviews: true
# Specifies whether admins can overwrite branch protection. boolean
isAdminEnforced: true
# Indicates whether "Require a pull request before merging" is enabled. boolean
requiresPullRequestBeforeMerging: true
# Specifies the number of pull request reviews before merging. int (0-6). Should be null/empty if PRs are not required
requiredApprovingReviewsCount: 1
# Require review from Code Owners. Requires requiredApprovingReviewsCount. boolean
requireCodeOwnersReview: true
# Are commits required to be signed. boolean. TODO: all contributors must have commit signing on local machines.
requiresCommitSignatures: false
# Are conversations required to be resolved before merging? boolean
requiresConversationResolution: true
# Are merge commits prohibited from being pushed to this branch. boolean
requiresLinearHistory: false
# Required status checks to pass before merging. Values can be any string, but if the value does not correspond to any existing status check, the status check will be stuck on pending for status since nothing exists to push an actual status
requiredStatusChecks:
- license/cla
- CodeQL
- Continuous Integration
# Require branches to be up to date before merging. boolean
requiresStrictStatusChecks: false
# Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush.
restrictsPushes: false
# Restrict who can dismiss pull request reviews. boolean
restrictsReviewDismissals: false

- branchNamePattern: support/v1
# This branch pattern applies to the following branches as of approximately 02/27/2025 15:28:20:
# support/v1

# Specifies whether this branch can be deleted. boolean
allowsDeletions: false
# Specifies whether forced pushes are allowed on this branch. boolean
allowsForcePushes: false
# Specifies whether new commits pushed to the matching branches dismiss pull request review approvals. boolean
dismissStaleReviews: true
# Specifies whether admins can overwrite branch protection. boolean
isAdminEnforced: true
# Indicates whether "Require a pull request before merging" is enabled. boolean
requiresPullRequestBeforeMerging: true
# Specifies the number of pull request reviews before merging. int (0-6). Should be null/empty if PRs are not required
requiredApprovingReviewsCount: 1
# Require review from Code Owners. Requires requiredApprovingReviewsCount. boolean
requireCodeOwnersReview: true
# Are commits required to be signed. boolean. TODO: all contributors must have commit signing on local machines.
requiresCommitSignatures: false
# Are conversations required to be resolved before merging? boolean
requiresConversationResolution: true
# Are merge commits prohibited from being pushed to this branch. boolean
requiresLinearHistory: false
# Required status checks to pass before merging. Values can be any string, but if the value does not correspond to any existing status check, the status check will be stuck on pending for status since nothing exists to push an actual status
requiredStatusChecks:
- license/cla
- CodeQL
- Continuous Integration
# Require branches to be up to date before merging. boolean
requiresStrictStatusChecks: false
# Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush.
restrictsPushes: false
# Restrict who can dismiss pull request reviews. boolean
restrictsReviewDismissals: false

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![Category overview screenshot](docs/images/oainet.png "Microsoft + OpenAPI = Love")
<!-- using the raw image URL so it displays correctly on nuget.org -->
![Category overview screenshot](https://raw.githubusercontent.com/microsoft/OpenAPI.NET/main/docs/images/oainet.png "Microsoft + OpenAPI = Love")

# OpenAPI.NET

Expand Down Expand Up @@ -109,7 +110,7 @@ In order to test the validity of an OpenApi document, we avail the following too
4. Run the project and you'll see a GUI pop up resembling the one below:


<img src="https://user-images.githubusercontent.com/36787645/235884441-f45d2ef7-c27b-4e1a-a890-d6f7fbef87c3.png" width="700" height="500">
![workbench preview](https://raw.githubusercontent.com/microsoft/OpenAPI.NET/main/docs/images/workbench.png "a screenshot of the workbench application")

5. Copy and paste your OpenAPI descriptions in the **Input Content** window or paste the path to the descriptions file in the **Input File** textbox and click on `Convert` to render the results.

Expand Down
Binary file added docs/images/workbench.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ -370,7 +370,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 @@ -106,7 +106,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, Fu
},

Components = components,
SecurityRequirements = source?.SecurityRequirements,
SecurityRequirements = source?.Security,

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / CodeQL Analysis

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / Validate Project for Trimming

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / Build

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / Build

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / Build

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'

Check failure on line 83 in src/Microsoft.OpenApi/Services/OpenApiFilterService.cs

View workflow job for this annotation

GitHub Actions / Build

'OpenApiDocument' does not contain a definition for 'SecurityRequirements'
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 @@ -717,7 +717,7 @@ namespace Microsoft.OpenApi.Models
public Microsoft.OpenApi.Models.OpenApiInfo Info { get; set; }
public System.Uri? 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

0 comments on commit cd41026

Please sign in to comment.