From e2130bd881ca4023251c078c29ea52e3d8494a61 Mon Sep 17 00:00:00 2001 From: Xiaogang Date: Fri, 18 Oct 2024 09:51:00 +0800 Subject: [PATCH] SDK - Add support for decimal (#1392) --- powershell/sdk/utility.ts | 6 +++-- .../model-validate/csharp/Models/Operation.cs | 26 ++++++++++++++++++- .../model-validate/swagger.json | 15 +++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/powershell/sdk/utility.ts b/powershell/sdk/utility.ts index 1b60ed3eaa1..ceb415cf40b 100644 --- a/powershell/sdk/utility.ts +++ b/powershell/sdk/utility.ts @@ -30,7 +30,7 @@ export class Helper { public GetCsharpType(schema: Schema): string { let type = schema.type; - if (schema.type === SchemaType.Integer) { + if (schema.type === SchemaType.Integer || schema.type === SchemaType.Number) { type = type + (schema).precision; } const offset = this.useDateTimeOffset ? 'Offset' : ''; @@ -38,7 +38,9 @@ export class Helper { ['integer', 'int'], ['integer32', 'int'], ['integer64', 'long'], - ['number', 'double'], + ['number32', 'double'], + ['number64', 'double'], + ['number128', 'decimal'], ['boolean', 'bool'], ['string', 'string'], ['unixtime', 'System.DateTime'], diff --git a/tests-upgrade/tests-sdk1-support/model-validate/csharp/Models/Operation.cs b/tests-upgrade/tests-sdk1-support/model-validate/csharp/Models/Operation.cs index 2169cc2dd3d..38144de31c1 100644 --- a/tests-upgrade/tests-sdk1-support/model-validate/csharp/Models/Operation.cs +++ b/tests-upgrade/tests-sdk1-support/model-validate/csharp/Models/Operation.cs @@ -45,13 +45,16 @@ public Operation() /// This is byte array /// This is boolean /// This is number + /// This is number + /// This is number + /// This is number /// This is constant. Possible values /// include: 'const' /// This is choice. Possible values include: /// 'choice1', 'choice2' /// This is sealed choice. Possible /// values include: 'sealedchoice1', 'sealedchoice2' - public Operation(string typeString, int typeInteger, System.Collections.Generic.IList typeArray, object typeAny = default(object), System.Collections.Generic.IDictionary typeDictionary = default(System.Collections.Generic.IDictionary), OperationTypeObject typeObject = default(OperationTypeObject), System.DateTime? typeTime = default(System.DateTime?), string typeCredential = default(string), byte[] typeBinary = default(byte[]), System.TimeSpan? typeDuration = default(System.TimeSpan?), string typeUri = default(string), System.Guid? typeUuid = default(System.Guid?), System.DateTime? typeDateTime = default(System.DateTime?), System.DateTime? typeDate = default(System.DateTime?), byte[] typeByteArray = default(byte[]), bool? typeBoolean = default(bool?), double? typeNumber = default(double?), string typeConstant = default(string), string typeChoice = default(string), string typeSealedChoice = default(string)) + public Operation(string typeString, int typeInteger, System.Collections.Generic.IList typeArray, object typeAny = default(object), System.Collections.Generic.IDictionary typeDictionary = default(System.Collections.Generic.IDictionary), OperationTypeObject typeObject = default(OperationTypeObject), System.DateTime? typeTime = default(System.DateTime?), string typeCredential = default(string), byte[] typeBinary = default(byte[]), System.TimeSpan? typeDuration = default(System.TimeSpan?), string typeUri = default(string), System.Guid? typeUuid = default(System.Guid?), System.DateTime? typeDateTime = default(System.DateTime?), System.DateTime? typeDate = default(System.DateTime?), byte[] typeByteArray = default(byte[]), bool? typeBoolean = default(bool?), double? typeNumber = default(double?), double? typeNumber32 = default(double?), double? typeNumber64 = default(double?), decimal? typeNumber128 = default(decimal?), string typeConstant = default(string), string typeChoice = default(string), string typeSealedChoice = default(string)) { this.TypeAny = typeAny; this.TypeDictionary = typeDictionary; @@ -69,6 +72,9 @@ public Operation() this.TypeBoolean = typeBoolean; this.TypeInteger = typeInteger; this.TypeNumber = typeNumber; + this.TypeNumber32 = typeNumber32; + this.TypeNumber64 = typeNumber64; + this.TypeNumber128 = typeNumber128; this.TypeConstant = typeConstant; this.TypeChoice = typeChoice; this.TypeSealedChoice = typeSealedChoice; @@ -179,6 +185,24 @@ public Operation() [Newtonsoft.Json.JsonProperty(PropertyName = "typeNumber")] public double? TypeNumber { get; set; } + /// + /// Gets or sets this is number + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "typeNumber32")] + public double? TypeNumber32 { get; set; } + + /// + /// Gets or sets this is number + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "typeNumber64")] + public double? TypeNumber64 { get; set; } + + /// + /// Gets or sets this is number + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "typeNumber128")] + public decimal? TypeNumber128 { get; set; } + /// /// Gets or sets this is constant. Possible values include: 'const' /// diff --git a/tests-upgrade/tests-sdk1-support/model-validate/swagger.json b/tests-upgrade/tests-sdk1-support/model-validate/swagger.json index 39da5730cda..e0e6149619d 100644 --- a/tests-upgrade/tests-sdk1-support/model-validate/swagger.json +++ b/tests-upgrade/tests-sdk1-support/model-validate/swagger.json @@ -148,6 +148,21 @@ "type": "number", "description": "This is number" }, + "typeNumber32": { + "type": "number", + "format": "float", + "description": "This is number" + }, + "typeNumber64": { + "type": "number", + "format": "double", + "description": "This is number" + }, + "typeNumber128": { + "type": "number", + "format": "decimal", + "description": "This is number" + }, "typeConstant": { "type": "string", "description": "This is constant",