forked from loafle/openapi-generator-original
[python] Add tests and fix enum path parameters (#16769)
* test: Tests for enum params in path, query and header * fix: Get enum ref values correctly in path parameters Closes #16688 * fix java tests failure --------- Co-authored-by: William Cheng <wing328hk@gmail.com>
This commit is contained in:
@@ -4,11 +4,11 @@ All URIs are relative to *http://localhost:3000*
|
||||
|
||||
| Method | HTTP request | Description |
|
||||
|--------|--------------|-------------|
|
||||
| [**TestHeaderIntegerBooleanString**](HeaderApi.md#testheaderintegerbooleanstring) | **GET** /header/integer/boolean/string | Test header parameter(s) |
|
||||
| [**TestHeaderIntegerBooleanStringEnums**](HeaderApi.md#testheaderintegerbooleanstringenums) | **GET** /header/integer/boolean/string/enums | Test header parameter(s) |
|
||||
|
||||
<a id="testheaderintegerbooleanstring"></a>
|
||||
# **TestHeaderIntegerBooleanString**
|
||||
> string TestHeaderIntegerBooleanString (int? integerHeader = null, bool? booleanHeader = null, string? stringHeader = null)
|
||||
<a id="testheaderintegerbooleanstringenums"></a>
|
||||
# **TestHeaderIntegerBooleanStringEnums**
|
||||
> string TestHeaderIntegerBooleanStringEnums (int? integerHeader = null, bool? booleanHeader = null, string? stringHeader = null, string? enumNonrefStringHeader = null, StringEnumRef? enumRefStringHeader = null)
|
||||
|
||||
Test header parameter(s)
|
||||
|
||||
@@ -24,7 +24,7 @@ using Org.OpenAPITools.Model;
|
||||
|
||||
namespace Example
|
||||
{
|
||||
public class TestHeaderIntegerBooleanStringExample
|
||||
public class TestHeaderIntegerBooleanStringEnumsExample
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
@@ -34,16 +34,18 @@ namespace Example
|
||||
var integerHeader = 56; // int? | (optional)
|
||||
var booleanHeader = true; // bool? | (optional)
|
||||
var stringHeader = "stringHeader_example"; // string? | (optional)
|
||||
var enumNonrefStringHeader = "success"; // string? | (optional)
|
||||
var enumRefStringHeader = new StringEnumRef?(); // StringEnumRef? | (optional)
|
||||
|
||||
try
|
||||
{
|
||||
// Test header parameter(s)
|
||||
string result = apiInstance.TestHeaderIntegerBooleanString(integerHeader, booleanHeader, stringHeader);
|
||||
string result = apiInstance.TestHeaderIntegerBooleanStringEnums(integerHeader, booleanHeader, stringHeader, enumNonrefStringHeader, enumRefStringHeader);
|
||||
Debug.WriteLine(result);
|
||||
}
|
||||
catch (ApiException e)
|
||||
{
|
||||
Debug.Print("Exception when calling HeaderApi.TestHeaderIntegerBooleanString: " + e.Message);
|
||||
Debug.Print("Exception when calling HeaderApi.TestHeaderIntegerBooleanStringEnums: " + e.Message);
|
||||
Debug.Print("Status Code: " + e.ErrorCode);
|
||||
Debug.Print(e.StackTrace);
|
||||
}
|
||||
@@ -52,21 +54,21 @@ namespace Example
|
||||
}
|
||||
```
|
||||
|
||||
#### Using the TestHeaderIntegerBooleanStringWithHttpInfo variant
|
||||
#### Using the TestHeaderIntegerBooleanStringEnumsWithHttpInfo variant
|
||||
This returns an ApiResponse object which contains the response data, status code and headers.
|
||||
|
||||
```csharp
|
||||
try
|
||||
{
|
||||
// Test header parameter(s)
|
||||
ApiResponse<string> response = apiInstance.TestHeaderIntegerBooleanStringWithHttpInfo(integerHeader, booleanHeader, stringHeader);
|
||||
ApiResponse<string> response = apiInstance.TestHeaderIntegerBooleanStringEnumsWithHttpInfo(integerHeader, booleanHeader, stringHeader, enumNonrefStringHeader, enumRefStringHeader);
|
||||
Debug.Write("Status Code: " + response.StatusCode);
|
||||
Debug.Write("Response Headers: " + response.Headers);
|
||||
Debug.Write("Response Body: " + response.Data);
|
||||
}
|
||||
catch (ApiException e)
|
||||
{
|
||||
Debug.Print("Exception when calling HeaderApi.TestHeaderIntegerBooleanStringWithHttpInfo: " + e.Message);
|
||||
Debug.Print("Exception when calling HeaderApi.TestHeaderIntegerBooleanStringEnumsWithHttpInfo: " + e.Message);
|
||||
Debug.Print("Status Code: " + e.ErrorCode);
|
||||
Debug.Print(e.StackTrace);
|
||||
}
|
||||
@@ -79,6 +81,8 @@ catch (ApiException e)
|
||||
| **integerHeader** | **int?** | | [optional] |
|
||||
| **booleanHeader** | **bool?** | | [optional] |
|
||||
| **stringHeader** | **string?** | | [optional] |
|
||||
| **enumNonrefStringHeader** | **string?** | | [optional] |
|
||||
| **enumRefStringHeader** | [**StringEnumRef?**](StringEnumRef?.md) | | [optional] |
|
||||
|
||||
### Return type
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ All URIs are relative to *http://localhost:3000*
|
||||
|
||||
| Method | HTTP request | Description |
|
||||
|--------|--------------|-------------|
|
||||
| [**TestsPathStringPathStringIntegerPathInteger**](PathApi.md#testspathstringpathstringintegerpathinteger) | **GET** /path/string/{path_string}/integer/{path_integer} | Test path parameter(s) |
|
||||
| [**TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath**](PathApi.md#testspathstringpathstringintegerpathintegerenumnonrefstringpathenumrefstringpath) | **GET** /path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path} | Test path parameter(s) |
|
||||
|
||||
<a id="testspathstringpathstringintegerpathinteger"></a>
|
||||
# **TestsPathStringPathStringIntegerPathInteger**
|
||||
> string TestsPathStringPathStringIntegerPathInteger (string pathString, int pathInteger)
|
||||
<a id="testspathstringpathstringintegerpathintegerenumnonrefstringpathenumrefstringpath"></a>
|
||||
# **TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath**
|
||||
> string TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath (string pathString, int pathInteger, string enumNonrefStringPath, StringEnumRef enumRefStringPath)
|
||||
|
||||
Test path parameter(s)
|
||||
|
||||
@@ -24,7 +24,7 @@ using Org.OpenAPITools.Model;
|
||||
|
||||
namespace Example
|
||||
{
|
||||
public class TestsPathStringPathStringIntegerPathIntegerExample
|
||||
public class TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathExample
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
@@ -33,16 +33,18 @@ namespace Example
|
||||
var apiInstance = new PathApi(config);
|
||||
var pathString = "pathString_example"; // string |
|
||||
var pathInteger = 56; // int |
|
||||
var enumNonrefStringPath = "success"; // string |
|
||||
var enumRefStringPath = new StringEnumRef(); // StringEnumRef |
|
||||
|
||||
try
|
||||
{
|
||||
// Test path parameter(s)
|
||||
string result = apiInstance.TestsPathStringPathStringIntegerPathInteger(pathString, pathInteger);
|
||||
string result = apiInstance.TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(pathString, pathInteger, enumNonrefStringPath, enumRefStringPath);
|
||||
Debug.WriteLine(result);
|
||||
}
|
||||
catch (ApiException e)
|
||||
{
|
||||
Debug.Print("Exception when calling PathApi.TestsPathStringPathStringIntegerPathInteger: " + e.Message);
|
||||
Debug.Print("Exception when calling PathApi.TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath: " + e.Message);
|
||||
Debug.Print("Status Code: " + e.ErrorCode);
|
||||
Debug.Print(e.StackTrace);
|
||||
}
|
||||
@@ -51,21 +53,21 @@ namespace Example
|
||||
}
|
||||
```
|
||||
|
||||
#### Using the TestsPathStringPathStringIntegerPathIntegerWithHttpInfo variant
|
||||
#### Using the TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo variant
|
||||
This returns an ApiResponse object which contains the response data, status code and headers.
|
||||
|
||||
```csharp
|
||||
try
|
||||
{
|
||||
// Test path parameter(s)
|
||||
ApiResponse<string> response = apiInstance.TestsPathStringPathStringIntegerPathIntegerWithHttpInfo(pathString, pathInteger);
|
||||
ApiResponse<string> response = apiInstance.TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo(pathString, pathInteger, enumNonrefStringPath, enumRefStringPath);
|
||||
Debug.Write("Status Code: " + response.StatusCode);
|
||||
Debug.Write("Response Headers: " + response.Headers);
|
||||
Debug.Write("Response Body: " + response.Data);
|
||||
}
|
||||
catch (ApiException e)
|
||||
{
|
||||
Debug.Print("Exception when calling PathApi.TestsPathStringPathStringIntegerPathIntegerWithHttpInfo: " + e.Message);
|
||||
Debug.Print("Exception when calling PathApi.TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo: " + e.Message);
|
||||
Debug.Print("Status Code: " + e.ErrorCode);
|
||||
Debug.Print(e.StackTrace);
|
||||
}
|
||||
@@ -77,6 +79,8 @@ catch (ApiException e)
|
||||
|------|------|-------------|-------|
|
||||
| **pathString** | **string** | | |
|
||||
| **pathInteger** | **int** | | |
|
||||
| **enumNonrefStringPath** | **string** | | |
|
||||
| **enumRefStringPath** | [**StringEnumRef**](StringEnumRef.md) | | |
|
||||
|
||||
### Return type
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ All URIs are relative to *http://localhost:3000*
|
||||
|
||||
<a id="testenumrefstring"></a>
|
||||
# **TestEnumRefString**
|
||||
> string TestEnumRefString (StringEnumRef? enumRefStringQuery = null)
|
||||
> string TestEnumRefString (string? enumNonrefStringQuery = null, StringEnumRef? enumRefStringQuery = null)
|
||||
|
||||
Test query parameter(s)
|
||||
|
||||
@@ -38,12 +38,13 @@ namespace Example
|
||||
Configuration config = new Configuration();
|
||||
config.BasePath = "http://localhost:3000";
|
||||
var apiInstance = new QueryApi(config);
|
||||
var enumNonrefStringQuery = "success"; // string? | (optional)
|
||||
var enumRefStringQuery = new StringEnumRef?(); // StringEnumRef? | (optional)
|
||||
|
||||
try
|
||||
{
|
||||
// Test query parameter(s)
|
||||
string result = apiInstance.TestEnumRefString(enumRefStringQuery);
|
||||
string result = apiInstance.TestEnumRefString(enumNonrefStringQuery, enumRefStringQuery);
|
||||
Debug.WriteLine(result);
|
||||
}
|
||||
catch (ApiException e)
|
||||
@@ -64,7 +65,7 @@ This returns an ApiResponse object which contains the response data, status code
|
||||
try
|
||||
{
|
||||
// Test query parameter(s)
|
||||
ApiResponse<string> response = apiInstance.TestEnumRefStringWithHttpInfo(enumRefStringQuery);
|
||||
ApiResponse<string> response = apiInstance.TestEnumRefStringWithHttpInfo(enumNonrefStringQuery, enumRefStringQuery);
|
||||
Debug.Write("Status Code: " + response.StatusCode);
|
||||
Debug.Write("Response Headers: " + response.Headers);
|
||||
Debug.Write("Response Body: " + response.Data);
|
||||
@@ -81,6 +82,7 @@ catch (ApiException e)
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------|------|-------------|-------|
|
||||
| **enumNonrefStringQuery** | **string?** | | [optional] |
|
||||
| **enumRefStringQuery** | [**StringEnumRef?**](StringEnumRef?.md) | | [optional] |
|
||||
|
||||
### Return type
|
||||
|
||||
Reference in New Issue
Block a user