Skip to content

Commit

Permalink
fix: Position field now emits also 0 values in JSON (#23)
Browse files Browse the repository at this point in the history
### 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

Manually override the setting for those fields in these models.

Currently supported:
 - `src/TalonOne/Model/CartItem.cs`'s `Position` property
 - `src/TalonOne/Model/ReturnedCartItem.cs`'s `Position` property
 - `src/TalonOne/Model/SetDiscountPerItemEffectProps.cs`'s `Position` property
 
### Notes
 - This is a similar problem to the one fixed in #19 , with a couple of new Models
  • Loading branch information
altJake authored Mar 27, 2022
1 parent bc2fd37 commit 07c63af
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ endif
--rm \
-v $(PWD):/tmp/talon-client \
-w "/tmp/talon-client/$(BUILD_DIR)" \
mcr.microsoft.com/dotnet/sdk:3.1-focal-arm64v8 \
mcr.microsoft.com/dotnet/sdk:3.1-focal \
dotnet pack TalonOne.csproj \
-p:PackageVersion=$(VERSION) \
--output . \
Expand All @@ -34,7 +34,7 @@ endif
--rm \
-v $(PWD):/tmp/talon-client \
-w "/tmp/talon-client/$(BUILD_DIR)" \
mcr.microsoft.com/dotnet/sdk:3.1-focal-arm64v8 \
mcr.microsoft.com/dotnet/sdk:3.1-focal \
dotnet nuget push TalonOne.$(VERSION).nupkg \
--api-key $(apiKey) \
--source https://api.nuget.org/v3/index.json
Expand All @@ -44,5 +44,5 @@ testenv:
--rm -it \
-v $(PWD):/tmp/talon-client \
-w /tmp/talon-client \
mcr.microsoft.com/dotnet/sdk:3.1-focal-arm64v8 \
mcr.microsoft.com/dotnet/sdk:3.1-focal \
/bin/bash
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.3
- SDK version: 4.0.4
- 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.3";
public const string Version = "4.0.4";

/// <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.3/csharp";
UserAgent = "OpenAPI-Generator/4.0.4/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.3\n";
report += " SDK Package Version: 4.0.4\n";

return report;
}
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 @@ -152,7 +152,7 @@ protected CartItem() { }
/// Position of the Cart Item in the Cart (calculated internally)
/// </summary>
/// <value>Position of the Cart Item in the Cart (calculated internally)</value>
[DataMember(Name="position", EmitDefaultValue=false)]
[DataMember(Name="position", EmitDefaultValue=true)]
public decimal Position { get; set; }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/TalonOne/Model/ReturnedCartItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected ReturnedCartItem() { }
/// The index of the cart item in the provided customer session&#39;s &#x60;cartItems&#x60; property.
/// </summary>
/// <value>The index of the cart item in the provided customer session&#39;s &#x60;cartItems&#x60; property.</value>
[DataMember(Name="position", EmitDefaultValue=false)]
[DataMember(Name="position", EmitDefaultValue=true)]
public int Position { get; set; }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/TalonOne/Model/SetDiscountPerItemEffectProps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected SetDiscountPerItemEffectProps() { }
/// The index of the item in the cart items list on which this discount should be applied.
/// </summary>
/// <value>The index of the item in the cart items list on which this discount should be applied.</value>
[DataMember(Name="position", EmitDefaultValue=false)]
[DataMember(Name="position", EmitDefaultValue=true)]
public decimal Position { 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.3")]
[assembly: AssemblyFileVersion("4.0.3")]
[assembly: AssemblyVersion("4.0.4")]
[assembly: AssemblyFileVersion("4.0.4")]

0 comments on commit 07c63af

Please sign in to comment.