Cleaned up documentation. Implemented named parameters option for Javascript generator. Bumped package version to 1.9.0

This commit is contained in:
2025-10-12 13:39:55 -07:00
parent e8e8efc00d
commit f6b01af770
3 changed files with 19 additions and 8 deletions

View File

@@ -17,7 +17,7 @@
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Version>1.8.9</Version>
<Version>1.9.0</Version>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>

View File

@@ -16,15 +16,21 @@ namespace MontoyaTech.Rest.Net
public class RestJavascriptClientGenerator : RestClientGenerator
{
/// <summary>
/// Whether or not to generate static code, if true the client will be static.
/// Whether or not to generate static code, if true the client will be static. Default is false.
/// </summary>
public bool StaticCode = false;
/// <summary>
/// Whether or not to use Json Property names instead of the Field/Property names.
/// Whether or not to use Json Property names instead of the Field/Property names. Default is false.
/// </summary>
public bool UseJsonNames = false;
/// <summary>
/// Whether or not to generate route functions to accept named parameters instead
/// of positional ones. Default is false.
/// </summary>
public bool NamedParameters = false;
/// <summary>
/// Generates a Javascript Client from a given set of routes and returns it.
/// </summary>
@@ -367,6 +373,7 @@ namespace MontoyaTech.Rest.Net
writer.Outdent().WriteLine("*/");
writer.Write("constructor(");
writer.WriteAssert(this.UseJsonNames, "{");
//Write the default fields
foreach (var field in fields)
@@ -386,6 +393,7 @@ namespace MontoyaTech.Rest.Net
writer.WriteSeparator().Write(EscapeName(property.Name)).Write(" = ").Write(this.GetTypeDefaultValue(property.PropertyType));
}
writer.WriteAssert(this.UseJsonNames, "} = {}");
writer.WriteLine(") {").Indent();
//Init the default fields

View File

@@ -237,8 +237,8 @@ namespace MontoyaTech.Rest.Net
/// <summary>
/// Generates a C# client from this Route Listener and returns the code.
/// </summary>
/// <param name="clientName">The name of the Client. Default is Client.</param>
/// <param name="staticCode">Whether or not to generate a static client.</param>
/// <param name="clientName">The name of the Client class. Default is Client.</param>
/// <param name="staticCode">Whether or not to generate a static client. Default is false.</param>
/// <returns></returns>
public string GenerateCSharpClient(string clientName = "Client", bool staticCode = false)
{
@@ -253,16 +253,19 @@ namespace MontoyaTech.Rest.Net
/// <summary>
/// Generates a Javascript client from this Route Listener and returns the code.
/// </summary>
/// <param name="clientName"></param>
/// <param name="staticCode"></param>
/// <param name="clientName">The name of the Client class. Default is Client.</param>
/// <param name="staticCode">Whether or not to generate a static client. Default is false.</param>
/// <param name="useJsonNames">Whether or not to use JSON Property name overrides during code generation. Default is false.</param>
/// <param name="namedParameters">Whether or not to generate routes that use named parameters over positional parameters. Default is false.</param>
/// <returns></returns>
public string GenerateJavascriptClient(string clientName = "Client", bool staticCode = false, bool useJsonNames = false)
public string GenerateJavascriptClient(string clientName = "Client", bool staticCode = false, bool useJsonNames = false, bool namedParameters = false)
{
var generator = new RestJavascriptClientGenerator();
generator.ClientName = clientName;
generator.StaticCode = staticCode;
generator.UseJsonNames = useJsonNames;
generator.NamedParameters = namedParameters;
return generator.Generate(this);
}