Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace {{packageName}}.{{modelPackage}}
/// </summary>
{{>visibility}} abstract partial class AbstractOpenAPISchema
{
/// <summary>
/// Custom JSON serializer
/// </summary>
protected readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings
{
// OpenAPI generated types generally hide default constructors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ namespace {{packageName}}.Client
InterceptRequest(req);

IRestResponse<T> response;
if (RetryConfiguration.RetryPolicy != null)
if (RetryConfiguration.RetryPolicy != null)
{
var policy = RetryConfiguration.RetryPolicy;
var policyResult = policy.ExecuteAndCapture(() => client.Execute(req));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ namespace {{packageName}}.Client
}
{{/-last}}
{{/enumValues}}
}
}
}{{^-last}},{{/-last}}
{{#-last}}
}
Expand Down Expand Up @@ -397,7 +397,7 @@ namespace {{packageName}}.Client
/// Gets or sets the servers.
/// </summary>
/// <value>The servers.</value>
public virtual IList<IReadOnlyDictionary<string, object>> Servers
public virtual IList<IReadOnlyDictionary<string, object>> Servers
{
get { return _servers; }
set
Expand Down Expand Up @@ -447,7 +447,7 @@ namespace {{packageName}}.Client
{

IReadOnlyDictionary<string, object> serverVariables = (IReadOnlyDictionary<string, object>)(variable.Value);

if (inputVariables.ContainsKey(variable.Key))
{
if (((List<string>)serverVariables["enum_values"]).Contains(inputVariables[variable.Key]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ namespace {{packageName}}.Client
SigningAlgorithm = "PKCS1-v15";
}
#endregion

#region Properties
/// <summary>
///Gets the Api keyId
///Gets the Api keyId
/// </summary>
public string KeyId { get; set; }

Expand Down Expand Up @@ -141,7 +141,7 @@ namespace {{packageName}}.Client
var dateTime = DateTime.Now;
String Digest = String.Empty;

//get the body
//get the body
string requestBody = string.Empty;
if (requestOptions.Data != null)
{
Expand Down Expand Up @@ -296,7 +296,7 @@ namespace {{packageName}}.Client
}

/// <summary>
/// Gets the ECDSA signature
/// Gets the ECDSA signature
/// </summary>
/// <param name="dataToSign"></param>
/// <returns></returns>
Expand All @@ -313,16 +313,16 @@ namespace {{packageName}}.Client
var ecKeyBase64String = keyStr.Replace(ecKeyHeader, "").Replace(ecKeyFooter, "").Trim();
var keyBytes = System.Convert.FromBase64String(ecKeyBase64String);
var ecdsa = ECDsa.Create();
var bytCount = 0;

#if (NETCOREAPP3_0 || NETCOREAPP3_1 || NET5_0)
var byteCount = 0;
if (configuration.KeyPassPhrase != null)
{
ecdsa.ImportEncryptedPkcs8PrivateKey(keyPassPhrase, keyBytes, out bytCount);
ecdsa.ImportEncryptedPkcs8PrivateKey(keyPassPhrase, keyBytes, out byteCount);
}
else
{
ecdsa.ImportPkcs8PrivateKey(keyBytes, out bytCount);
ecdsa.ImportPkcs8PrivateKey(keyBytes, out byteCount);
}
var signedBytes = ecdsa.SignHash(dataToSign);
var derBytes = ConvertToECDSAANS1Format(signedBytes);
Expand All @@ -339,7 +339,7 @@ namespace {{packageName}}.Client
{
var derBytes = new List<byte>();
byte derLength = 68; //default lenght for ECDSA code signinged bit 0x44
byte rbytesLength = 32; //R length 0x20
byte rbytesLength = 32; //R length 0x20
byte sbytesLength = 32; //S length 0x20
var rBytes = new List<byte>();
var sBytes = new List<byte>();
Expand Down Expand Up @@ -610,7 +610,7 @@ namespace {{packageName}}.Client
{
// ---- Now hash consecutively for count times ------
if (j == 0)
result = data00; //initialize
result = data00; //initialize
else
{
Array.Copy(result, hashtarget, result.Length);
Expand Down Expand Up @@ -669,8 +669,8 @@ namespace {{packageName}}.Client
var ecPrivateKeyFooter = "END EC PRIVATE KEY";
var rsaPrivateKeyHeader = "BEGIN RSA PRIVATE KEY";
var rsaPrivateFooter = "END RSA PRIVATE KEY";
var pkcs8Header = "BEGIN PRIVATE KEY";
var pkcs8Footer = "END PRIVATE KEY";
//var pkcs8Header = "BEGIN PRIVATE KEY";
//var pkcs8Footer = "END PRIVATE KEY";
var keyType = PrivateKeyType.None;
var key = File.ReadAllLines(keyFilePath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@
}

/// <summary>
/// Converts the JSON string into the object
/// Converts the JSON string into an instance of {{classname}}
/// </summary>
/// <param name="jsonString">JSON string</param>
/// <returns>An instance of {{classname}}</returns>
public static {{classname}} FromJson(string jsonString)
{
{{classname}} new{{classname}} = new {{classname}}();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@ public void SpecialModelNameInstanceTest()
//Assert.IsType<SpecialModelName> (instance, "variable 'instance' is a SpecialModelName");
}


/// <summary>
/// Test the property 'SpecialPropertyName'
/// </summary>
[Fact]
public void SpecialPropertyNameTest()
{
SpecialModelName s = new SpecialModelName();
s.SpecialPropertyName = 123l;
s.SpecialPropertyName = 123L;
Assert.Equal("{\"$special[property.name]\":123}", JsonConvert.SerializeObject(s));
// comment out the following as the result is OS-dependent
//Assert.Equal("{\"id\":123}", s.ToJson());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ private ApiResponse<T> Exec<T>(RestRequest req, IReadableConfiguration configura
InterceptRequest(req);

IRestResponse<T> response;
if (RetryConfiguration.RetryPolicy != null)
if (RetryConfiguration.RetryPolicy != null)
{
var policy = RetryConfiguration.RetryPolicy;
var policyResult = policy.ExecuteAndCapture(() => client.Execute(req));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public Configuration()
"dev-petstore"
}
}
}
}
},
{
"port", new Dictionary<string, object> {
Expand All @@ -140,7 +140,7 @@ public Configuration()
"8080"
}
}
}
}
}
}
}
Expand All @@ -162,7 +162,7 @@ public Configuration()
"v2"
}
}
}
}
}
}
}
Expand Down Expand Up @@ -415,7 +415,7 @@ public virtual IDictionary<string, string> ApiKey
/// Gets or sets the servers.
/// </summary>
/// <value>The servers.</value>
public virtual IList<IReadOnlyDictionary<string, object>> Servers
public virtual IList<IReadOnlyDictionary<string, object>> Servers
{
get { return _servers; }
set
Expand Down Expand Up @@ -465,7 +465,7 @@ public string GetServerUrl(int index, Dictionary<string, string> inputVariables)
{

IReadOnlyDictionary<string, object> serverVariables = (IReadOnlyDictionary<string, object>)(variable.Value);

if (inputVariables.ContainsKey(variable.Key))
{
if (((List<string>)serverVariables["enum_values"]).Contains(inputVariables[variable.Key]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public HttpSigningConfiguration()
SigningAlgorithm = "PKCS1-v15";
}
#endregion

#region Properties
/// <summary>
///Gets the Api keyId
///Gets the Api keyId
/// </summary>
public string KeyId { get; set; }

Expand Down Expand Up @@ -141,7 +141,7 @@ internal Dictionary<string, string> GetHttpSignedHeader(string basePath,string m
var dateTime = DateTime.Now;
String Digest = String.Empty;

//get the body
//get the body
string requestBody = string.Empty;
if (requestOptions.Data != null)
{
Expand Down Expand Up @@ -296,7 +296,7 @@ private string GetRSASignature(byte[] stringToSign)
}

/// <summary>
/// Gets the ECDSA signature
/// Gets the ECDSA signature
/// </summary>
/// <param name="dataToSign"></param>
/// <returns></returns>
Expand All @@ -313,16 +313,16 @@ private string GetECDSASignature(byte[] dataToSign)
var ecKeyBase64String = keyStr.Replace(ecKeyHeader, "").Replace(ecKeyFooter, "").Trim();
var keyBytes = System.Convert.FromBase64String(ecKeyBase64String);
var ecdsa = ECDsa.Create();
var bytCount = 0;

#if (NETCOREAPP3_0 || NETCOREAPP3_1 || NET5_0)
var byteCount = 0;
if (configuration.KeyPassPhrase != null)
{
ecdsa.ImportEncryptedPkcs8PrivateKey(keyPassPhrase, keyBytes, out bytCount);
ecdsa.ImportEncryptedPkcs8PrivateKey(keyPassPhrase, keyBytes, out byteCount);
}
else
{
ecdsa.ImportPkcs8PrivateKey(keyBytes, out bytCount);
ecdsa.ImportPkcs8PrivateKey(keyBytes, out byteCount);
}
var signedBytes = ecdsa.SignHash(dataToSign);
var derBytes = ConvertToECDSAANS1Format(signedBytes);
Expand All @@ -339,7 +339,7 @@ private byte[] ConvertToECDSAANS1Format(byte[] signedBytes)
{
var derBytes = new List<byte>();
byte derLength = 68; //default lenght for ECDSA code signinged bit 0x44
byte rbytesLength = 32; //R length 0x20
byte rbytesLength = 32; //R length 0x20
byte sbytesLength = 32; //S length 0x20
var rBytes = new List<byte>();
var sBytes = new List<byte>();
Expand Down Expand Up @@ -610,7 +610,7 @@ private byte[] GetEncryptedKey(byte[] salt, SecureString secpswd, int count, int
{
// ---- Now hash consecutively for count times ------
if (j == 0)
result = data00; //initialize
result = data00; //initialize
else
{
Array.Copy(result, hashtarget, result.Length);
Expand Down Expand Up @@ -669,8 +669,8 @@ private PrivateKeyType GetKeyType(string keyFilePath)
var ecPrivateKeyFooter = "END EC PRIVATE KEY";
var rsaPrivateKeyHeader = "BEGIN RSA PRIVATE KEY";
var rsaPrivateFooter = "END RSA PRIVATE KEY";
var pkcs8Header = "BEGIN PRIVATE KEY";
var pkcs8Footer = "END PRIVATE KEY";
//var pkcs8Header = "BEGIN PRIVATE KEY";
//var pkcs8Footer = "END PRIVATE KEY";
var keyType = PrivateKeyType.None;
var key = File.ReadAllLines(keyFilePath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ namespace Org.OpenAPITools.Model
/// </summary>
public abstract partial class AbstractOpenAPISchema
{
/// <summary>
/// Custom JSON serializer
/// </summary>
protected readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings
{
// OpenAPI generated types generally hide default constructors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ public override string ToJson()
}

/// <summary>
/// Converts the JSON string into the object
/// Converts the JSON string into an instance of Fruit
/// </summary>
/// <param name="jsonString">JSON string</param>
/// <returns>An instance of Fruit</returns>
public static Fruit FromJson(string jsonString)
{
Fruit newFruit = new Fruit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ public override string ToJson()
}

/// <summary>
/// Converts the JSON string into the object
/// Converts the JSON string into an instance of FruitReq
/// </summary>
/// <param name="jsonString">JSON string</param>
/// <returns>An instance of FruitReq</returns>
public static FruitReq FromJson(string jsonString)
{
FruitReq newFruitReq = new FruitReq();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ public override string ToJson()
}

/// <summary>
/// Converts the JSON string into the object
/// Converts the JSON string into an instance of Mammal
/// </summary>
/// <param name="jsonString">JSON string</param>
/// <returns>An instance of Mammal</returns>
public static Mammal FromJson(string jsonString)
{
Mammal newMammal = new Mammal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ public override string ToJson()
}

/// <summary>
/// Converts the JSON string into the object
/// Converts the JSON string into an instance of NullableShape
/// </summary>
/// <param name="jsonString">JSON string</param>
/// <returns>An instance of NullableShape</returns>
public static NullableShape FromJson(string jsonString)
{
NullableShape newNullableShape = new NullableShape();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ public override string ToJson()
}

/// <summary>
/// Converts the JSON string into the object
/// Converts the JSON string into an instance of Pig
/// </summary>
/// <param name="jsonString">JSON string</param>
/// <returns>An instance of Pig</returns>
public static Pig FromJson(string jsonString)
{
Pig newPig = new Pig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ public override string ToJson()
}

/// <summary>
/// Converts the JSON string into the object
/// Converts the JSON string into an instance of Quadrilateral
/// </summary>
/// <param name="jsonString">JSON string</param>
/// <returns>An instance of Quadrilateral</returns>
public static Quadrilateral FromJson(string jsonString)
{
Quadrilateral newQuadrilateral = new Quadrilateral();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ public override string ToJson()
}

/// <summary>
/// Converts the JSON string into the object
/// Converts the JSON string into an instance of Shape
/// </summary>
/// <param name="jsonString">JSON string</param>
/// <returns>An instance of Shape</returns>
public static Shape FromJson(string jsonString)
{
Shape newShape = new Shape();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ public override string ToJson()
}

/// <summary>
/// Converts the JSON string into the object
/// Converts the JSON string into an instance of ShapeOrNull
/// </summary>
/// <param name="jsonString">JSON string</param>
/// <returns>An instance of ShapeOrNull</returns>
public static ShapeOrNull FromJson(string jsonString)
{
ShapeOrNull newShapeOrNull = new ShapeOrNull();
Expand Down
Loading