Skip to content

Commit

Permalink
Merge pull request #745 from microsoft/mk/feature/add-constants
Browse files Browse the repository at this point in the history
Adds Constants for the Scheme and Bearer format types
  • Loading branch information
darrelmiller authored Feb 22, 2022
2 parents 8e04fd1 + 0f1350d commit ad36f92
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 19 deletions.
10 changes: 3 additions & 7 deletions Microsoft.OpenApi.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
# Visual Studio Version 17
VisualStudioVersion = 17.1.32210.238
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi", "src\Microsoft.OpenApi\Microsoft.OpenApi.csproj", "{A8E50143-69B2-472A-9D45-3F9A05D13202}"
EndProject
Expand All @@ -12,7 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
readme.md = readme.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.OpenApi.Workbench", "src\Microsoft.OpenApi.Workbench\Microsoft.OpenApi.Workbench.csproj", "{6A5E91E5-0441-46EE-AEB9-8334981B7F08}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Workbench", "src\Microsoft.OpenApi.Workbench\Microsoft.OpenApi.Workbench.csproj", "{6A5E91E5-0441-46EE-AEB9-8334981B7F08}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Readers", "src\Microsoft.OpenApi.Readers\Microsoft.OpenApi.Readers.csproj", "{79933258-0126-4382-8755-D50820ECC483}"
EndProject
Expand All @@ -38,10 +38,6 @@ Global
{A8E50143-69B2-472A-9D45-3F9A05D13202}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8E50143-69B2-472A-9D45-3F9A05D13202}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8E50143-69B2-472A-9D45-3F9A05D13202}.Release|Any CPU.Build.0 = Release|Any CPU
{6A5E91E5-0441-46EE-AEB9-8334981B7F08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A5E91E5-0441-46EE-AEB9-8334981B7F08}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A5E91E5-0441-46EE-AEB9-8334981B7F08}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A5E91E5-0441-46EE-AEB9-8334981B7F08}.Release|Any CPU.Build.0 = Release|Any CPU
{79933258-0126-4382-8755-D50820ECC483}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{79933258-0126-4382-8755-D50820ECC483}.Debug|Any CPU.Build.0 = Debug|Any CPU
{79933258-0126-4382-8755-D50820ECC483}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal static partial class OpenApiV2Deserializer
{
case "basic":
o.Type = SecuritySchemeType.Http;
o.Scheme = "basic";
o.Scheme = OpenApiConstants.Basic;
break;

case "apiKey":
Expand Down
10 changes: 10 additions & 0 deletions src/Microsoft.OpenApi/Models/OpenApiConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,16 @@ public static class OpenApiConstants
/// </summary>
public const string Basic = "basic";

/// <summary>
/// Field: Bearer
/// </summary>
public const string Bearer = "bearer";

/// <summary>
/// Field: JWT
/// </summary>
public const string Jwt = "JWT";

/// <summary>
/// Field: Consumes
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void ParseHttpSecuritySchemeShouldSucceed()
new OpenApiSecurityScheme
{
Type = SecuritySchemeType.Http,
Scheme = "basic"
Scheme = OpenApiConstants.Basic
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void ParseHttpSecuritySchemeShouldSucceed()
new OpenApiSecurityScheme
{
Type = SecuritySchemeType.Http,
Scheme = "basic"
Scheme = OpenApiConstants.Basic
});
}
}
Expand Down Expand Up @@ -95,8 +95,8 @@ public void ParseBearerSecuritySchemeShouldSucceed()
new OpenApiSecurityScheme
{
Type = SecuritySchemeType.Http,
Scheme = "bearer",
BearerFormat = "JWT"
Scheme = OpenApiConstants.Bearer,
BearerFormat = OpenApiConstants.Jwt
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class OpenApiComponentsTests
{
Description = "description1",
Type = SecuritySchemeType.OpenIdConnect,
Scheme = "openIdConnectUrl",
Scheme = OpenApiConstants.Bearer,
OpenIdConnectUrl = new Uri("https://example.com/openIdConnect")
}
}
Expand Down Expand Up @@ -129,7 +129,7 @@ public class OpenApiComponentsTests
{
Description = "description1",
Type = SecuritySchemeType.OpenIdConnect,
Scheme = "openIdConnectUrl",
Scheme = OpenApiConstants.Bearer,
OpenIdConnectUrl = new Uri("https://example.com/openIdConnect"),
Reference = new OpenApiReference
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ public class OpenApiSecuritySchemeTests
{
Description = "description1",
Type = SecuritySchemeType.Http,
Scheme = "basic",
Scheme = OpenApiConstants.Basic

};

public static OpenApiSecurityScheme HttpBearerSecurityScheme = new OpenApiSecurityScheme
{
Description = "description1",
Type = SecuritySchemeType.Http,
Scheme = "bearer",
BearerFormat = "JWT",
Scheme = OpenApiConstants.Bearer,
BearerFormat = OpenApiConstants.Jwt
};

public static OpenApiSecurityScheme OAuth2SingleFlowSecurityScheme = new OpenApiSecurityScheme
Expand Down Expand Up @@ -103,15 +104,15 @@ public class OpenApiSecuritySchemeTests
{
Description = "description1",
Type = SecuritySchemeType.OpenIdConnect,
Scheme = "openIdConnectUrl",
Scheme = OpenApiConstants.Bearer,
OpenIdConnectUrl = new Uri("https://example.com/openIdConnect")
};

public static OpenApiSecurityScheme ReferencedSecurityScheme = new OpenApiSecurityScheme
{
Description = "description1",
Type = SecuritySchemeType.OpenIdConnect,
Scheme = "openIdConnectUrl",
Scheme = OpenApiConstants.Bearer,
OpenIdConnectUrl = new Uri("https://example.com/openIdConnect"),
Reference = new OpenApiReference
{
Expand Down

0 comments on commit ad36f92

Please sign in to comment.