diff --git a/.vscode/settings.json b/.vscode/settings.json
index 662e126..c6ec83b 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,10 +1,16 @@
{
- "cSpell.words": [
- "CSDL",
- "Edmx",
- "intune",
- "Markdig",
- "Mooncake",
- "olders"
- ]
+ "cSpell.words": [
+ "CSDL",
+ "Edmx",
+ "intune",
+ "Markdig",
+ "Mooncake",
+ "olders"
+ ],
+ "json.schemas": [
+ {
+ "fileMatch": ["cloud-exclusions.json"],
+ "url": "./schema/cloud.exclusions.schema.json"
+ }
+ ]
}
diff --git a/CheckCloudSupport.sln b/CheckCloudSupport.sln
deleted file mode 100644
index 1fa9bf2..0000000
--- a/CheckCloudSupport.sln
+++ /dev/null
@@ -1,28 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.0.31903.59
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CheckCloudSupport", "src\CheckCloudSupport.csproj", "{134E52CE-90B2-4A93-9AC2-01BB1D695961}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CheckCloudSupportTests", "test\CheckCloudSupportTests.csproj", "{400AB96F-5515-4A08-9387-20D7E72CEC10}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {134E52CE-90B2-4A93-9AC2-01BB1D695961}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {134E52CE-90B2-4A93-9AC2-01BB1D695961}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {134E52CE-90B2-4A93-9AC2-01BB1D695961}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {134E52CE-90B2-4A93-9AC2-01BB1D695961}.Release|Any CPU.Build.0 = Release|Any CPU
- {400AB96F-5515-4A08-9387-20D7E72CEC10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {400AB96F-5515-4A08-9387-20D7E72CEC10}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {400AB96F-5515-4A08-9387-20D7E72CEC10}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {400AB96F-5515-4A08-9387-20D7E72CEC10}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
-EndGlobal
diff --git a/CheckCloudSupport.slnx b/CheckCloudSupport.slnx
new file mode 100644
index 0000000..9a7fe0d
--- /dev/null
+++ b/CheckCloudSupport.slnx
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/schema/cloud.exclusions.schema.json b/schema/cloud.exclusions.schema.json
index a9e128a..7563fff 100644
--- a/schema/cloud.exclusions.schema.json
+++ b/schema/cloud.exclusions.schema.json
@@ -14,6 +14,10 @@
"description": "The HTTP method for the API to exclude.",
"type": "string"
},
+ "fileName": {
+ "description": "The API doc file name. Setting this property excludes all APIs in the specified file from the specified cloud.",
+ "type": "string"
+ },
"cloud": {
"description": "The cloud to exclude this API from. Must be 'Global', 'UsGov', or 'China'.",
"type": "string",
@@ -22,13 +26,23 @@
"UsGov",
"China"
]
+ },
+ "description": {
+ "description": "A description of the reason for the exclusion.",
+ "type": "string"
}
},
"required": [
- "apiPath",
- "operation",
"cloud"
],
+ "oneOf": [
+ {
+ "required": ["apiPath", "operation"]
+ },
+ {
+ "required": ["fileName"]
+ }
+ ],
"additionalProperties": false
}
},
diff --git a/src/CheckCloudSupport.csproj b/src/CheckCloudSupport.csproj
index e8cff24..2ff1f2a 100644
--- a/src/CheckCloudSupport.csproj
+++ b/src/CheckCloudSupport.csproj
@@ -14,7 +14,7 @@
-
+
diff --git a/src/Extensions/OpenApiUrlTreeNodeExtensions.cs b/src/Extensions/OpenApiUrlTreeNodeExtensions.cs
index 939484a..b7b4065 100644
--- a/src/Extensions/OpenApiUrlTreeNodeExtensions.cs
+++ b/src/Extensions/OpenApiUrlTreeNodeExtensions.cs
@@ -99,27 +99,35 @@ public static class OpenApiUrlTreeNodeExtensions
///
/// The API URL node to check.
/// The HTTP method to check for.
+ /// The API document file path.
/// The indicating the cloud support status of the API.
- public static CloudSupportStatus GetCloudSupportStatus(this OpenApiUrlTreeNode node, HttpMethod? method)
+ public static CloudSupportStatus GetCloudSupportStatus(
+ this OpenApiUrlTreeNode node,
+ HttpMethod? method,
+ string filePath)
{
if (method == null)
{
return CloudSupportStatus.Unknown;
}
+ var fileName = Path.GetFileName(filePath);
+
if (node.Path.EndsWith("\\bundles\\{driveItem-id}"))
- {
- method = HttpMethod.Get;
- }
+ {
+ method = HttpMethod.Get;
+ }
var supportsGlobal = node.PathItems.ContainsKey("Global") &&
(node.PathItems["Global"].Operations?.ContainsKey(method) ?? false);
var supportsUsGov = node.PathItems.ContainsKey("UsGov") &&
(node.PathItems["UsGov"].Operations?.ContainsKey(method) ?? false) &&
- !OpenAPIOverrides.CheckIfCloudExcluded(node.Path, method, "UsGov");
+ !OpenAPIOverrides.CheckIfCloudExcluded(node.Path, method, "UsGov") &&
+ !OpenAPIOverrides.CheckIfCloudExcludedForFile(fileName, "UsGov");
var supportsChina = node.PathItems.ContainsKey("China") &&
(node.PathItems["China"].Operations?.ContainsKey(method) ?? false) &&
- !OpenAPIOverrides.CheckIfCloudExcluded(node.Path, method, "China");
+ !OpenAPIOverrides.CheckIfCloudExcluded(node.Path, method, "China") &&
+ !OpenAPIOverrides.CheckIfCloudExcludedForFile(fileName, "China");
if (!supportsGlobal)
{
diff --git a/src/OpenAPI/CloudExclusion.cs b/src/OpenAPI/CloudExclusion.cs
index aa54fde..222ced9 100644
--- a/src/OpenAPI/CloudExclusion.cs
+++ b/src/OpenAPI/CloudExclusion.cs
@@ -24,6 +24,13 @@ public class CloudExclusion
[JsonPropertyName("operation")]
public string? Operation { get; set; }
+ ///
+ /// Gets or sets the API doc file name. Setting this property excludes
+ /// all APIs in the specified file from the specified cloud.
+ ///
+ [JsonPropertyName("fileName")]
+ public string? FileName { get; set; }
+
///
/// Gets or sets the cloud to exclude.
///
diff --git a/src/OpenAPI/OpenAPIOverrides.cs b/src/OpenAPI/OpenAPIOverrides.cs
index 8465483..c6dd7ba 100644
--- a/src/OpenAPI/OpenAPIOverrides.cs
+++ b/src/OpenAPI/OpenAPIOverrides.cs
@@ -58,6 +58,19 @@ public static bool CheckIfCloudExcluded(string apiPath, HttpMethod? method, stri
string.Compare(e.Cloud, cloud, StringComparison.InvariantCultureIgnoreCase) == 0) ?? false;
}
+ ///
+ /// Checks if a cloud is excluded for a given API doc file. This is used to exclude entire
+ /// files of APIs that don't function in certain clouds, even if the individual API paths aren't known.
+ ///
+ /// The name of the API doc file to check for an exclusion for.
+ /// The cloud to check.
+ /// True if the given cloud is excluded for the specified file.
+ public static bool CheckIfCloudExcludedForFile(string fileName, string cloud)
+ {
+ return cloudExclusions?.Any(e => string.Compare(e.FileName, fileName, StringComparison.InvariantCultureIgnoreCase) == 0 &&
+ string.Compare(e.Cloud, cloud, StringComparison.InvariantCultureIgnoreCase) == 0) ?? false;
+ }
+
private static void LoadOverridesFromJson(string? jsonFile)
{
if (!string.IsNullOrEmpty(jsonFile))
diff --git a/src/Program.cs b/src/Program.cs
index 835d346..5c7501d 100644
--- a/src/Program.cs
+++ b/src/Program.cs
@@ -148,7 +148,7 @@
continue;
}
- var supportStatus = operationNode.GetCloudSupportStatus(operation.Method);
+ var supportStatus = operationNode.GetCloudSupportStatus(operation.Method, apiDoc.FilePath);
OutputLogger.Logger?.LogInformation("{path} support status: {status}", operation.Path, supportStatus);
if (supportStatus != CloudSupportStatus.Unknown &&
apiDoc.CloudSupportStatus != CloudSupportStatus.Unknown &&
@@ -327,7 +327,7 @@
continue;
}
- var supportStatus = operationNode.GetCloudSupportStatus(operation.Method);
+ var supportStatus = operationNode.GetCloudSupportStatus(operation.Method, apiDoc.FilePath);
OutputLogger.Logger?.LogInformation("{version} {path} support status: {status}", "v1", operation.Path, supportStatus);
if (supportStatus != CloudSupportStatus.Unknown &&
v1CloudSupportStatus != CloudSupportStatus.Unknown &&
@@ -364,7 +364,7 @@
continue;
}
- var supportStatus = operationNode.GetCloudSupportStatus(operation.Method);
+ var supportStatus = operationNode.GetCloudSupportStatus(operation.Method, apiDoc.FilePath);
OutputLogger.Logger?.LogInformation("{version} {path} support status: {status}", "beta", operation.Path, supportStatus);
if (supportStatus != CloudSupportStatus.Unknown &&
betaCloudSupportStatus != CloudSupportStatus.Unknown &&
diff --git a/test/CheckCloudSupportTests.csproj b/test/CheckCloudSupportTests.csproj
index b15786d..96ccb65 100644
--- a/test/CheckCloudSupportTests.csproj
+++ b/test/CheckCloudSupportTests.csproj
@@ -16,7 +16,7 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all