Skip to content

Commit

Permalink
Add option to specify the permissions source file to use with Kibali …
Browse files Browse the repository at this point in the history
…during permission tables generation
  • Loading branch information
millicentachieng committed Feb 22, 2023
1 parent f684836 commit 585566a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions ApiDoctor.Console/ApiDoctor.ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Graph.Kibali" Version="0.6.0-preview" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
</Project>
22 changes: 20 additions & 2 deletions ApiDoctor.Console/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace ApiDoctor.ConsoleApp
using ApiDoctor.Validation;
using ApiDoctor.Validation.Writers;
using CommandLine;
using CommandLine.Text;
using Publishing.CSDL;

class CommandLineOptions
Expand Down Expand Up @@ -620,9 +619,28 @@ class DeduplicateExampleNamesOptions : BasicCheckOptions
}

[Verb(CommandLineOptions.VerbGeneratePermissionFiles, HelpText = "Generate permission files for operation topics, optionally enable bootstrapping.")]
class GeneratePermissionFilesOptions: DocSetOptions
class GeneratePermissionFilesOptions: BasicCheckOptions
{
[Option("bootstrapping-only", HelpText = "If set to true, moves permissions table in reference document to own file but will not update contents of permissions table.")]
public bool BootstrappingOnly { get; set; } = false;

[Option("permissions-source-file", HelpText = "The file path or URL to permissions in JSON format to be consumed by Kibali")]
public string PermissionsSourceFile { get; set; }

public override bool HasRequiredProperties(out string[] missingArguments)
{
if (!base.HasRequiredProperties(out missingArguments))
return false;

if (!this.BootstrappingOnly && string.IsNullOrWhiteSpace(this.PermissionsSourceFile))
{
missingArguments = new string[] { "The file path or URL to JSON permissions file has not been specified." };
}
else
{
missingArguments = Array.Empty<string>();
}
return !missingArguments.Any();
}
}
}

0 comments on commit 585566a

Please sign in to comment.