Cleaned up documentation. Implemented named parameters option for Javascript generator. Bumped package version to 1.9.0
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
|
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
|
||||||
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
|
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
|
||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<Version>1.8.9</Version>
|
<Version>1.9.0</Version>
|
||||||
<PackageReleaseNotes></PackageReleaseNotes>
|
<PackageReleaseNotes></PackageReleaseNotes>
|
||||||
<PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon>
|
<PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon>
|
||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
|
@@ -16,15 +16,21 @@ namespace MontoyaTech.Rest.Net
|
|||||||
public class RestJavascriptClientGenerator : RestClientGenerator
|
public class RestJavascriptClientGenerator : RestClientGenerator
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public bool StaticCode = false;
|
public bool StaticCode = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public bool UseJsonNames = false;
|
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>
|
/// <summary>
|
||||||
/// Generates a Javascript Client from a given set of routes and returns it.
|
/// Generates a Javascript Client from a given set of routes and returns it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -367,6 +373,7 @@ namespace MontoyaTech.Rest.Net
|
|||||||
|
|
||||||
writer.Outdent().WriteLine("*/");
|
writer.Outdent().WriteLine("*/");
|
||||||
writer.Write("constructor(");
|
writer.Write("constructor(");
|
||||||
|
writer.WriteAssert(this.UseJsonNames, "{");
|
||||||
|
|
||||||
//Write the default fields
|
//Write the default fields
|
||||||
foreach (var field in 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.WriteSeparator().Write(EscapeName(property.Name)).Write(" = ").Write(this.GetTypeDefaultValue(property.PropertyType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
writer.WriteAssert(this.UseJsonNames, "} = {}");
|
||||||
writer.WriteLine(") {").Indent();
|
writer.WriteLine(") {").Indent();
|
||||||
|
|
||||||
//Init the default fields
|
//Init the default fields
|
||||||
|
@@ -237,8 +237,8 @@ namespace MontoyaTech.Rest.Net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates a C# client from this Route Listener and returns the code.
|
/// Generates a C# client from this Route Listener and returns the code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="clientName">The name of the Client. Default is 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.</param>
|
/// <param name="staticCode">Whether or not to generate a static client. Default is false.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GenerateCSharpClient(string clientName = "Client", bool staticCode = false)
|
public string GenerateCSharpClient(string clientName = "Client", bool staticCode = false)
|
||||||
{
|
{
|
||||||
@@ -253,16 +253,19 @@ namespace MontoyaTech.Rest.Net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates a Javascript client from this Route Listener and returns the code.
|
/// Generates a Javascript client from this Route Listener and returns the code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="clientName"></param>
|
/// <param name="clientName">The name of the Client class. Default is Client.</param>
|
||||||
/// <param name="staticCode"></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>
|
/// <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();
|
var generator = new RestJavascriptClientGenerator();
|
||||||
|
|
||||||
generator.ClientName = clientName;
|
generator.ClientName = clientName;
|
||||||
generator.StaticCode = staticCode;
|
generator.StaticCode = staticCode;
|
||||||
generator.UseJsonNames = useJsonNames;
|
generator.UseJsonNames = useJsonNames;
|
||||||
|
generator.NamedParameters = namedParameters;
|
||||||
|
|
||||||
return generator.Generate(this);
|
return generator.Generate(this);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user