forked from loafle/openapi-generator-original
[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>
This commit is contained in:
parent
b897a99ebb
commit
0b1b3f531e
@ -77,7 +77,7 @@ namespace {{modelPackage}}
|
|||||||
public {{{datatypeWithEnum}}}{{#isNullable}}?{{/isNullable}} {{name}} { get; set; }{{#defaultValue}} = {{{.}}};{{/defaultValue}}
|
public {{{datatypeWithEnum}}}{{#isNullable}}?{{/isNullable}} {{name}} { get; set; }{{#defaultValue}} = {{{.}}};{{/defaultValue}}
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{^isEnum}}
|
{{^isEnum}}
|
||||||
public {{{dataType}}}{{#nullableReferenceTypes}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}}{{/nullableReferenceTypes}} {{name}} { get; set; }{{#defaultValue}} = {{{.}}};{{/defaultValue}}
|
public {{{dataType}}}{{#nullableReferenceTypes}}{{^isContainer}}{{^required}}{{^isNullable}}?{{/isNullable}}{{/required}}{{/isContainer}}{{/nullableReferenceTypes}} {{name}} { get; set; }{{#defaultValue}} = {{{.}}};{{/defaultValue}}
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{^-last}}
|
{{^-last}}
|
||||||
|
|
||||||
|
@ -594,6 +594,20 @@ paths:
|
|||||||
responses:
|
responses:
|
||||||
default:
|
default:
|
||||||
description: successful operation
|
description: successful operation
|
||||||
|
/fake/nullable_example_test:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- fake
|
||||||
|
summary: Fake endpoint to test nullable example (object)
|
||||||
|
description: ''
|
||||||
|
operationId: fake_nullable_example_test
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/TestNullable'
|
||||||
externalDocs:
|
externalDocs:
|
||||||
description: Find out more about Swagger
|
description: Find out more about Swagger
|
||||||
url: 'http://swagger.io'
|
url: 'http://swagger.io'
|
||||||
@ -637,6 +651,14 @@ components:
|
|||||||
enum:
|
enum:
|
||||||
- A
|
- A
|
||||||
- B
|
- B
|
||||||
|
TestNullable:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
nullableName:
|
||||||
|
type: string
|
||||||
|
nullable: true
|
||||||
Order:
|
Order:
|
||||||
title: Pet Order
|
title: Pet Order
|
||||||
description: An order for a pets from the pet store
|
description: An order for a pets from the pet store
|
||||||
|
@ -24,6 +24,7 @@ src/Org.OpenAPITools/Models/Order.cs
|
|||||||
src/Org.OpenAPITools/Models/Pet.cs
|
src/Org.OpenAPITools/Models/Pet.cs
|
||||||
src/Org.OpenAPITools/Models/Tag.cs
|
src/Org.OpenAPITools/Models/Tag.cs
|
||||||
src/Org.OpenAPITools/Models/TestEnum.cs
|
src/Org.OpenAPITools/Models/TestEnum.cs
|
||||||
|
src/Org.OpenAPITools/Models/TestNullable.cs
|
||||||
src/Org.OpenAPITools/Models/User.cs
|
src/Org.OpenAPITools/Models/User.cs
|
||||||
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
|
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
|
||||||
src/Org.OpenAPITools/Program.cs
|
src/Org.OpenAPITools/Program.cs
|
||||||
|
@ -28,6 +28,30 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class FakeApiController : ControllerBase
|
public class FakeApiController : ControllerBase
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Fake endpoint to test nullable example (object)
|
||||||
|
/// </summary>
|
||||||
|
/// <response code="200">Successful operation</response>
|
||||||
|
[HttpGet]
|
||||||
|
[Route("/v2/fake/nullable_example_test")]
|
||||||
|
[ValidateModelState]
|
||||||
|
[SwaggerOperation("FakeNullableExampleTest")]
|
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(TestNullable), description: "Successful operation")]
|
||||||
|
public virtual IActionResult FakeNullableExampleTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
|
||||||
|
// return StatusCode(200, default(TestNullable));
|
||||||
|
string exampleJson = null;
|
||||||
|
exampleJson = "{\n \"nullableName\" : \"nullableName\",\n \"name\" : \"name\"\n}";
|
||||||
|
|
||||||
|
var example = exampleJson != null
|
||||||
|
? JsonConvert.DeserializeObject<TestNullable>(exampleJson)
|
||||||
|
: default(TestNullable);
|
||||||
|
//TODO: Change the data returned
|
||||||
|
return new ObjectResult(example);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// fake endpoint to test parameter example (object)
|
/// fake endpoint to test parameter example (object)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -812,6 +812,26 @@
|
|||||||
"summary" : "fake endpoint to test parameter example (object)",
|
"summary" : "fake endpoint to test parameter example (object)",
|
||||||
"tags" : [ "fake" ]
|
"tags" : [ "fake" ]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/fake/nullable_example_test" : {
|
||||||
|
"get" : {
|
||||||
|
"description" : "",
|
||||||
|
"operationId" : "fake_nullable_example_test",
|
||||||
|
"responses" : {
|
||||||
|
"200" : {
|
||||||
|
"content" : {
|
||||||
|
"application/json" : {
|
||||||
|
"schema" : {
|
||||||
|
"$ref" : "#/components/schemas/TestNullable"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description" : "Successful operation"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"summary" : "Fake endpoint to test nullable example (object)",
|
||||||
|
"tags" : [ "fake" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"components" : {
|
"components" : {
|
||||||
@ -852,6 +872,22 @@
|
|||||||
"enum" : [ "A", "B" ],
|
"enum" : [ "A", "B" ],
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
},
|
},
|
||||||
|
"TestNullable" : {
|
||||||
|
"example" : {
|
||||||
|
"nullableName" : "nullableName",
|
||||||
|
"name" : "name"
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"name" : {
|
||||||
|
"type" : "string"
|
||||||
|
},
|
||||||
|
"nullableName" : {
|
||||||
|
"nullable" : true,
|
||||||
|
"type" : "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type" : "object"
|
||||||
|
},
|
||||||
"Order" : {
|
"Order" : {
|
||||||
"description" : "An order for a pets from the pet store",
|
"description" : "An order for a pets from the pet store",
|
||||||
"example" : {
|
"example" : {
|
||||||
|
@ -24,6 +24,7 @@ src/Org.OpenAPITools/Models/Order.cs
|
|||||||
src/Org.OpenAPITools/Models/Pet.cs
|
src/Org.OpenAPITools/Models/Pet.cs
|
||||||
src/Org.OpenAPITools/Models/Tag.cs
|
src/Org.OpenAPITools/Models/Tag.cs
|
||||||
src/Org.OpenAPITools/Models/TestEnum.cs
|
src/Org.OpenAPITools/Models/TestEnum.cs
|
||||||
|
src/Org.OpenAPITools/Models/TestNullable.cs
|
||||||
src/Org.OpenAPITools/Models/User.cs
|
src/Org.OpenAPITools/Models/User.cs
|
||||||
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
|
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
|
||||||
src/Org.OpenAPITools/Program.cs
|
src/Org.OpenAPITools/Program.cs
|
||||||
|
@ -28,6 +28,30 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class FakeApiController : ControllerBase
|
public class FakeApiController : ControllerBase
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Fake endpoint to test nullable example (object)
|
||||||
|
/// </summary>
|
||||||
|
/// <response code="200">Successful operation</response>
|
||||||
|
[HttpGet]
|
||||||
|
[Route("/v2/fake/nullable_example_test")]
|
||||||
|
[ValidateModelState]
|
||||||
|
[SwaggerOperation("FakeNullableExampleTest")]
|
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(TestNullable), description: "Successful operation")]
|
||||||
|
public virtual IActionResult FakeNullableExampleTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
|
||||||
|
// return StatusCode(200, default(TestNullable));
|
||||||
|
string exampleJson = null;
|
||||||
|
exampleJson = "{\n \"nullableName\" : \"nullableName\",\n \"name\" : \"name\"\n}";
|
||||||
|
|
||||||
|
var example = exampleJson != null
|
||||||
|
? JsonConvert.DeserializeObject<TestNullable>(exampleJson)
|
||||||
|
: default(TestNullable);
|
||||||
|
//TODO: Change the data returned
|
||||||
|
return new ObjectResult(example);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// fake endpoint to test parameter example (object)
|
/// fake endpoint to test parameter example (object)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -812,6 +812,26 @@
|
|||||||
"summary" : "fake endpoint to test parameter example (object)",
|
"summary" : "fake endpoint to test parameter example (object)",
|
||||||
"tags" : [ "fake" ]
|
"tags" : [ "fake" ]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/fake/nullable_example_test" : {
|
||||||
|
"get" : {
|
||||||
|
"description" : "",
|
||||||
|
"operationId" : "fake_nullable_example_test",
|
||||||
|
"responses" : {
|
||||||
|
"200" : {
|
||||||
|
"content" : {
|
||||||
|
"application/json" : {
|
||||||
|
"schema" : {
|
||||||
|
"$ref" : "#/components/schemas/TestNullable"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description" : "Successful operation"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"summary" : "Fake endpoint to test nullable example (object)",
|
||||||
|
"tags" : [ "fake" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"components" : {
|
"components" : {
|
||||||
@ -852,6 +872,22 @@
|
|||||||
"enum" : [ "A", "B" ],
|
"enum" : [ "A", "B" ],
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
},
|
},
|
||||||
|
"TestNullable" : {
|
||||||
|
"example" : {
|
||||||
|
"nullableName" : "nullableName",
|
||||||
|
"name" : "name"
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"name" : {
|
||||||
|
"type" : "string"
|
||||||
|
},
|
||||||
|
"nullableName" : {
|
||||||
|
"nullable" : true,
|
||||||
|
"type" : "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type" : "object"
|
||||||
|
},
|
||||||
"Order" : {
|
"Order" : {
|
||||||
"description" : "An order for a pets from the pet store",
|
"description" : "An order for a pets from the pet store",
|
||||||
"example" : {
|
"example" : {
|
||||||
|
@ -24,6 +24,7 @@ src/Org.OpenAPITools/Models/Order.cs
|
|||||||
src/Org.OpenAPITools/Models/Pet.cs
|
src/Org.OpenAPITools/Models/Pet.cs
|
||||||
src/Org.OpenAPITools/Models/Tag.cs
|
src/Org.OpenAPITools/Models/Tag.cs
|
||||||
src/Org.OpenAPITools/Models/TestEnum.cs
|
src/Org.OpenAPITools/Models/TestEnum.cs
|
||||||
|
src/Org.OpenAPITools/Models/TestNullable.cs
|
||||||
src/Org.OpenAPITools/Models/User.cs
|
src/Org.OpenAPITools/Models/User.cs
|
||||||
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
|
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
|
||||||
src/Org.OpenAPITools/Program.cs
|
src/Org.OpenAPITools/Program.cs
|
||||||
|
@ -28,6 +28,30 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class FakeApiController : ControllerBase
|
public class FakeApiController : ControllerBase
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Fake endpoint to test nullable example (object)
|
||||||
|
/// </summary>
|
||||||
|
/// <response code="200">Successful operation</response>
|
||||||
|
[HttpGet]
|
||||||
|
[Route("/v2/fake/nullable_example_test")]
|
||||||
|
[ValidateModelState]
|
||||||
|
[SwaggerOperation("FakeNullableExampleTest")]
|
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(TestNullable), description: "Successful operation")]
|
||||||
|
public virtual IActionResult FakeNullableExampleTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
|
||||||
|
// return StatusCode(200, default(TestNullable));
|
||||||
|
string exampleJson = null;
|
||||||
|
exampleJson = "{\n \"nullableName\" : \"nullableName\",\n \"name\" : \"name\"\n}";
|
||||||
|
|
||||||
|
var example = exampleJson != null
|
||||||
|
? JsonConvert.DeserializeObject<TestNullable>(exampleJson)
|
||||||
|
: default(TestNullable);
|
||||||
|
//TODO: Change the data returned
|
||||||
|
return new ObjectResult(example);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// fake endpoint to test parameter example (object)
|
/// fake endpoint to test parameter example (object)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -812,6 +812,26 @@
|
|||||||
"summary" : "fake endpoint to test parameter example (object)",
|
"summary" : "fake endpoint to test parameter example (object)",
|
||||||
"tags" : [ "fake" ]
|
"tags" : [ "fake" ]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/fake/nullable_example_test" : {
|
||||||
|
"get" : {
|
||||||
|
"description" : "",
|
||||||
|
"operationId" : "fake_nullable_example_test",
|
||||||
|
"responses" : {
|
||||||
|
"200" : {
|
||||||
|
"content" : {
|
||||||
|
"application/json" : {
|
||||||
|
"schema" : {
|
||||||
|
"$ref" : "#/components/schemas/TestNullable"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description" : "Successful operation"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"summary" : "Fake endpoint to test nullable example (object)",
|
||||||
|
"tags" : [ "fake" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"components" : {
|
"components" : {
|
||||||
@ -852,6 +872,22 @@
|
|||||||
"enum" : [ "A", "B" ],
|
"enum" : [ "A", "B" ],
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
},
|
},
|
||||||
|
"TestNullable" : {
|
||||||
|
"example" : {
|
||||||
|
"nullableName" : "nullableName",
|
||||||
|
"name" : "name"
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"name" : {
|
||||||
|
"type" : "string"
|
||||||
|
},
|
||||||
|
"nullableName" : {
|
||||||
|
"nullable" : true,
|
||||||
|
"type" : "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type" : "object"
|
||||||
|
},
|
||||||
"Order" : {
|
"Order" : {
|
||||||
"description" : "An order for a pets from the pet store",
|
"description" : "An order for a pets from the pet store",
|
||||||
"example" : {
|
"example" : {
|
||||||
|
@ -24,6 +24,7 @@ src/Org.OpenAPITools/Models/Order.cs
|
|||||||
src/Org.OpenAPITools/Models/Pet.cs
|
src/Org.OpenAPITools/Models/Pet.cs
|
||||||
src/Org.OpenAPITools/Models/Tag.cs
|
src/Org.OpenAPITools/Models/Tag.cs
|
||||||
src/Org.OpenAPITools/Models/TestEnum.cs
|
src/Org.OpenAPITools/Models/TestEnum.cs
|
||||||
|
src/Org.OpenAPITools/Models/TestNullable.cs
|
||||||
src/Org.OpenAPITools/Models/User.cs
|
src/Org.OpenAPITools/Models/User.cs
|
||||||
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
|
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
|
||||||
src/Org.OpenAPITools/Org.OpenAPITools.csproj
|
src/Org.OpenAPITools/Org.OpenAPITools.csproj
|
||||||
|
@ -28,6 +28,30 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class FakeApiController : ControllerBase
|
public class FakeApiController : ControllerBase
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Fake endpoint to test nullable example (object)
|
||||||
|
/// </summary>
|
||||||
|
/// <response code="200">Successful operation</response>
|
||||||
|
[HttpGet]
|
||||||
|
[Route("/v2/fake/nullable_example_test")]
|
||||||
|
[ValidateModelState]
|
||||||
|
[SwaggerOperation("FakeNullableExampleTest")]
|
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(TestNullable), description: "Successful operation")]
|
||||||
|
public virtual IActionResult FakeNullableExampleTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
|
||||||
|
// return StatusCode(200, default(TestNullable));
|
||||||
|
string exampleJson = null;
|
||||||
|
exampleJson = "{\n \"nullableName\" : \"nullableName\",\n \"name\" : \"name\"\n}";
|
||||||
|
|
||||||
|
var example = exampleJson != null
|
||||||
|
? JsonSerializer.Deserialize<TestNullable>(exampleJson)
|
||||||
|
: default(TestNullable);
|
||||||
|
//TODO: Change the data returned
|
||||||
|
return new ObjectResult(example);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// fake endpoint to test parameter example (object)
|
/// fake endpoint to test parameter example (object)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -0,0 +1,138 @@
|
|||||||
|
/*
|
||||||
|
* 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 System.Text.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()
|
||||||
|
{
|
||||||
|
var options = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true
|
||||||
|
};
|
||||||
|
|
||||||
|
return JsonSerializer.Serialize(this, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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
|
||||||
|
}
|
||||||
|
}
|
@ -812,6 +812,26 @@
|
|||||||
"summary" : "fake endpoint to test parameter example (object)",
|
"summary" : "fake endpoint to test parameter example (object)",
|
||||||
"tags" : [ "fake" ]
|
"tags" : [ "fake" ]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/fake/nullable_example_test" : {
|
||||||
|
"get" : {
|
||||||
|
"description" : "",
|
||||||
|
"operationId" : "fake_nullable_example_test",
|
||||||
|
"responses" : {
|
||||||
|
"200" : {
|
||||||
|
"content" : {
|
||||||
|
"application/json" : {
|
||||||
|
"schema" : {
|
||||||
|
"$ref" : "#/components/schemas/TestNullable"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description" : "Successful operation"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"summary" : "Fake endpoint to test nullable example (object)",
|
||||||
|
"tags" : [ "fake" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"components" : {
|
"components" : {
|
||||||
@ -852,6 +872,22 @@
|
|||||||
"enum" : [ "A", "B" ],
|
"enum" : [ "A", "B" ],
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
},
|
},
|
||||||
|
"TestNullable" : {
|
||||||
|
"example" : {
|
||||||
|
"nullableName" : "nullableName",
|
||||||
|
"name" : "name"
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"name" : {
|
||||||
|
"type" : "string"
|
||||||
|
},
|
||||||
|
"nullableName" : {
|
||||||
|
"nullable" : true,
|
||||||
|
"type" : "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type" : "object"
|
||||||
|
},
|
||||||
"Order" : {
|
"Order" : {
|
||||||
"description" : "An order for a pets from the pet store",
|
"description" : "An order for a pets from the pet store",
|
||||||
"example" : {
|
"example" : {
|
||||||
|
@ -24,6 +24,7 @@ src/Org.OpenAPITools/Models/Order.cs
|
|||||||
src/Org.OpenAPITools/Models/Pet.cs
|
src/Org.OpenAPITools/Models/Pet.cs
|
||||||
src/Org.OpenAPITools/Models/Tag.cs
|
src/Org.OpenAPITools/Models/Tag.cs
|
||||||
src/Org.OpenAPITools/Models/TestEnum.cs
|
src/Org.OpenAPITools/Models/TestEnum.cs
|
||||||
|
src/Org.OpenAPITools/Models/TestNullable.cs
|
||||||
src/Org.OpenAPITools/Models/User.cs
|
src/Org.OpenAPITools/Models/User.cs
|
||||||
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
|
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
|
||||||
src/Org.OpenAPITools/Org.OpenAPITools.csproj
|
src/Org.OpenAPITools/Org.OpenAPITools.csproj
|
||||||
|
@ -28,6 +28,30 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class FakeApiController : ControllerBase
|
public class FakeApiController : ControllerBase
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Fake endpoint to test nullable example (object)
|
||||||
|
/// </summary>
|
||||||
|
/// <response code="200">Successful operation</response>
|
||||||
|
[HttpGet]
|
||||||
|
[Route("/v2/fake/nullable_example_test")]
|
||||||
|
[ValidateModelState]
|
||||||
|
[SwaggerOperation("FakeNullableExampleTest")]
|
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(TestNullable), description: "Successful operation")]
|
||||||
|
public virtual IActionResult FakeNullableExampleTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
|
||||||
|
// return StatusCode(200, default(TestNullable));
|
||||||
|
string exampleJson = null;
|
||||||
|
exampleJson = "{\n \"nullableName\" : \"nullableName\",\n \"name\" : \"name\"\n}";
|
||||||
|
|
||||||
|
var example = exampleJson != null
|
||||||
|
? JsonConvert.DeserializeObject<TestNullable>(exampleJson)
|
||||||
|
: default(TestNullable);
|
||||||
|
//TODO: Change the data returned
|
||||||
|
return new ObjectResult(example);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// fake endpoint to test parameter example (object)
|
/// fake endpoint to test parameter example (object)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -812,6 +812,26 @@
|
|||||||
"summary" : "fake endpoint to test parameter example (object)",
|
"summary" : "fake endpoint to test parameter example (object)",
|
||||||
"tags" : [ "fake" ]
|
"tags" : [ "fake" ]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/fake/nullable_example_test" : {
|
||||||
|
"get" : {
|
||||||
|
"description" : "",
|
||||||
|
"operationId" : "fake_nullable_example_test",
|
||||||
|
"responses" : {
|
||||||
|
"200" : {
|
||||||
|
"content" : {
|
||||||
|
"application/json" : {
|
||||||
|
"schema" : {
|
||||||
|
"$ref" : "#/components/schemas/TestNullable"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description" : "Successful operation"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"summary" : "Fake endpoint to test nullable example (object)",
|
||||||
|
"tags" : [ "fake" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"components" : {
|
"components" : {
|
||||||
@ -852,6 +872,22 @@
|
|||||||
"enum" : [ "A", "B" ],
|
"enum" : [ "A", "B" ],
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
},
|
},
|
||||||
|
"TestNullable" : {
|
||||||
|
"example" : {
|
||||||
|
"nullableName" : "nullableName",
|
||||||
|
"name" : "name"
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"name" : {
|
||||||
|
"type" : "string"
|
||||||
|
},
|
||||||
|
"nullableName" : {
|
||||||
|
"nullable" : true,
|
||||||
|
"type" : "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type" : "object"
|
||||||
|
},
|
||||||
"Order" : {
|
"Order" : {
|
||||||
"description" : "An order for a pets from the pet store",
|
"description" : "An order for a pets from the pet store",
|
||||||
"example" : {
|
"example" : {
|
||||||
|
@ -24,6 +24,7 @@ src/Org.OpenAPITools/Models/Order.cs
|
|||||||
src/Org.OpenAPITools/Models/Pet.cs
|
src/Org.OpenAPITools/Models/Pet.cs
|
||||||
src/Org.OpenAPITools/Models/Tag.cs
|
src/Org.OpenAPITools/Models/Tag.cs
|
||||||
src/Org.OpenAPITools/Models/TestEnum.cs
|
src/Org.OpenAPITools/Models/TestEnum.cs
|
||||||
|
src/Org.OpenAPITools/Models/TestNullable.cs
|
||||||
src/Org.OpenAPITools/Models/User.cs
|
src/Org.OpenAPITools/Models/User.cs
|
||||||
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
|
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
|
||||||
src/Org.OpenAPITools/Org.OpenAPITools.csproj
|
src/Org.OpenAPITools/Org.OpenAPITools.csproj
|
||||||
|
@ -28,6 +28,30 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class FakeApiController : ControllerBase
|
public class FakeApiController : ControllerBase
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Fake endpoint to test nullable example (object)
|
||||||
|
/// </summary>
|
||||||
|
/// <response code="200">Successful operation</response>
|
||||||
|
[HttpGet]
|
||||||
|
[Route("/v2/fake/nullable_example_test")]
|
||||||
|
[ValidateModelState]
|
||||||
|
[SwaggerOperation("FakeNullableExampleTest")]
|
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(TestNullable), description: "Successful operation")]
|
||||||
|
public virtual IActionResult FakeNullableExampleTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
|
||||||
|
// return StatusCode(200, default(TestNullable));
|
||||||
|
string exampleJson = null;
|
||||||
|
exampleJson = "{\n \"nullableName\" : \"nullableName\",\n \"name\" : \"name\"\n}";
|
||||||
|
|
||||||
|
var example = exampleJson != null
|
||||||
|
? JsonConvert.DeserializeObject<TestNullable>(exampleJson)
|
||||||
|
: default(TestNullable);
|
||||||
|
//TODO: Change the data returned
|
||||||
|
return new ObjectResult(example);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// fake endpoint to test parameter example (object)
|
/// fake endpoint to test parameter example (object)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
{
|
||||||
|
/// <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; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -812,6 +812,26 @@
|
|||||||
"summary" : "fake endpoint to test parameter example (object)",
|
"summary" : "fake endpoint to test parameter example (object)",
|
||||||
"tags" : [ "fake" ]
|
"tags" : [ "fake" ]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/fake/nullable_example_test" : {
|
||||||
|
"get" : {
|
||||||
|
"description" : "",
|
||||||
|
"operationId" : "fake_nullable_example_test",
|
||||||
|
"responses" : {
|
||||||
|
"200" : {
|
||||||
|
"content" : {
|
||||||
|
"application/json" : {
|
||||||
|
"schema" : {
|
||||||
|
"$ref" : "#/components/schemas/TestNullable"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description" : "Successful operation"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"summary" : "Fake endpoint to test nullable example (object)",
|
||||||
|
"tags" : [ "fake" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"components" : {
|
"components" : {
|
||||||
@ -852,6 +872,22 @@
|
|||||||
"enum" : [ "A", "B" ],
|
"enum" : [ "A", "B" ],
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
},
|
},
|
||||||
|
"TestNullable" : {
|
||||||
|
"example" : {
|
||||||
|
"nullableName" : "nullableName",
|
||||||
|
"name" : "name"
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"name" : {
|
||||||
|
"type" : "string"
|
||||||
|
},
|
||||||
|
"nullableName" : {
|
||||||
|
"nullable" : true,
|
||||||
|
"type" : "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type" : "object"
|
||||||
|
},
|
||||||
"Order" : {
|
"Order" : {
|
||||||
"description" : "An order for a pets from the pet store",
|
"description" : "An order for a pets from the pet store",
|
||||||
"example" : {
|
"example" : {
|
||||||
|
@ -14,6 +14,7 @@ src/Org.OpenAPITools.Models/Org.OpenAPITools.Models.csproj
|
|||||||
src/Org.OpenAPITools.Models/Pet.cs
|
src/Org.OpenAPITools.Models/Pet.cs
|
||||||
src/Org.OpenAPITools.Models/Tag.cs
|
src/Org.OpenAPITools.Models/Tag.cs
|
||||||
src/Org.OpenAPITools.Models/TestEnum.cs
|
src/Org.OpenAPITools.Models/TestEnum.cs
|
||||||
|
src/Org.OpenAPITools.Models/TestNullable.cs
|
||||||
src/Org.OpenAPITools.Models/User.cs
|
src/Org.OpenAPITools.Models/User.cs
|
||||||
src/Org.OpenAPITools/.gitignore
|
src/Org.OpenAPITools/.gitignore
|
||||||
src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs
|
src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -28,6 +28,30 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class FakeApiController : ControllerBase
|
public class FakeApiController : ControllerBase
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Fake endpoint to test nullable example (object)
|
||||||
|
/// </summary>
|
||||||
|
/// <response code="200">Successful operation</response>
|
||||||
|
[HttpGet]
|
||||||
|
[Route("/v2/fake/nullable_example_test")]
|
||||||
|
[ValidateModelState]
|
||||||
|
[SwaggerOperation("FakeNullableExampleTest")]
|
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(TestNullable), description: "Successful operation")]
|
||||||
|
public virtual IActionResult FakeNullableExampleTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
|
||||||
|
// return StatusCode(200, default(TestNullable));
|
||||||
|
string exampleJson = null;
|
||||||
|
exampleJson = "{\n \"nullableName\" : \"nullableName\",\n \"name\" : \"name\"\n}";
|
||||||
|
|
||||||
|
var example = exampleJson != null
|
||||||
|
? JsonConvert.DeserializeObject<TestNullable>(exampleJson)
|
||||||
|
: default(TestNullable);
|
||||||
|
//TODO: Change the data returned
|
||||||
|
return new ObjectResult(example);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// fake endpoint to test parameter example (object)
|
/// fake endpoint to test parameter example (object)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -812,6 +812,26 @@
|
|||||||
"summary" : "fake endpoint to test parameter example (object)",
|
"summary" : "fake endpoint to test parameter example (object)",
|
||||||
"tags" : [ "fake" ]
|
"tags" : [ "fake" ]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/fake/nullable_example_test" : {
|
||||||
|
"get" : {
|
||||||
|
"description" : "",
|
||||||
|
"operationId" : "fake_nullable_example_test",
|
||||||
|
"responses" : {
|
||||||
|
"200" : {
|
||||||
|
"content" : {
|
||||||
|
"application/json" : {
|
||||||
|
"schema" : {
|
||||||
|
"$ref" : "#/components/schemas/TestNullable"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description" : "Successful operation"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"summary" : "Fake endpoint to test nullable example (object)",
|
||||||
|
"tags" : [ "fake" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"components" : {
|
"components" : {
|
||||||
@ -852,6 +872,22 @@
|
|||||||
"enum" : [ "A", "B" ],
|
"enum" : [ "A", "B" ],
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
},
|
},
|
||||||
|
"TestNullable" : {
|
||||||
|
"example" : {
|
||||||
|
"nullableName" : "nullableName",
|
||||||
|
"name" : "name"
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"name" : {
|
||||||
|
"type" : "string"
|
||||||
|
},
|
||||||
|
"nullableName" : {
|
||||||
|
"nullable" : true,
|
||||||
|
"type" : "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type" : "object"
|
||||||
|
},
|
||||||
"Order" : {
|
"Order" : {
|
||||||
"description" : "An order for a pets from the pet store",
|
"description" : "An order for a pets from the pet store",
|
||||||
"example" : {
|
"example" : {
|
||||||
|
@ -21,6 +21,7 @@ src/Org.OpenAPITools/Models/Order.cs
|
|||||||
src/Org.OpenAPITools/Models/Pet.cs
|
src/Org.OpenAPITools/Models/Pet.cs
|
||||||
src/Org.OpenAPITools/Models/Tag.cs
|
src/Org.OpenAPITools/Models/Tag.cs
|
||||||
src/Org.OpenAPITools/Models/TestEnum.cs
|
src/Org.OpenAPITools/Models/TestEnum.cs
|
||||||
|
src/Org.OpenAPITools/Models/TestNullable.cs
|
||||||
src/Org.OpenAPITools/Models/User.cs
|
src/Org.OpenAPITools/Models/User.cs
|
||||||
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
|
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
|
||||||
src/Org.OpenAPITools/Org.OpenAPITools.csproj
|
src/Org.OpenAPITools/Org.OpenAPITools.csproj
|
||||||
|
@ -25,6 +25,16 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public abstract class FakeApiController : ControllerBase
|
public abstract class FakeApiController : ControllerBase
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Fake endpoint to test nullable example (object)
|
||||||
|
/// </summary>
|
||||||
|
/// <response code="200">Successful operation</response>
|
||||||
|
[HttpGet]
|
||||||
|
[Route("/v2/fake/nullable_example_test")]
|
||||||
|
[ValidateModelState]
|
||||||
|
[ProducesResponseType(statusCode: 200, type: typeof(TestNullable))]
|
||||||
|
public abstract IActionResult FakeNullableExampleTest();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// fake endpoint to test parameter example (object)
|
/// fake endpoint to test parameter example (object)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -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 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
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,7 @@ src/Org.OpenAPITools/Models/Order.cs
|
|||||||
src/Org.OpenAPITools/Models/Pet.cs
|
src/Org.OpenAPITools/Models/Pet.cs
|
||||||
src/Org.OpenAPITools/Models/Tag.cs
|
src/Org.OpenAPITools/Models/Tag.cs
|
||||||
src/Org.OpenAPITools/Models/TestEnum.cs
|
src/Org.OpenAPITools/Models/TestEnum.cs
|
||||||
|
src/Org.OpenAPITools/Models/TestNullable.cs
|
||||||
src/Org.OpenAPITools/Models/User.cs
|
src/Org.OpenAPITools/Models/User.cs
|
||||||
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
|
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
|
||||||
src/Org.OpenAPITools/Org.OpenAPITools.csproj
|
src/Org.OpenAPITools/Org.OpenAPITools.csproj
|
||||||
|
@ -28,6 +28,30 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class FakeApiController : ControllerBase
|
public class FakeApiController : ControllerBase
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Fake endpoint to test nullable example (object)
|
||||||
|
/// </summary>
|
||||||
|
/// <response code="200">Successful operation</response>
|
||||||
|
[HttpGet]
|
||||||
|
[Route("/v2/fake/nullable_example_test")]
|
||||||
|
[ValidateModelState]
|
||||||
|
[SwaggerOperation("FakeNullableExampleTest")]
|
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(TestNullable), description: "Successful operation")]
|
||||||
|
public virtual IActionResult FakeNullableExampleTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
|
||||||
|
// return StatusCode(200, default(TestNullable));
|
||||||
|
string exampleJson = null;
|
||||||
|
exampleJson = "{\n \"nullableName\" : \"nullableName\",\n \"name\" : \"name\"\n}";
|
||||||
|
|
||||||
|
var example = exampleJson != null
|
||||||
|
? JsonConvert.DeserializeObject<TestNullable>(exampleJson)
|
||||||
|
: default(TestNullable);
|
||||||
|
//TODO: Change the data returned
|
||||||
|
return new ObjectResult(example);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// fake endpoint to test parameter example (object)
|
/// fake endpoint to test parameter example (object)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -812,6 +812,26 @@
|
|||||||
"summary" : "fake endpoint to test parameter example (object)",
|
"summary" : "fake endpoint to test parameter example (object)",
|
||||||
"tags" : [ "fake" ]
|
"tags" : [ "fake" ]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/fake/nullable_example_test" : {
|
||||||
|
"get" : {
|
||||||
|
"description" : "",
|
||||||
|
"operationId" : "fake_nullable_example_test",
|
||||||
|
"responses" : {
|
||||||
|
"200" : {
|
||||||
|
"content" : {
|
||||||
|
"application/json" : {
|
||||||
|
"schema" : {
|
||||||
|
"$ref" : "#/components/schemas/TestNullable"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description" : "Successful operation"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"summary" : "Fake endpoint to test nullable example (object)",
|
||||||
|
"tags" : [ "fake" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"components" : {
|
"components" : {
|
||||||
@ -852,6 +872,22 @@
|
|||||||
"enum" : [ "A", "B" ],
|
"enum" : [ "A", "B" ],
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
},
|
},
|
||||||
|
"TestNullable" : {
|
||||||
|
"example" : {
|
||||||
|
"nullableName" : "nullableName",
|
||||||
|
"name" : "name"
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"name" : {
|
||||||
|
"type" : "string"
|
||||||
|
},
|
||||||
|
"nullableName" : {
|
||||||
|
"nullable" : true,
|
||||||
|
"type" : "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type" : "object"
|
||||||
|
},
|
||||||
"Order" : {
|
"Order" : {
|
||||||
"description" : "An order for a pets from the pet store",
|
"description" : "An order for a pets from the pet store",
|
||||||
"example" : {
|
"example" : {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user