Skip to content

Commit

Permalink
fix: Price which is set to 0 for CartItem / AdditionalCost are not …
Browse files Browse the repository at this point in the history
…ignored (#19)

### Problem
Open API Generator sets `DataMember` attribute's `EmitDefaultValue` per default to `false`.

Unfortunately for some of our data models, it means that the emitted JSON for decimal values of `0` are ignored.

### Solution
There's no nice way to address the problem gracefully using a configuration value for the Open API Generator, so currently we manually override the setting for those models.

Currently supported:
 - `CartItem`'s `Price` property
 - `AdditionalCost`'s `Price` property

### Commit Summary
* Force emitting default value of CartItem price (0-value decimal)
* Also force emitting of zero values for additional costs's price
* Bump version to 4.0.2
  • Loading branch information
altJake authored Nov 8, 2021
1 parent 7cea788 commit 112ade2
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ is `https://mycompany.talon.one/v2/customer_sessions/{Id}`
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 1.0.0
- SDK version: 4.0.1
- SDK version: 4.0.2
- Build package: org.openapitools.codegen.languages.CSharpNetCoreClientCodegen

<a name="frameworks-supported"></a>
Expand Down
6 changes: 3 additions & 3 deletions src/TalonOne/Client/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Configuration : IReadableConfiguration
/// Version of the package.
/// </summary>
/// <value>Version of the package.</value>
public const string Version = "4.0.1";
public const string Version = "4.0.2";

/// <summary>
/// Identifier for ISO 8601 DateTime Format
Expand Down Expand Up @@ -96,7 +96,7 @@ public class Configuration : IReadableConfiguration
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")]
public Configuration()
{
UserAgent = "OpenAPI-Generator/4.0.1/csharp";
UserAgent = "OpenAPI-Generator/4.0.2/csharp";
BasePath = "http://localhost";
DefaultHeaders = new ConcurrentDictionary<string, string>();
ApiKey = new ConcurrentDictionary<string, string>();
Expand Down Expand Up @@ -351,7 +351,7 @@ public static String ToDebugReport()
String report = "C# SDK (TalonOne) Debug Report:\n";
report += " OS: " + System.Runtime.InteropServices.RuntimeInformation.OSDescription + "\n";
report += " Version of the API: 1.0.0\n";
report += " SDK Package Version: 4.0.1\n";
report += " SDK Package Version: 4.0.2\n";

return report;
}
Expand Down
2 changes: 1 addition & 1 deletion src/TalonOne/Model/AdditionalCost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected AdditionalCost() { }
/// <summary>
/// Gets or Sets Price
/// </summary>
[DataMember(Name="price", EmitDefaultValue=false)]
[DataMember(Name="price", EmitDefaultValue=true)]
public decimal Price { get; set; }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/TalonOne/Model/CartItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected CartItem() { }
/// Price of item
/// </summary>
/// <value>Price of item</value>
[DataMember(Name="price", EmitDefaultValue=false)]
[DataMember(Name="price", EmitDefaultValue=true)]
public decimal Price { get; set; }

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/TalonOne/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.0.1")]
[assembly: AssemblyFileVersion("4.0.1")]
[assembly: AssemblyVersion("4.0.2")]
[assembly: AssemblyFileVersion("4.0.2")]

0 comments on commit 112ade2

Please sign in to comment.