-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ASPNETCORE] Fix having two "?" when not required and nullable = true (…
…#19062) * fix #18005: Prevent adding 2 times the "?" when not required and nullable = true * fix #18005: Fix carriage return diff * update samples --------- Co-authored-by: William Cheng <wing328hk@gmail.com>
- Loading branch information
Showing
37 changed files
with
1,633 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Models/TestNullable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/* | ||
* OpenAPI Petstore | ||
* | ||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. | ||
* | ||
* The version of the OpenAPI document: 1.0.0 | ||
* | ||
* Generated by: https://openapi-generator.tech | ||
*/ | ||
|
||
using System; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Runtime.Serialization; | ||
using Newtonsoft.Json; | ||
using Org.OpenAPITools.Converters; | ||
|
||
namespace Org.OpenAPITools.Models | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
[DataContract] | ||
public partial class TestNullable : IEquatable<TestNullable> | ||
{ | ||
/// <summary> | ||
/// Gets or Sets Name | ||
/// </summary> | ||
[DataMember(Name="name", EmitDefaultValue=false)] | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or Sets NullableName | ||
/// </summary> | ||
[DataMember(Name="nullableName", EmitDefaultValue=true)] | ||
public string NullableName { get; set; } | ||
|
||
/// <summary> | ||
/// Returns the string presentation of the object | ||
/// </summary> | ||
/// <returns>String presentation of the object</returns> | ||
public override string ToString() | ||
{ | ||
var sb = new StringBuilder(); | ||
sb.Append("class TestNullable {\n"); | ||
sb.Append(" Name: ").Append(Name).Append("\n"); | ||
sb.Append(" NullableName: ").Append(NullableName).Append("\n"); | ||
sb.Append("}\n"); | ||
return sb.ToString(); | ||
} | ||
|
||
/// <summary> | ||
/// Returns the JSON string presentation of the object | ||
/// </summary> | ||
/// <returns>JSON string presentation of the object</returns> | ||
public string ToJson() | ||
{ | ||
return JsonConvert.SerializeObject(this, Formatting.Indented); | ||
} | ||
|
||
/// <summary> | ||
/// Returns true if objects are equal | ||
/// </summary> | ||
/// <param name="obj">Object to be compared</param> | ||
/// <returns>Boolean</returns> | ||
public override bool Equals(object obj) | ||
{ | ||
if (obj is null) return false; | ||
if (ReferenceEquals(this, obj)) return true; | ||
return obj.GetType() == GetType() && Equals((TestNullable)obj); | ||
} | ||
|
||
/// <summary> | ||
/// Returns true if TestNullable instances are equal | ||
/// </summary> | ||
/// <param name="other">Instance of TestNullable to be compared</param> | ||
/// <returns>Boolean</returns> | ||
public bool Equals(TestNullable other) | ||
{ | ||
if (other is null) return false; | ||
if (ReferenceEquals(this, other)) return true; | ||
|
||
return | ||
( | ||
Name == other.Name || | ||
Name != null && | ||
Name.Equals(other.Name) | ||
) && | ||
( | ||
NullableName == other.NullableName || | ||
NullableName != null && | ||
NullableName.Equals(other.NullableName) | ||
); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the hash code | ||
/// </summary> | ||
/// <returns>Hash code</returns> | ||
public override int GetHashCode() | ||
{ | ||
unchecked // Overflow is fine, just wrap | ||
{ | ||
var hashCode = 41; | ||
// Suitable nullity checks etc, of course :) | ||
if (Name != null) | ||
hashCode = hashCode * 59 + Name.GetHashCode(); | ||
if (NullableName != null) | ||
hashCode = hashCode * 59 + NullableName.GetHashCode(); | ||
return hashCode; | ||
} | ||
} | ||
|
||
#region Operators | ||
#pragma warning disable 1591 | ||
|
||
public static bool operator ==(TestNullable left, TestNullable right) | ||
{ | ||
return Equals(left, right); | ||
} | ||
|
||
public static bool operator !=(TestNullable left, TestNullable right) | ||
{ | ||
return !Equals(left, right); | ||
} | ||
|
||
#pragma warning restore 1591 | ||
#endregion Operators | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.