Skip to content

Commit

Permalink
Merge pull request #1010 from christianhelle/kiota-v1.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
christianhelle authored Oct 4, 2024
2 parents 0fbb5fa + 62f8028 commit aca0ac6
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 36 deletions.
6 changes: 6 additions & 0 deletions src/CLI/ApiClientCodeGen.CLI/Commands/CSharp/KiotaCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ public override ICodeGenerator CreateGenerator() =>
LongName = "generate-multiple-files",
Description = "Set this to TRUE to generate multiple files (default: FALSE)")]
public bool GenerateMultipleFiles { get; set; }

[Option(
ShortName = "tam",
LongName = "type-access-modifier",
Description = "Set the access modifier for the generated types (default: public)")]
public TypeAccessModifier TypeAccessModifier { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ public string GenerateCode(IProgressReporter? pGenerateProgress)

private void RunKiotaGenerate(string outputFolder)
{
var arguments = $" generate -l CSharp -d \"{swaggerFile}\" -o \"{outputFolder}\" -n {defaultNamespace}";
var arguments = $" generate " +
$"-l CSharp " +
$"-d \"{swaggerFile}\" " +
$"-o \"{outputFolder}\" " +
$"-n {defaultNamespace} " +
$"--type-access-modifier {options.TypeAccessModifier}";

using var context = new DependencyContext("Kiota", $"{Command} {arguments}");
processLauncher.Start(Command, arguments);
context.Succeeded();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,55 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

public class KiotaConfiguration
{
[JsonPropertyName("descriptionHash")]
public string? DescriptionHash { get; set; }
namespace Rapicgen.Core.Generators.Kiota;

[JsonPropertyName("descriptionLocation")]
public string? DescriptionLocation { get; set; }
public class KiotaConfiguration
{
[JsonPropertyName("descriptionHash")]
public string? DescriptionHash { get; set; }

[JsonPropertyName("lockFileVersion")]
public string? LockFileVersion { get; set; }
[JsonPropertyName("descriptionLocation")]
public string? DescriptionLocation { get; set; }

[JsonPropertyName("kiotaVersion")]
public string? KiotaVersion { get; set; }
[JsonPropertyName("lockFileVersion")]
public string? LockFileVersion { get; set; }

[JsonPropertyName("clientClassName")]
public string? ClientClassName { get; set; }
[JsonPropertyName("kiotaVersion")]
public string? KiotaVersion { get; set; }

[JsonPropertyName("clientNamespaceName")]
public string? ClientNamespaceName { get; set; }
[JsonPropertyName("clientClassName")]
public string? ClientClassName { get; set; }

[JsonPropertyName("typeAccessModifier")]
public TypeAccessModifier? TypeAccessModifier { get; set; }

[JsonPropertyName("language")]
public string? Language { get; set; }
[JsonPropertyName("clientNamespaceName")]
public string? ClientNamespaceName { get; set; }

[JsonPropertyName("usesBackingStore")]
public bool UsesBackingStore { get; set; }
[JsonPropertyName("language")]
public string? Language { get; set; }

[JsonPropertyName("includeAdditionalData")]
public bool IncludeAdditionalData { get; set; }
[JsonPropertyName("usesBackingStore")]
public bool UsesBackingStore { get; set; }

[JsonPropertyName("serializers")]
public List<string>? Serializers { get; set; }
[JsonPropertyName("includeAdditionalData")]
public bool IncludeAdditionalData { get; set; }

[JsonPropertyName("deserializers")]
public List<string>? Deserializers { get; set; }
[JsonPropertyName("serializers")]
public List<string>? Serializers { get; set; }

[JsonPropertyName("structuredMimeTypes")]
public List<string>? StructuredMimeTypes { get; set; }
[JsonPropertyName("deserializers")]
public List<string>? Deserializers { get; set; }

[JsonPropertyName("includePatterns")]
public List<string>? IncludePatterns { get; set; }
[JsonPropertyName("structuredMimeTypes")]
public List<string>? StructuredMimeTypes { get; set; }

[JsonPropertyName("excludePatterns")]
public List<string>? ExcludePatterns { get; set; }
[JsonPropertyName("includePatterns")]
public List<string>? IncludePatterns { get; set; }

[JsonPropertyName("disabledValidationRules")]
public List<object>? DisabledValidationRules { get; set; }
}
[JsonPropertyName("excludePatterns")]
public List<string>? ExcludePatterns { get; set; }

[JsonPropertyName("disabledValidationRules")]
public List<object>? DisabledValidationRules { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Text.Json.Serialization;

namespace Rapicgen.Core.Generators.Kiota;

[JsonConverter(typeof(JsonStringEnumConverter))]
public enum TypeAccessModifier
{
Public,
Internal,
Private,
Protected
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
namespace Rapicgen.Core.Options.Kiota
using Rapicgen.Core.Generators.Kiota;

namespace Rapicgen.Core.Options.Kiota
{
public class DefaultKiotaOptions : IKiotaOptions
{
public bool GenerateMultipleFiles { get; set; } = false;
public TypeAccessModifier TypeAccessModifier { get; set; } = TypeAccessModifier.Public;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
namespace Rapicgen.Core.Options.Kiota
using Rapicgen.Core.Generators.Kiota;

namespace Rapicgen.Core.Options.Kiota
{
public interface IKiotaOptions
{
bool GenerateMultipleFiles { get; }

TypeAccessModifier TypeAccessModifier { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Rapicgen.Core.Generators.Kiota;
using Rapicgen.Core.Logging;
using Rapicgen.Core.Options.Kiota;

Expand All @@ -13,6 +14,7 @@ public KiotaOptions(IKiotaOptions? options = null)
{
options ??= GetFromDialogPage();
GenerateMultipleFiles = options.GenerateMultipleFiles;
TypeAccessModifier = options.TypeAccessModifier;
}
catch (Exception e)
{
Expand All @@ -23,9 +25,11 @@ public KiotaOptions(IKiotaOptions? options = null)
Logger.Instance.WriteLine("GenerateMultipleFiles = false");

GenerateMultipleFiles = false;
TypeAccessModifier = TypeAccessModifier.Public;
}
}

public bool GenerateMultipleFiles { get; }
public TypeAccessModifier TypeAccessModifier { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Rapicgen.Core.Options.Kiota;
using Microsoft.VisualStudio.Shell;
using System.Runtime.InteropServices;
using Rapicgen.Core.Generators.Kiota;

namespace Rapicgen.Options.Kiota
{
Expand All @@ -16,5 +17,10 @@ public class KiotaOptionsPage : DialogPage, IKiotaOptions
[DisplayName("Generate Multiple Files")]
[Description("Generate multiple files for each operation. This only works for SDK style projects")]
public bool GenerateMultipleFiles { get; set; }

[Category(Name)]
[DisplayName("Type Access Modifier")]
[Description("The access modifier for the generated types")]
public TypeAccessModifier TypeAccessModifier { get; set; }
}
}

0 comments on commit aca0ac6

Please sign in to comment.