forked from loafle/openapi-generator-original
bump version to .net8 (#20384)
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
[*.cs]
|
||||
dotnet_diagnostic.xUnit1031.severity = none
|
||||
@@ -1,68 +0,0 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using Xunit;
|
||||
|
||||
namespace Org.OpenAPITools.Test
|
||||
{
|
||||
public class CustomTest
|
||||
{
|
||||
private QueryApi api = new QueryApi();
|
||||
private BodyApi bodyApi = new BodyApi();
|
||||
|
||||
[Fact]
|
||||
public void TestEchoBodyPet()
|
||||
{
|
||||
Pet queryObject = new Pet(12345L, "Hello World", new Category(987L, "new category"), new List<string> { "http://a.com", "http://b.com" });
|
||||
Pet p = bodyApi.TestEchoBodyPet(queryObject);
|
||||
Assert.NotNull(p);
|
||||
Assert.Equal("Hello World", p.Name);
|
||||
Assert.Equal(12345L, p.Id);
|
||||
|
||||
// response is empty body
|
||||
Pet p2 = bodyApi.TestEchoBodyPet(null);
|
||||
Assert.Null(p2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test query parameter(s)
|
||||
* <p>
|
||||
* Test query parameter(s)
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
[Fact]
|
||||
public void TestQueryStyleFormExplodeTrueObjectTest()
|
||||
{
|
||||
Pet queryObject = new Pet(12345L, "Hello World", new Category(987L, "new category"), new List<string> { "http://a.com", "http://b.com" });
|
||||
String response = api.TestQueryStyleFormExplodeTrueObject(queryObject);
|
||||
EchoServerResponseParser p = new EchoServerResponseParser(response);
|
||||
Assert.Equal("/query/style_form/explode_true/object?query_object=class%20Pet%20%7b%0a%20%20Id%3a%2012345%0a%20%20Name%3a%20Hello%20World%0a%20%20Category%3a%20class%20Category%20%7b%0a%20%20Id%3a%20987%0a%20%20Name%3a%20new%20category%0a%7d%0a%0a%20%20PhotoUrls%3a%20System.Collections.Generic.List%601%5bSystem.String%5d%0a%20%20Tags%3a%20%0a%20%20Status%3a%20%0a%7d%0a", p.path);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void testQueryStyleDeepObjectExplodeTrueObjectTest()
|
||||
{
|
||||
Pet queryObject = new Pet(12345L, "Hello World", new Category(987L, "new category"), new List<string> { "http://a.com", "http://b.com" });
|
||||
String response = api.TestQueryStyleDeepObjectExplodeTrueObject(queryObject);
|
||||
EchoServerResponseParser p = new EchoServerResponseParser(response);
|
||||
Assert.Equal("/query/style_deepObject/explode_true/object?queryObject%5bid%5d=12345&queryObject%5bname%5d=Hello%20World&queryObject%5bcategory%5d=class%20Category%20%7b%0a%20%20Id%3a%20987%0a%20%20Name%3a%20new%20category%0a%7d%0a&queryObject%5bphotoUrls%5d=http%3a%2f%2fa.com%2chttp%3a%2f%2fb.com", p.path);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void testQueryStyleDeepObjectExplodeTrueObjectAsyncTest()
|
||||
{
|
||||
Pet queryObject = new Pet(12345L, "Hello World", new Category(987L, "new category"), new List<string> { "http://a.com", "http://b.com" });
|
||||
Task<String> responseTask = api.TestQueryStyleDeepObjectExplodeTrueObjectAsync(queryObject);
|
||||
EchoServerResponseParser p = new EchoServerResponseParser(responseTask.Result);
|
||||
Assert.Equal("/query/style_deepObject/explode_true/object?queryObject%5bid%5d=12345&queryObject%5bname%5d=Hello%20World&queryObject%5bcategory%5d=class%20Category%20%7b%0a%20%20Id%3a%20987%0a%20%20Name%3a%20new%20category%0a%7d%0a&queryObject%5bphotoUrls%5d=http%3a%2f%2fa.com%2chttp%3a%2f%2fb.com", p.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace Org.OpenAPITools.Test
|
||||
{
|
||||
public class EchoServerResponseParser
|
||||
{
|
||||
public String method; // e.g. GET
|
||||
public String path; // e.g. /query/style_form/explode_true/object?id=12345
|
||||
public String protocol; // e.g. HTTP/1.1
|
||||
public Dictionary<String, String> headers = new Dictionary<String, String>();
|
||||
public String body; // e.g. <html><head></head><body>Hello World!</body></html>
|
||||
|
||||
public EchoServerResponseParser(String response)
|
||||
{
|
||||
if (response == null)
|
||||
{
|
||||
throw new SystemException("Echo server response cannot be null");
|
||||
}
|
||||
|
||||
String[] lines = Regex.Split(response, "\r\n|\r|\n");
|
||||
bool firstLine = true;
|
||||
bool bodyStart = false;
|
||||
StringBuilder bodyBuilder = new StringBuilder();
|
||||
|
||||
foreach (String line in lines)
|
||||
{
|
||||
if (firstLine)
|
||||
{
|
||||
String[] items = line.Split(" ");
|
||||
this.method = items[0];
|
||||
this.path = items[1];
|
||||
this.protocol = items[2];
|
||||
firstLine = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bodyStart)
|
||||
{
|
||||
bodyBuilder.Append(line);
|
||||
bodyBuilder.Append("\n");
|
||||
}
|
||||
|
||||
if (String.IsNullOrEmpty(line))
|
||||
{
|
||||
bodyStart = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// store the header key-value pair in headers
|
||||
String[] keyValue = line.Split(": ");
|
||||
if (keyValue.Length == 2)
|
||||
{ // skip blank line, non key-value pair
|
||||
this.headers.Add(keyValue[0], keyValue[1]);
|
||||
}
|
||||
}
|
||||
|
||||
body = bodyBuilder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,5 +63,16 @@ namespace Org.OpenAPITools.Test.Api
|
||||
//var response = instance.TestAuthHttpBasic();
|
||||
//Assert.IsType<string>(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test TestAuthHttpBearer
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestAuthHttpBearerTest()
|
||||
{
|
||||
// TODO uncomment below to test the method and replace null with proper value
|
||||
//var response = instance.TestAuthHttpBearer();
|
||||
//Assert.IsType<string>(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@ using Xunit;
|
||||
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
// uncomment below to import models
|
||||
//using Org.OpenAPITools.Model;
|
||||
|
||||
@@ -79,6 +78,42 @@ namespace Org.OpenAPITools.Test.Api
|
||||
//Assert.IsType<string>(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test TestBodyMultipartFormdataArrayOfBinary
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestBodyMultipartFormdataArrayOfBinaryTest()
|
||||
{
|
||||
// TODO uncomment below to test the method and replace null with proper value
|
||||
//List<System.IO.Stream> files = null;
|
||||
//var response = instance.TestBodyMultipartFormdataArrayOfBinary(files);
|
||||
//Assert.IsType<string>(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test TestBodyMultipartFormdataSingleBinary
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestBodyMultipartFormdataSingleBinaryTest()
|
||||
{
|
||||
// TODO uncomment below to test the method and replace null with proper value
|
||||
//System.IO.Stream? myFile = null;
|
||||
//var response = instance.TestBodyMultipartFormdataSingleBinary(myFile);
|
||||
//Assert.IsType<string>(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test TestEchoBodyAllOfPet
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestEchoBodyAllOfPetTest()
|
||||
{
|
||||
// TODO uncomment below to test the method and replace null with proper value
|
||||
//Pet? pet = null;
|
||||
//var response = instance.TestEchoBodyAllOfPet(pet);
|
||||
//Assert.IsType<Pet>(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test TestEchoBodyFreeFormObjectResponseString
|
||||
/// </summary>
|
||||
@@ -97,9 +132,10 @@ namespace Org.OpenAPITools.Test.Api
|
||||
[Fact]
|
||||
public void TestEchoBodyPetTest()
|
||||
{
|
||||
Pet? pet = new Pet(123, "cat", new Category() { Id = 12, Name = "Test" }, new List<string>(){"http://google.com"},null, null);
|
||||
var response = instance.TestEchoBodyPet(pet);
|
||||
Assert.IsType<Pet>(response);
|
||||
// TODO uncomment below to test the method and replace null with proper value
|
||||
//Pet? pet = null;
|
||||
//var response = instance.TestEchoBodyPet(pet);
|
||||
//Assert.IsType<Pet>(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -114,6 +150,18 @@ namespace Org.OpenAPITools.Test.Api
|
||||
//Assert.IsType<string>(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test TestEchoBodyStringEnum
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestEchoBodyStringEnumTest()
|
||||
{
|
||||
// TODO uncomment below to test the method and replace null with proper value
|
||||
//string? body = null;
|
||||
//var response = instance.TestEchoBodyStringEnum(body);
|
||||
//Assert.IsType<StringEnumRef>(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test TestEchoBodyTagResponseString
|
||||
/// </summary>
|
||||
@@ -19,6 +19,8 @@ using Xunit;
|
||||
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
// uncomment below to import models
|
||||
//using Org.OpenAPITools.Model;
|
||||
|
||||
namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
@@ -66,5 +68,34 @@ namespace Org.OpenAPITools.Test.Api
|
||||
//var response = instance.TestFormIntegerBooleanString(integerForm, booleanForm, stringForm);
|
||||
//Assert.IsType<string>(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test TestFormObjectMultipart
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestFormObjectMultipartTest()
|
||||
{
|
||||
// TODO uncomment below to test the method and replace null with proper value
|
||||
//TestFormObjectMultipartRequestMarker marker = null;
|
||||
//var response = instance.TestFormObjectMultipart(marker);
|
||||
//Assert.IsType<string>(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test TestFormOneof
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestFormOneofTest()
|
||||
{
|
||||
// TODO uncomment below to test the method and replace null with proper value
|
||||
//string? form1 = null;
|
||||
//int? form2 = null;
|
||||
//string? form3 = null;
|
||||
//bool? form4 = null;
|
||||
//long? id = null;
|
||||
//string? name = null;
|
||||
//var response = instance.TestFormOneof(form1, form2, form3, form4, id, name);
|
||||
//Assert.IsType<string>(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@ using Xunit;
|
||||
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
// uncomment below to import models
|
||||
//using Org.OpenAPITools.Model;
|
||||
|
||||
namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
@@ -54,16 +56,18 @@ namespace Org.OpenAPITools.Test.Api
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test TestHeaderIntegerBooleanString
|
||||
/// Test TestHeaderIntegerBooleanStringEnums
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestHeaderIntegerBooleanStringTest()
|
||||
public void TestHeaderIntegerBooleanStringEnumsTest()
|
||||
{
|
||||
// TODO uncomment below to test the method and replace null with proper value
|
||||
//int? integerHeader = null;
|
||||
//bool? booleanHeader = null;
|
||||
//string? stringHeader = null;
|
||||
//var response = instance.TestHeaderIntegerBooleanString(integerHeader, booleanHeader, stringHeader);
|
||||
//string? enumNonrefStringHeader = null;
|
||||
//StringEnumRef? enumRefStringHeader = null;
|
||||
//var response = instance.TestHeaderIntegerBooleanStringEnums(integerHeader, booleanHeader, stringHeader, enumNonrefStringHeader, enumRefStringHeader);
|
||||
//Assert.IsType<string>(response);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@ using Xunit;
|
||||
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
// uncomment below to import models
|
||||
//using Org.OpenAPITools.Model;
|
||||
|
||||
namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
@@ -54,15 +56,17 @@ namespace Org.OpenAPITools.Test.Api
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test TestsPathStringPathStringIntegerPathInteger
|
||||
/// Test TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestsPathStringPathStringIntegerPathIntegerTest()
|
||||
public void TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathTest()
|
||||
{
|
||||
// TODO uncomment below to test the method and replace null with proper value
|
||||
//string pathString = null;
|
||||
//int pathInteger = null;
|
||||
//var response = instance.TestsPathStringPathStringIntegerPathInteger(pathString, pathInteger);
|
||||
//string enumNonrefStringPath = null;
|
||||
//StringEnumRef enumRefStringPath = null;
|
||||
//var response = instance.TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(pathString, pathInteger, enumNonrefStringPath, enumRefStringPath);
|
||||
//Assert.IsType<string>(response);
|
||||
}
|
||||
}
|
||||
@@ -62,8 +62,9 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public void TestEnumRefStringTest()
|
||||
{
|
||||
// TODO uncomment below to test the method and replace null with proper value
|
||||
//string? enumNonrefStringQuery = null;
|
||||
//StringEnumRef? enumRefStringQuery = null;
|
||||
//var response = instance.TestEnumRefString(enumRefStringQuery);
|
||||
//var response = instance.TestEnumRefString(enumNonrefStringQuery, enumRefStringQuery);
|
||||
//Assert.IsType<string>(response);
|
||||
}
|
||||
|
||||
@@ -75,7 +76,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
// TODO uncomment below to test the method and replace null with proper value
|
||||
//DateTime? datetimeQuery = null;
|
||||
//DateTime? dateQuery = null;
|
||||
//DateOnly? dateQuery = null;
|
||||
//string? stringQuery = null;
|
||||
//var response = instance.TestQueryDatetimeDateString(datetimeQuery, dateQuery, stringQuery);
|
||||
//Assert.IsType<string>(response);
|
||||
@@ -119,6 +120,30 @@ namespace Org.OpenAPITools.Test.Api
|
||||
//Assert.IsType<string>(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test TestQueryStyleFormExplodeFalseArrayInteger
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestQueryStyleFormExplodeFalseArrayIntegerTest()
|
||||
{
|
||||
// TODO uncomment below to test the method and replace null with proper value
|
||||
//List<int>? queryObject = null;
|
||||
//var response = instance.TestQueryStyleFormExplodeFalseArrayInteger(queryObject);
|
||||
//Assert.IsType<string>(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test TestQueryStyleFormExplodeFalseArrayString
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestQueryStyleFormExplodeFalseArrayStringTest()
|
||||
{
|
||||
// TODO uncomment below to test the method and replace null with proper value
|
||||
//List<string>? queryObject = null;
|
||||
//var response = instance.TestQueryStyleFormExplodeFalseArrayString(queryObject);
|
||||
//Assert.IsType<string>(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test TestQueryStyleFormExplodeTrueArrayString
|
||||
/// </summary>
|
||||
@@ -65,21 +65,21 @@ namespace Org.OpenAPITools.Test.Model
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'VarFloat'
|
||||
/// Test the property 'Float'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void VarFloatTest()
|
||||
public void FloatTest()
|
||||
{
|
||||
// TODO unit test for the property 'VarFloat'
|
||||
// TODO unit test for the property 'Float'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'VarDouble'
|
||||
/// Test the property 'Double'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void VarDoubleTest()
|
||||
public void DoubleTest()
|
||||
{
|
||||
// TODO unit test for the property 'VarDouble'
|
||||
// TODO unit test for the property 'Double'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Org.OpenAPITools.Test</AssemblyName>
|
||||
<RootNamespace>Org.OpenAPITools.Test</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<Nullable>annotations</Nullable>
|
||||
</PropertyGroup>
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo><!-- setting GenerateAssemblyInfo to false causes this bug https://github.com/dotnet/project-system/issues/3934 -->
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<AssemblyName>Org.OpenAPITools</AssemblyName>
|
||||
<PackageId>Org.OpenAPITools</PackageId>
|
||||
<OutputType>Library</OutputType>
|
||||
Reference in New Issue
Block a user