mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-10-14 00:13:50 +00:00
[java] [spring] Fix annotationLibrary option being ignored in spring generator (#22046)
* Fix annotationLibrary option being ignored in spring generator * Generate sample code * Sample generator weirdness * Revert "Sample generator weirdness"
This commit is contained in:
parent
6b1b5cc4c5
commit
fb277f82d5
@ -988,6 +988,11 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
codegenModel.imports.remove("ApiModel");
|
codegenModel.imports.remove("ApiModel");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getAnnotationLibrary() != AnnotationLibrary.SWAGGER2) {
|
||||||
|
// remove swagger imports
|
||||||
|
codegenModel.imports.remove("Schema");
|
||||||
|
}
|
||||||
|
|
||||||
return codegenModel;
|
return codegenModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ import static org.openapitools.codegen.languages.SpringCodegen.*;
|
|||||||
import static org.openapitools.codegen.languages.features.DocumentationProviderFeatures.ANNOTATION_LIBRARY;
|
import static org.openapitools.codegen.languages.features.DocumentationProviderFeatures.ANNOTATION_LIBRARY;
|
||||||
import static org.openapitools.codegen.languages.features.DocumentationProviderFeatures.DOCUMENTATION_PROVIDER;
|
import static org.openapitools.codegen.languages.features.DocumentationProviderFeatures.DOCUMENTATION_PROVIDER;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.fail;
|
import static org.testng.Assert.fail;
|
||||||
|
|
||||||
public class SpringCodegenTest {
|
public class SpringCodegenTest {
|
||||||
@ -5759,4 +5760,72 @@ public class SpringCodegenTest {
|
|||||||
.assertMethodAnnotations()
|
.assertMethodAnnotations()
|
||||||
.containsWithNameAndDoesContainAttributes("RequestMapping", List.of("version"));
|
.containsWithNameAndDoesContainAttributes("RequestMapping", List.of("version"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void annotationLibraryDoesNotCauseImportConflictsInSpring() throws IOException {
|
||||||
|
Map<String, Object> properties = new HashMap<>();
|
||||||
|
properties.put("documentationProvider", "source");
|
||||||
|
properties.put("annotationLibrary", "none");
|
||||||
|
|
||||||
|
File output = Files.createTempDirectory("test").toFile();
|
||||||
|
output.deleteOnExit();
|
||||||
|
|
||||||
|
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/java/native/issue21991.yaml");
|
||||||
|
|
||||||
|
SpringCodegen codegen = new SpringCodegen();
|
||||||
|
codegen.setLibrary(SPRING_BOOT);
|
||||||
|
codegen.setOpenAPI(openAPI);
|
||||||
|
codegen.setOutputDir(output.getAbsolutePath());
|
||||||
|
codegen.additionalProperties().putAll(properties);
|
||||||
|
|
||||||
|
ClientOptInput input = new ClientOptInput()
|
||||||
|
.openAPI(openAPI)
|
||||||
|
.config(codegen);
|
||||||
|
|
||||||
|
DefaultGenerator generator = new DefaultGenerator();
|
||||||
|
|
||||||
|
Map<String, File> files = generator.opts(input).generate().stream()
|
||||||
|
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||||
|
|
||||||
|
File apiFile = files.get("Schema.java");
|
||||||
|
assertNotNull(apiFile);
|
||||||
|
|
||||||
|
JavaFileAssert.assertThat(apiFile).fileDoesNotContain(
|
||||||
|
"import io.swagger.v3.oas.annotations.media.Schema;"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void annotationLibraryDoesNotCauseImportConflictsInSpringWithAnnotationLibrary() throws IOException {
|
||||||
|
Map<String, Object> properties = new HashMap<>();
|
||||||
|
properties.put("documentationProvider", "source");
|
||||||
|
properties.put("annotationLibrary", "swagger2");
|
||||||
|
|
||||||
|
File output = Files.createTempDirectory("test").toFile();
|
||||||
|
output.deleteOnExit();
|
||||||
|
|
||||||
|
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/java/native/issue21991.yaml");
|
||||||
|
|
||||||
|
SpringCodegen codegen = new SpringCodegen();
|
||||||
|
codegen.setOpenAPI(openAPI);
|
||||||
|
codegen.setLibrary(SPRING_BOOT);
|
||||||
|
codegen.setOutputDir(output.getAbsolutePath());
|
||||||
|
codegen.additionalProperties().putAll(properties);
|
||||||
|
|
||||||
|
ClientOptInput input = new ClientOptInput()
|
||||||
|
.openAPI(openAPI)
|
||||||
|
.config(codegen);
|
||||||
|
|
||||||
|
DefaultGenerator generator = new DefaultGenerator();
|
||||||
|
|
||||||
|
Map<String, File> files = generator.opts(input).generate().stream()
|
||||||
|
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||||
|
|
||||||
|
File apiFile = files.get("Schema.java");
|
||||||
|
assertNotNull(apiFile);
|
||||||
|
|
||||||
|
JavaFileAssert.assertThat(apiFile).fileContains(
|
||||||
|
"import io.swagger.v3.oas.annotations.media.Schema;"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
# Category
|
||||||
|
|
||||||
|
A category for a pet
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
|------------ | ------------- | ------------- | -------------|
|
||||||
|
|**id** | **Long** | | [optional] |
|
||||||
|
|**name** | **String** | | [optional] |
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
|
||||||
|
# ModelApiResponse
|
||||||
|
|
||||||
|
Describes the result of uploading an image resource
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
|------------ | ------------- | ------------- | -------------|
|
||||||
|
|**code** | **Integer** | | [optional] |
|
||||||
|
|**type** | **String** | | [optional] |
|
||||||
|
|**message** | **String** | | [optional] |
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
|
||||||
|
# Order
|
||||||
|
|
||||||
|
An order for a pets from the pet store
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
|------------ | ------------- | ------------- | -------------|
|
||||||
|
|**id** | **Long** | | [optional] |
|
||||||
|
|**petId** | **Long** | | [optional] |
|
||||||
|
|**quantity** | **Integer** | | [optional] |
|
||||||
|
|**shipDate** | **OffsetDateTime** | | [optional] |
|
||||||
|
|**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] |
|
||||||
|
|**complete** | **Boolean** | | [optional] |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Enum: StatusEnum
|
||||||
|
|
||||||
|
| Name | Value |
|
||||||
|
|---- | -----|
|
||||||
|
| PLACED | "placed" |
|
||||||
|
| APPROVED | "approved" |
|
||||||
|
| DELIVERED | "delivered" |
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
|
||||||
|
# Pet
|
||||||
|
|
||||||
|
A pet for sale in the pet store
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
|------------ | ------------- | ------------- | -------------|
|
||||||
|
|**id** | **Long** | | [optional] |
|
||||||
|
|**category** | [**Category**](Category.md) | | [optional] |
|
||||||
|
|**name** | **String** | | |
|
||||||
|
|**photoUrls** | **List<String>** | | |
|
||||||
|
|**tags** | [**List<Tag>**](Tag.md) | | [optional] |
|
||||||
|
|**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Enum: StatusEnum
|
||||||
|
|
||||||
|
| Name | Value |
|
||||||
|
|---- | -----|
|
||||||
|
| AVAILABLE | "available" |
|
||||||
|
| PENDING | "pending" |
|
||||||
|
| SOLD | "sold" |
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,266 @@
|
|||||||
|
# StoreApi
|
||||||
|
|
||||||
|
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||||
|
|
||||||
|
| Method | HTTP request | Description |
|
||||||
|
|------------- | ------------- | -------------|
|
||||||
|
| [**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID |
|
||||||
|
| [**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status |
|
||||||
|
| [**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID |
|
||||||
|
| [**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet |
|
||||||
|
|
||||||
|
|
||||||
|
<a id="deleteOrder"></a>
|
||||||
|
# **deleteOrder**
|
||||||
|
> deleteOrder(orderId)
|
||||||
|
|
||||||
|
Delete purchase order by ID
|
||||||
|
|
||||||
|
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```java
|
||||||
|
// Import classes:
|
||||||
|
import org.openapitools.client.ApiClient;
|
||||||
|
import org.openapitools.client.ApiException;
|
||||||
|
import org.openapitools.client.Configuration;
|
||||||
|
import org.openapitools.client.models.*;
|
||||||
|
import org.openapitools.client.api.StoreApi;
|
||||||
|
|
||||||
|
public class Example {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
|
defaultClient.setBasePath("http://petstore.swagger.io/v2");
|
||||||
|
|
||||||
|
StoreApi apiInstance = new StoreApi(defaultClient);
|
||||||
|
String orderId = "orderId_example"; // String | ID of the order that needs to be deleted
|
||||||
|
try {
|
||||||
|
apiInstance.deleteOrder(orderId);
|
||||||
|
} catch (ApiException e) {
|
||||||
|
System.err.println("Exception when calling StoreApi#deleteOrder");
|
||||||
|
System.err.println("Status code: " + e.getCode());
|
||||||
|
System.err.println("Reason: " + e.getResponseBody());
|
||||||
|
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
|------------- | ------------- | ------------- | -------------|
|
||||||
|
| **orderId** | **String**| ID of the order that needs to be deleted | |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
| **400** | Invalid ID supplied | - |
|
||||||
|
| **404** | Order not found | - |
|
||||||
|
|
||||||
|
<a id="getInventory"></a>
|
||||||
|
# **getInventory**
|
||||||
|
> Map<String, Integer> getInventory()
|
||||||
|
|
||||||
|
Returns pet inventories by status
|
||||||
|
|
||||||
|
Returns a map of status codes to quantities
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```java
|
||||||
|
// Import classes:
|
||||||
|
import org.openapitools.client.ApiClient;
|
||||||
|
import org.openapitools.client.ApiException;
|
||||||
|
import org.openapitools.client.Configuration;
|
||||||
|
import org.openapitools.client.auth.*;
|
||||||
|
import org.openapitools.client.models.*;
|
||||||
|
import org.openapitools.client.api.StoreApi;
|
||||||
|
|
||||||
|
public class Example {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
|
defaultClient.setBasePath("http://petstore.swagger.io/v2");
|
||||||
|
|
||||||
|
// Configure API key authorization: api_key
|
||||||
|
ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key");
|
||||||
|
api_key.setApiKey("YOUR API KEY");
|
||||||
|
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
|
||||||
|
//api_key.setApiKeyPrefix("Token");
|
||||||
|
|
||||||
|
StoreApi apiInstance = new StoreApi(defaultClient);
|
||||||
|
try {
|
||||||
|
Map<String, Integer> result = apiInstance.getInventory();
|
||||||
|
System.out.println(result);
|
||||||
|
} catch (ApiException e) {
|
||||||
|
System.err.println("Exception when calling StoreApi#getInventory");
|
||||||
|
System.err.println("Status code: " + e.getCode());
|
||||||
|
System.err.println("Reason: " + e.getResponseBody());
|
||||||
|
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
This endpoint does not need any parameter.
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**Map<String, Integer>**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](../README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/json
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
| **200** | successful operation | - |
|
||||||
|
|
||||||
|
<a id="getOrderById"></a>
|
||||||
|
# **getOrderById**
|
||||||
|
> Order getOrderById(orderId)
|
||||||
|
|
||||||
|
Find purchase order by ID
|
||||||
|
|
||||||
|
For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```java
|
||||||
|
// Import classes:
|
||||||
|
import org.openapitools.client.ApiClient;
|
||||||
|
import org.openapitools.client.ApiException;
|
||||||
|
import org.openapitools.client.Configuration;
|
||||||
|
import org.openapitools.client.models.*;
|
||||||
|
import org.openapitools.client.api.StoreApi;
|
||||||
|
|
||||||
|
public class Example {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
|
defaultClient.setBasePath("http://petstore.swagger.io/v2");
|
||||||
|
|
||||||
|
StoreApi apiInstance = new StoreApi(defaultClient);
|
||||||
|
Long orderId = 56L; // Long | ID of pet that needs to be fetched
|
||||||
|
try {
|
||||||
|
Order result = apiInstance.getOrderById(orderId);
|
||||||
|
System.out.println(result);
|
||||||
|
} catch (ApiException e) {
|
||||||
|
System.err.println("Exception when calling StoreApi#getOrderById");
|
||||||
|
System.err.println("Status code: " + e.getCode());
|
||||||
|
System.err.println("Reason: " + e.getResponseBody());
|
||||||
|
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
|------------- | ------------- | ------------- | -------------|
|
||||||
|
| **orderId** | **Long**| ID of pet that needs to be fetched | |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**Order**](Order.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
| **200** | successful operation | - |
|
||||||
|
| **400** | Invalid ID supplied | - |
|
||||||
|
| **404** | Order not found | - |
|
||||||
|
|
||||||
|
<a id="placeOrder"></a>
|
||||||
|
# **placeOrder**
|
||||||
|
> Order placeOrder(order)
|
||||||
|
|
||||||
|
Place an order for a pet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```java
|
||||||
|
// Import classes:
|
||||||
|
import org.openapitools.client.ApiClient;
|
||||||
|
import org.openapitools.client.ApiException;
|
||||||
|
import org.openapitools.client.Configuration;
|
||||||
|
import org.openapitools.client.models.*;
|
||||||
|
import org.openapitools.client.api.StoreApi;
|
||||||
|
|
||||||
|
public class Example {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
|
defaultClient.setBasePath("http://petstore.swagger.io/v2");
|
||||||
|
|
||||||
|
StoreApi apiInstance = new StoreApi(defaultClient);
|
||||||
|
Order order = new Order(); // Order | order placed for purchasing the pet
|
||||||
|
try {
|
||||||
|
Order result = apiInstance.placeOrder(order);
|
||||||
|
System.out.println(result);
|
||||||
|
} catch (ApiException e) {
|
||||||
|
System.err.println("Exception when calling StoreApi#placeOrder");
|
||||||
|
System.err.println("Status code: " + e.getCode());
|
||||||
|
System.err.println("Reason: " + e.getResponseBody());
|
||||||
|
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
|------------- | ------------- | ------------- | -------------|
|
||||||
|
| **order** | [**Order**](Order.md)| order placed for purchasing the pet | |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**Order**](Order.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
| **200** | successful operation | - |
|
||||||
|
| **400** | Invalid Order | - |
|
||||||
|
|
@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
# Tag
|
||||||
|
|
||||||
|
A tag for a pet
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
|------------ | ------------- | ------------- | -------------|
|
||||||
|
|**id** | **Long** | | [optional] |
|
||||||
|
|**name** | **String** | | [optional] |
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
|
||||||
|
# User
|
||||||
|
|
||||||
|
A User who is purchasing from the pet store
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
|------------ | ------------- | ------------- | -------------|
|
||||||
|
|**id** | **Long** | | [optional] |
|
||||||
|
|**username** | **String** | | [optional] |
|
||||||
|
|**firstName** | **String** | | [optional] |
|
||||||
|
|**lastName** | **String** | | [optional] |
|
||||||
|
|**email** | **String** | | [optional] |
|
||||||
|
|**password** | **String** | | [optional] |
|
||||||
|
|**phone** | **String** | | [optional] |
|
||||||
|
|**userStatus** | **Integer** | User Status | [optional] |
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,553 @@
|
|||||||
|
# UserApi
|
||||||
|
|
||||||
|
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||||
|
|
||||||
|
| Method | HTTP request | Description |
|
||||||
|
|------------- | ------------- | -------------|
|
||||||
|
| [**createUser**](UserApi.md#createUser) | **POST** /user | Create user |
|
||||||
|
| [**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array |
|
||||||
|
| [**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array |
|
||||||
|
| [**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user |
|
||||||
|
| [**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name |
|
||||||
|
| [**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system |
|
||||||
|
| [**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session |
|
||||||
|
| [**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user |
|
||||||
|
|
||||||
|
|
||||||
|
<a id="createUser"></a>
|
||||||
|
# **createUser**
|
||||||
|
> createUser(user)
|
||||||
|
|
||||||
|
Create user
|
||||||
|
|
||||||
|
This can only be done by the logged in user.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```java
|
||||||
|
// Import classes:
|
||||||
|
import org.openapitools.client.ApiClient;
|
||||||
|
import org.openapitools.client.ApiException;
|
||||||
|
import org.openapitools.client.Configuration;
|
||||||
|
import org.openapitools.client.auth.*;
|
||||||
|
import org.openapitools.client.models.*;
|
||||||
|
import org.openapitools.client.api.UserApi;
|
||||||
|
|
||||||
|
public class Example {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
|
defaultClient.setBasePath("http://petstore.swagger.io/v2");
|
||||||
|
|
||||||
|
// Configure API key authorization: api_key
|
||||||
|
ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key");
|
||||||
|
api_key.setApiKey("YOUR API KEY");
|
||||||
|
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
|
||||||
|
//api_key.setApiKeyPrefix("Token");
|
||||||
|
|
||||||
|
UserApi apiInstance = new UserApi(defaultClient);
|
||||||
|
User user = new User(); // User | Created user object
|
||||||
|
try {
|
||||||
|
apiInstance.createUser(user);
|
||||||
|
} catch (ApiException e) {
|
||||||
|
System.err.println("Exception when calling UserApi#createUser");
|
||||||
|
System.err.println("Status code: " + e.getCode());
|
||||||
|
System.err.println("Reason: " + e.getResponseBody());
|
||||||
|
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
|------------- | ------------- | ------------- | -------------|
|
||||||
|
| **user** | [**User**](User.md)| Created user object | |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](../README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
| **0** | successful operation | - |
|
||||||
|
|
||||||
|
<a id="createUsersWithArrayInput"></a>
|
||||||
|
# **createUsersWithArrayInput**
|
||||||
|
> createUsersWithArrayInput(user)
|
||||||
|
|
||||||
|
Creates list of users with given input array
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```java
|
||||||
|
// Import classes:
|
||||||
|
import org.openapitools.client.ApiClient;
|
||||||
|
import org.openapitools.client.ApiException;
|
||||||
|
import org.openapitools.client.Configuration;
|
||||||
|
import org.openapitools.client.auth.*;
|
||||||
|
import org.openapitools.client.models.*;
|
||||||
|
import org.openapitools.client.api.UserApi;
|
||||||
|
|
||||||
|
public class Example {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
|
defaultClient.setBasePath("http://petstore.swagger.io/v2");
|
||||||
|
|
||||||
|
// Configure API key authorization: api_key
|
||||||
|
ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key");
|
||||||
|
api_key.setApiKey("YOUR API KEY");
|
||||||
|
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
|
||||||
|
//api_key.setApiKeyPrefix("Token");
|
||||||
|
|
||||||
|
UserApi apiInstance = new UserApi(defaultClient);
|
||||||
|
List<User> user = Arrays.asList(); // List<User> | List of user object
|
||||||
|
try {
|
||||||
|
apiInstance.createUsersWithArrayInput(user);
|
||||||
|
} catch (ApiException e) {
|
||||||
|
System.err.println("Exception when calling UserApi#createUsersWithArrayInput");
|
||||||
|
System.err.println("Status code: " + e.getCode());
|
||||||
|
System.err.println("Reason: " + e.getResponseBody());
|
||||||
|
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
|------------- | ------------- | ------------- | -------------|
|
||||||
|
| **user** | [**List<User>**](User.md)| List of user object | |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](../README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
| **0** | successful operation | - |
|
||||||
|
|
||||||
|
<a id="createUsersWithListInput"></a>
|
||||||
|
# **createUsersWithListInput**
|
||||||
|
> createUsersWithListInput(user)
|
||||||
|
|
||||||
|
Creates list of users with given input array
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```java
|
||||||
|
// Import classes:
|
||||||
|
import org.openapitools.client.ApiClient;
|
||||||
|
import org.openapitools.client.ApiException;
|
||||||
|
import org.openapitools.client.Configuration;
|
||||||
|
import org.openapitools.client.auth.*;
|
||||||
|
import org.openapitools.client.models.*;
|
||||||
|
import org.openapitools.client.api.UserApi;
|
||||||
|
|
||||||
|
public class Example {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
|
defaultClient.setBasePath("http://petstore.swagger.io/v2");
|
||||||
|
|
||||||
|
// Configure API key authorization: api_key
|
||||||
|
ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key");
|
||||||
|
api_key.setApiKey("YOUR API KEY");
|
||||||
|
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
|
||||||
|
//api_key.setApiKeyPrefix("Token");
|
||||||
|
|
||||||
|
UserApi apiInstance = new UserApi(defaultClient);
|
||||||
|
List<User> user = Arrays.asList(); // List<User> | List of user object
|
||||||
|
try {
|
||||||
|
apiInstance.createUsersWithListInput(user);
|
||||||
|
} catch (ApiException e) {
|
||||||
|
System.err.println("Exception when calling UserApi#createUsersWithListInput");
|
||||||
|
System.err.println("Status code: " + e.getCode());
|
||||||
|
System.err.println("Reason: " + e.getResponseBody());
|
||||||
|
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
|------------- | ------------- | ------------- | -------------|
|
||||||
|
| **user** | [**List<User>**](User.md)| List of user object | |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](../README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
| **0** | successful operation | - |
|
||||||
|
|
||||||
|
<a id="deleteUser"></a>
|
||||||
|
# **deleteUser**
|
||||||
|
> deleteUser(username)
|
||||||
|
|
||||||
|
Delete user
|
||||||
|
|
||||||
|
This can only be done by the logged in user.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```java
|
||||||
|
// Import classes:
|
||||||
|
import org.openapitools.client.ApiClient;
|
||||||
|
import org.openapitools.client.ApiException;
|
||||||
|
import org.openapitools.client.Configuration;
|
||||||
|
import org.openapitools.client.auth.*;
|
||||||
|
import org.openapitools.client.models.*;
|
||||||
|
import org.openapitools.client.api.UserApi;
|
||||||
|
|
||||||
|
public class Example {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
|
defaultClient.setBasePath("http://petstore.swagger.io/v2");
|
||||||
|
|
||||||
|
// Configure API key authorization: api_key
|
||||||
|
ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key");
|
||||||
|
api_key.setApiKey("YOUR API KEY");
|
||||||
|
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
|
||||||
|
//api_key.setApiKeyPrefix("Token");
|
||||||
|
|
||||||
|
UserApi apiInstance = new UserApi(defaultClient);
|
||||||
|
String username = "username_example"; // String | The name that needs to be deleted
|
||||||
|
try {
|
||||||
|
apiInstance.deleteUser(username);
|
||||||
|
} catch (ApiException e) {
|
||||||
|
System.err.println("Exception when calling UserApi#deleteUser");
|
||||||
|
System.err.println("Status code: " + e.getCode());
|
||||||
|
System.err.println("Reason: " + e.getResponseBody());
|
||||||
|
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
|------------- | ------------- | ------------- | -------------|
|
||||||
|
| **username** | **String**| The name that needs to be deleted | |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](../README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
| **400** | Invalid username supplied | - |
|
||||||
|
| **404** | User not found | - |
|
||||||
|
|
||||||
|
<a id="getUserByName"></a>
|
||||||
|
# **getUserByName**
|
||||||
|
> User getUserByName(username)
|
||||||
|
|
||||||
|
Get user by user name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```java
|
||||||
|
// Import classes:
|
||||||
|
import org.openapitools.client.ApiClient;
|
||||||
|
import org.openapitools.client.ApiException;
|
||||||
|
import org.openapitools.client.Configuration;
|
||||||
|
import org.openapitools.client.models.*;
|
||||||
|
import org.openapitools.client.api.UserApi;
|
||||||
|
|
||||||
|
public class Example {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
|
defaultClient.setBasePath("http://petstore.swagger.io/v2");
|
||||||
|
|
||||||
|
UserApi apiInstance = new UserApi(defaultClient);
|
||||||
|
String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing.
|
||||||
|
try {
|
||||||
|
User result = apiInstance.getUserByName(username);
|
||||||
|
System.out.println(result);
|
||||||
|
} catch (ApiException e) {
|
||||||
|
System.err.println("Exception when calling UserApi#getUserByName");
|
||||||
|
System.err.println("Status code: " + e.getCode());
|
||||||
|
System.err.println("Reason: " + e.getResponseBody());
|
||||||
|
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
|------------- | ------------- | ------------- | -------------|
|
||||||
|
| **username** | **String**| The name that needs to be fetched. Use user1 for testing. | |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**User**](User.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
| **200** | successful operation | - |
|
||||||
|
| **400** | Invalid username supplied | - |
|
||||||
|
| **404** | User not found | - |
|
||||||
|
|
||||||
|
<a id="loginUser"></a>
|
||||||
|
# **loginUser**
|
||||||
|
> String loginUser(username, password)
|
||||||
|
|
||||||
|
Logs user into the system
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```java
|
||||||
|
// Import classes:
|
||||||
|
import org.openapitools.client.ApiClient;
|
||||||
|
import org.openapitools.client.ApiException;
|
||||||
|
import org.openapitools.client.Configuration;
|
||||||
|
import org.openapitools.client.models.*;
|
||||||
|
import org.openapitools.client.api.UserApi;
|
||||||
|
|
||||||
|
public class Example {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
|
defaultClient.setBasePath("http://petstore.swagger.io/v2");
|
||||||
|
|
||||||
|
UserApi apiInstance = new UserApi(defaultClient);
|
||||||
|
String username = "username_example"; // String | The user name for login
|
||||||
|
String password = "password_example"; // String | The password for login in clear text
|
||||||
|
try {
|
||||||
|
String result = apiInstance.loginUser(username, password);
|
||||||
|
System.out.println(result);
|
||||||
|
} catch (ApiException e) {
|
||||||
|
System.err.println("Exception when calling UserApi#loginUser");
|
||||||
|
System.err.println("Status code: " + e.getCode());
|
||||||
|
System.err.println("Reason: " + e.getResponseBody());
|
||||||
|
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
|------------- | ------------- | ------------- | -------------|
|
||||||
|
| **username** | **String**| The user name for login | |
|
||||||
|
| **password** | **String**| The password for login in clear text | |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**String**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
| **200** | successful operation | * Set-Cookie - Cookie authentication key for use with the `api_key` apiKey authentication. <br> * X-Rate-Limit - calls per hour allowed by the user <br> * X-Expires-After - date in UTC when token expires <br> |
|
||||||
|
| **400** | Invalid username/password supplied | - |
|
||||||
|
|
||||||
|
<a id="logoutUser"></a>
|
||||||
|
# **logoutUser**
|
||||||
|
> logoutUser()
|
||||||
|
|
||||||
|
Logs out current logged in user session
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```java
|
||||||
|
// Import classes:
|
||||||
|
import org.openapitools.client.ApiClient;
|
||||||
|
import org.openapitools.client.ApiException;
|
||||||
|
import org.openapitools.client.Configuration;
|
||||||
|
import org.openapitools.client.auth.*;
|
||||||
|
import org.openapitools.client.models.*;
|
||||||
|
import org.openapitools.client.api.UserApi;
|
||||||
|
|
||||||
|
public class Example {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
|
defaultClient.setBasePath("http://petstore.swagger.io/v2");
|
||||||
|
|
||||||
|
// Configure API key authorization: api_key
|
||||||
|
ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key");
|
||||||
|
api_key.setApiKey("YOUR API KEY");
|
||||||
|
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
|
||||||
|
//api_key.setApiKeyPrefix("Token");
|
||||||
|
|
||||||
|
UserApi apiInstance = new UserApi(defaultClient);
|
||||||
|
try {
|
||||||
|
apiInstance.logoutUser();
|
||||||
|
} catch (ApiException e) {
|
||||||
|
System.err.println("Exception when calling UserApi#logoutUser");
|
||||||
|
System.err.println("Status code: " + e.getCode());
|
||||||
|
System.err.println("Reason: " + e.getResponseBody());
|
||||||
|
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
This endpoint does not need any parameter.
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](../README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
| **0** | successful operation | - |
|
||||||
|
|
||||||
|
<a id="updateUser"></a>
|
||||||
|
# **updateUser**
|
||||||
|
> updateUser(username, user)
|
||||||
|
|
||||||
|
Updated user
|
||||||
|
|
||||||
|
This can only be done by the logged in user.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```java
|
||||||
|
// Import classes:
|
||||||
|
import org.openapitools.client.ApiClient;
|
||||||
|
import org.openapitools.client.ApiException;
|
||||||
|
import org.openapitools.client.Configuration;
|
||||||
|
import org.openapitools.client.auth.*;
|
||||||
|
import org.openapitools.client.models.*;
|
||||||
|
import org.openapitools.client.api.UserApi;
|
||||||
|
|
||||||
|
public class Example {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
|
defaultClient.setBasePath("http://petstore.swagger.io/v2");
|
||||||
|
|
||||||
|
// Configure API key authorization: api_key
|
||||||
|
ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key");
|
||||||
|
api_key.setApiKey("YOUR API KEY");
|
||||||
|
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
|
||||||
|
//api_key.setApiKeyPrefix("Token");
|
||||||
|
|
||||||
|
UserApi apiInstance = new UserApi(defaultClient);
|
||||||
|
String username = "username_example"; // String | name that need to be deleted
|
||||||
|
User user = new User(); // User | Updated user object
|
||||||
|
try {
|
||||||
|
apiInstance.updateUser(username, user);
|
||||||
|
} catch (ApiException e) {
|
||||||
|
System.err.println("Exception when calling UserApi#updateUser");
|
||||||
|
System.err.println("Status code: " + e.getCode());
|
||||||
|
System.err.println("Reason: " + e.getResponseBody());
|
||||||
|
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
|------------- | ------------- | ------------- | -------------|
|
||||||
|
| **username** | **String**| name that need to be deleted | |
|
||||||
|
| **user** | [**User**](User.md)| Updated user object | |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](../README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
| **400** | Invalid user supplied | - |
|
||||||
|
| **404** | User not found | - |
|
||||||
|
|
@ -0,0 +1,586 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.openapitools.client.api;
|
||||||
|
|
||||||
|
import org.openapitools.client.ApiCallback;
|
||||||
|
import org.openapitools.client.ApiClient;
|
||||||
|
import org.openapitools.client.ApiException;
|
||||||
|
import org.openapitools.client.ApiResponse;
|
||||||
|
import org.openapitools.client.Configuration;
|
||||||
|
import org.openapitools.client.Pair;
|
||||||
|
import org.openapitools.client.ProgressRequestBody;
|
||||||
|
import org.openapitools.client.ProgressResponseBody;
|
||||||
|
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
|
import org.openapitools.client.model.Order;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class StoreApi {
|
||||||
|
private ApiClient localVarApiClient;
|
||||||
|
private int localHostIndex;
|
||||||
|
private String localCustomBaseUrl;
|
||||||
|
|
||||||
|
public StoreApi() {
|
||||||
|
this(Configuration.getDefaultApiClient());
|
||||||
|
}
|
||||||
|
|
||||||
|
public StoreApi(ApiClient apiClient) {
|
||||||
|
this.localVarApiClient = apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiClient getApiClient() {
|
||||||
|
return localVarApiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApiClient(ApiClient apiClient) {
|
||||||
|
this.localVarApiClient = apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHostIndex() {
|
||||||
|
return localHostIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHostIndex(int hostIndex) {
|
||||||
|
this.localHostIndex = hostIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCustomBaseUrl() {
|
||||||
|
return localCustomBaseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomBaseUrl(String customBaseUrl) {
|
||||||
|
this.localCustomBaseUrl = customBaseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build call for deleteOrder
|
||||||
|
* @param orderId ID of the order that needs to be deleted (required)
|
||||||
|
* @param _callback Callback for upload/download progress
|
||||||
|
* @return Call to execute
|
||||||
|
* @throws ApiException If fail to serialize the request body object
|
||||||
|
* @http.response.details
|
||||||
|
<table border="1">
|
||||||
|
<caption>Response Details</caption>
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 400 </td><td> Invalid ID supplied </td><td> - </td></tr>
|
||||||
|
<tr><td> 404 </td><td> Order not found </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public okhttp3.Call deleteOrderCall(@javax.annotation.Nonnull String orderId, final ApiCallback _callback) throws ApiException {
|
||||||
|
String basePath = null;
|
||||||
|
// Operation Servers
|
||||||
|
String[] localBasePaths = new String[] { };
|
||||||
|
|
||||||
|
// Determine Base Path to Use
|
||||||
|
if (localCustomBaseUrl != null){
|
||||||
|
basePath = localCustomBaseUrl;
|
||||||
|
} else if ( localBasePaths.length > 0 ) {
|
||||||
|
basePath = localBasePaths[localHostIndex];
|
||||||
|
} else {
|
||||||
|
basePath = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object localVarPostBody = null;
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String localVarPath = "/store/order/{orderId}"
|
||||||
|
.replace("{" + "orderId" + "}", localVarApiClient.escapeString(orderId.toString()));
|
||||||
|
|
||||||
|
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||||
|
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
|
||||||
|
Map<String, String> localVarCookieParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
final String[] localVarAccepts = {
|
||||||
|
};
|
||||||
|
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
|
||||||
|
if (localVarAccept != null) {
|
||||||
|
localVarHeaderParams.put("Accept", localVarAccept);
|
||||||
|
}
|
||||||
|
|
||||||
|
final String[] localVarContentTypes = {
|
||||||
|
};
|
||||||
|
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
|
||||||
|
if (localVarContentType != null) {
|
||||||
|
localVarHeaderParams.put("Content-Type", localVarContentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] localVarAuthNames = new String[] { };
|
||||||
|
return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
private okhttp3.Call deleteOrderValidateBeforeCall(@javax.annotation.Nonnull String orderId, final ApiCallback _callback) throws ApiException {
|
||||||
|
// verify the required parameter 'orderId' is set
|
||||||
|
if (orderId == null) {
|
||||||
|
throw new ApiException("Missing the required parameter 'orderId' when calling deleteOrder(Async)");
|
||||||
|
}
|
||||||
|
|
||||||
|
return deleteOrderCall(orderId, _callback);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete purchase order by ID
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
* @param orderId ID of the order that needs to be deleted (required)
|
||||||
|
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||||
|
* @http.response.details
|
||||||
|
<table border="1">
|
||||||
|
<caption>Response Details</caption>
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 400 </td><td> Invalid ID supplied </td><td> - </td></tr>
|
||||||
|
<tr><td> 404 </td><td> Order not found </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public void deleteOrder(@javax.annotation.Nonnull String orderId) throws ApiException {
|
||||||
|
deleteOrderWithHttpInfo(orderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete purchase order by ID
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
* @param orderId ID of the order that needs to be deleted (required)
|
||||||
|
* @return ApiResponse<Void>
|
||||||
|
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||||
|
* @http.response.details
|
||||||
|
<table border="1">
|
||||||
|
<caption>Response Details</caption>
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 400 </td><td> Invalid ID supplied </td><td> - </td></tr>
|
||||||
|
<tr><td> 404 </td><td> Order not found </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public ApiResponse<Void> deleteOrderWithHttpInfo(@javax.annotation.Nonnull String orderId) throws ApiException {
|
||||||
|
okhttp3.Call localVarCall = deleteOrderValidateBeforeCall(orderId, null);
|
||||||
|
return localVarApiClient.execute(localVarCall);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete purchase order by ID (asynchronously)
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
* @param orderId ID of the order that needs to be deleted (required)
|
||||||
|
* @param _callback The callback to be executed when the API call finishes
|
||||||
|
* @return The request call
|
||||||
|
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
|
||||||
|
* @http.response.details
|
||||||
|
<table border="1">
|
||||||
|
<caption>Response Details</caption>
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 400 </td><td> Invalid ID supplied </td><td> - </td></tr>
|
||||||
|
<tr><td> 404 </td><td> Order not found </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public okhttp3.Call deleteOrderAsync(@javax.annotation.Nonnull String orderId, final ApiCallback<Void> _callback) throws ApiException {
|
||||||
|
|
||||||
|
okhttp3.Call localVarCall = deleteOrderValidateBeforeCall(orderId, _callback);
|
||||||
|
localVarApiClient.executeAsync(localVarCall, _callback);
|
||||||
|
return localVarCall;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Build call for getInventory
|
||||||
|
* @param _callback Callback for upload/download progress
|
||||||
|
* @return Call to execute
|
||||||
|
* @throws ApiException If fail to serialize the request body object
|
||||||
|
* @http.response.details
|
||||||
|
<table border="1">
|
||||||
|
<caption>Response Details</caption>
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 200 </td><td> successful operation </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public okhttp3.Call getInventoryCall(final ApiCallback _callback) throws ApiException {
|
||||||
|
String basePath = null;
|
||||||
|
// Operation Servers
|
||||||
|
String[] localBasePaths = new String[] { };
|
||||||
|
|
||||||
|
// Determine Base Path to Use
|
||||||
|
if (localCustomBaseUrl != null){
|
||||||
|
basePath = localCustomBaseUrl;
|
||||||
|
} else if ( localBasePaths.length > 0 ) {
|
||||||
|
basePath = localBasePaths[localHostIndex];
|
||||||
|
} else {
|
||||||
|
basePath = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object localVarPostBody = null;
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String localVarPath = "/store/inventory";
|
||||||
|
|
||||||
|
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||||
|
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
|
||||||
|
Map<String, String> localVarCookieParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
final String[] localVarAccepts = {
|
||||||
|
"application/json"
|
||||||
|
};
|
||||||
|
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
|
||||||
|
if (localVarAccept != null) {
|
||||||
|
localVarHeaderParams.put("Accept", localVarAccept);
|
||||||
|
}
|
||||||
|
|
||||||
|
final String[] localVarContentTypes = {
|
||||||
|
};
|
||||||
|
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
|
||||||
|
if (localVarContentType != null) {
|
||||||
|
localVarHeaderParams.put("Content-Type", localVarContentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] localVarAuthNames = new String[] { "api_key" };
|
||||||
|
return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
private okhttp3.Call getInventoryValidateBeforeCall(final ApiCallback _callback) throws ApiException {
|
||||||
|
return getInventoryCall(_callback);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns pet inventories by status
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
* @return Map<String, Integer>
|
||||||
|
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||||
|
* @http.response.details
|
||||||
|
<table border="1">
|
||||||
|
<caption>Response Details</caption>
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 200 </td><td> successful operation </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public Map<String, Integer> getInventory() throws ApiException {
|
||||||
|
ApiResponse<Map<String, Integer>> localVarResp = getInventoryWithHttpInfo();
|
||||||
|
return localVarResp.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns pet inventories by status
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
* @return ApiResponse<Map<String, Integer>>
|
||||||
|
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||||
|
* @http.response.details
|
||||||
|
<table border="1">
|
||||||
|
<caption>Response Details</caption>
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 200 </td><td> successful operation </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public ApiResponse<Map<String, Integer>> getInventoryWithHttpInfo() throws ApiException {
|
||||||
|
okhttp3.Call localVarCall = getInventoryValidateBeforeCall(null);
|
||||||
|
Type localVarReturnType = new TypeToken<Map<String, Integer>>(){}.getType();
|
||||||
|
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns pet inventories by status (asynchronously)
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
* @param _callback The callback to be executed when the API call finishes
|
||||||
|
* @return The request call
|
||||||
|
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
|
||||||
|
* @http.response.details
|
||||||
|
<table border="1">
|
||||||
|
<caption>Response Details</caption>
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 200 </td><td> successful operation </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public okhttp3.Call getInventoryAsync(final ApiCallback<Map<String, Integer>> _callback) throws ApiException {
|
||||||
|
|
||||||
|
okhttp3.Call localVarCall = getInventoryValidateBeforeCall(_callback);
|
||||||
|
Type localVarReturnType = new TypeToken<Map<String, Integer>>(){}.getType();
|
||||||
|
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
|
||||||
|
return localVarCall;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Build call for getOrderById
|
||||||
|
* @param orderId ID of pet that needs to be fetched (required)
|
||||||
|
* @param _callback Callback for upload/download progress
|
||||||
|
* @return Call to execute
|
||||||
|
* @throws ApiException If fail to serialize the request body object
|
||||||
|
* @http.response.details
|
||||||
|
<table border="1">
|
||||||
|
<caption>Response Details</caption>
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 200 </td><td> successful operation </td><td> - </td></tr>
|
||||||
|
<tr><td> 400 </td><td> Invalid ID supplied </td><td> - </td></tr>
|
||||||
|
<tr><td> 404 </td><td> Order not found </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public okhttp3.Call getOrderByIdCall(@javax.annotation.Nonnull Long orderId, final ApiCallback _callback) throws ApiException {
|
||||||
|
String basePath = null;
|
||||||
|
// Operation Servers
|
||||||
|
String[] localBasePaths = new String[] { };
|
||||||
|
|
||||||
|
// Determine Base Path to Use
|
||||||
|
if (localCustomBaseUrl != null){
|
||||||
|
basePath = localCustomBaseUrl;
|
||||||
|
} else if ( localBasePaths.length > 0 ) {
|
||||||
|
basePath = localBasePaths[localHostIndex];
|
||||||
|
} else {
|
||||||
|
basePath = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object localVarPostBody = null;
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String localVarPath = "/store/order/{orderId}"
|
||||||
|
.replace("{" + "orderId" + "}", localVarApiClient.escapeString(orderId.toString()));
|
||||||
|
|
||||||
|
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||||
|
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
|
||||||
|
Map<String, String> localVarCookieParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
final String[] localVarAccepts = {
|
||||||
|
"application/xml",
|
||||||
|
"application/json"
|
||||||
|
};
|
||||||
|
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
|
||||||
|
if (localVarAccept != null) {
|
||||||
|
localVarHeaderParams.put("Accept", localVarAccept);
|
||||||
|
}
|
||||||
|
|
||||||
|
final String[] localVarContentTypes = {
|
||||||
|
};
|
||||||
|
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
|
||||||
|
if (localVarContentType != null) {
|
||||||
|
localVarHeaderParams.put("Content-Type", localVarContentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] localVarAuthNames = new String[] { };
|
||||||
|
return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
private okhttp3.Call getOrderByIdValidateBeforeCall(@javax.annotation.Nonnull Long orderId, final ApiCallback _callback) throws ApiException {
|
||||||
|
// verify the required parameter 'orderId' is set
|
||||||
|
if (orderId == null) {
|
||||||
|
throw new ApiException("Missing the required parameter 'orderId' when calling getOrderById(Async)");
|
||||||
|
}
|
||||||
|
|
||||||
|
return getOrderByIdCall(orderId, _callback);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find purchase order by ID
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||||
|
* @param orderId ID of pet that needs to be fetched (required)
|
||||||
|
* @return Order
|
||||||
|
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||||
|
* @http.response.details
|
||||||
|
<table border="1">
|
||||||
|
<caption>Response Details</caption>
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 200 </td><td> successful operation </td><td> - </td></tr>
|
||||||
|
<tr><td> 400 </td><td> Invalid ID supplied </td><td> - </td></tr>
|
||||||
|
<tr><td> 404 </td><td> Order not found </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public Order getOrderById(@javax.annotation.Nonnull Long orderId) throws ApiException {
|
||||||
|
ApiResponse<Order> localVarResp = getOrderByIdWithHttpInfo(orderId);
|
||||||
|
return localVarResp.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find purchase order by ID
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||||
|
* @param orderId ID of pet that needs to be fetched (required)
|
||||||
|
* @return ApiResponse<Order>
|
||||||
|
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||||
|
* @http.response.details
|
||||||
|
<table border="1">
|
||||||
|
<caption>Response Details</caption>
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 200 </td><td> successful operation </td><td> - </td></tr>
|
||||||
|
<tr><td> 400 </td><td> Invalid ID supplied </td><td> - </td></tr>
|
||||||
|
<tr><td> 404 </td><td> Order not found </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public ApiResponse<Order> getOrderByIdWithHttpInfo(@javax.annotation.Nonnull Long orderId) throws ApiException {
|
||||||
|
okhttp3.Call localVarCall = getOrderByIdValidateBeforeCall(orderId, null);
|
||||||
|
Type localVarReturnType = new TypeToken<Order>(){}.getType();
|
||||||
|
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find purchase order by ID (asynchronously)
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||||
|
* @param orderId ID of pet that needs to be fetched (required)
|
||||||
|
* @param _callback The callback to be executed when the API call finishes
|
||||||
|
* @return The request call
|
||||||
|
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
|
||||||
|
* @http.response.details
|
||||||
|
<table border="1">
|
||||||
|
<caption>Response Details</caption>
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 200 </td><td> successful operation </td><td> - </td></tr>
|
||||||
|
<tr><td> 400 </td><td> Invalid ID supplied </td><td> - </td></tr>
|
||||||
|
<tr><td> 404 </td><td> Order not found </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public okhttp3.Call getOrderByIdAsync(@javax.annotation.Nonnull Long orderId, final ApiCallback<Order> _callback) throws ApiException {
|
||||||
|
|
||||||
|
okhttp3.Call localVarCall = getOrderByIdValidateBeforeCall(orderId, _callback);
|
||||||
|
Type localVarReturnType = new TypeToken<Order>(){}.getType();
|
||||||
|
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
|
||||||
|
return localVarCall;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Build call for placeOrder
|
||||||
|
* @param order order placed for purchasing the pet (required)
|
||||||
|
* @param _callback Callback for upload/download progress
|
||||||
|
* @return Call to execute
|
||||||
|
* @throws ApiException If fail to serialize the request body object
|
||||||
|
* @http.response.details
|
||||||
|
<table border="1">
|
||||||
|
<caption>Response Details</caption>
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 200 </td><td> successful operation </td><td> - </td></tr>
|
||||||
|
<tr><td> 400 </td><td> Invalid Order </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public okhttp3.Call placeOrderCall(@javax.annotation.Nonnull Order order, final ApiCallback _callback) throws ApiException {
|
||||||
|
String basePath = null;
|
||||||
|
// Operation Servers
|
||||||
|
String[] localBasePaths = new String[] { };
|
||||||
|
|
||||||
|
// Determine Base Path to Use
|
||||||
|
if (localCustomBaseUrl != null){
|
||||||
|
basePath = localCustomBaseUrl;
|
||||||
|
} else if ( localBasePaths.length > 0 ) {
|
||||||
|
basePath = localBasePaths[localHostIndex];
|
||||||
|
} else {
|
||||||
|
basePath = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object localVarPostBody = order;
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String localVarPath = "/store/order";
|
||||||
|
|
||||||
|
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||||
|
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
|
||||||
|
Map<String, String> localVarCookieParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
final String[] localVarAccepts = {
|
||||||
|
"application/xml",
|
||||||
|
"application/json"
|
||||||
|
};
|
||||||
|
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
|
||||||
|
if (localVarAccept != null) {
|
||||||
|
localVarHeaderParams.put("Accept", localVarAccept);
|
||||||
|
}
|
||||||
|
|
||||||
|
final String[] localVarContentTypes = {
|
||||||
|
"application/json"
|
||||||
|
};
|
||||||
|
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
|
||||||
|
if (localVarContentType != null) {
|
||||||
|
localVarHeaderParams.put("Content-Type", localVarContentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] localVarAuthNames = new String[] { };
|
||||||
|
return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
private okhttp3.Call placeOrderValidateBeforeCall(@javax.annotation.Nonnull Order order, final ApiCallback _callback) throws ApiException {
|
||||||
|
// verify the required parameter 'order' is set
|
||||||
|
if (order == null) {
|
||||||
|
throw new ApiException("Missing the required parameter 'order' when calling placeOrder(Async)");
|
||||||
|
}
|
||||||
|
|
||||||
|
return placeOrderCall(order, _callback);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place an order for a pet
|
||||||
|
*
|
||||||
|
* @param order order placed for purchasing the pet (required)
|
||||||
|
* @return Order
|
||||||
|
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||||
|
* @http.response.details
|
||||||
|
<table border="1">
|
||||||
|
<caption>Response Details</caption>
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 200 </td><td> successful operation </td><td> - </td></tr>
|
||||||
|
<tr><td> 400 </td><td> Invalid Order </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public Order placeOrder(@javax.annotation.Nonnull Order order) throws ApiException {
|
||||||
|
ApiResponse<Order> localVarResp = placeOrderWithHttpInfo(order);
|
||||||
|
return localVarResp.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place an order for a pet
|
||||||
|
*
|
||||||
|
* @param order order placed for purchasing the pet (required)
|
||||||
|
* @return ApiResponse<Order>
|
||||||
|
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||||
|
* @http.response.details
|
||||||
|
<table border="1">
|
||||||
|
<caption>Response Details</caption>
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 200 </td><td> successful operation </td><td> - </td></tr>
|
||||||
|
<tr><td> 400 </td><td> Invalid Order </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public ApiResponse<Order> placeOrderWithHttpInfo(@javax.annotation.Nonnull Order order) throws ApiException {
|
||||||
|
okhttp3.Call localVarCall = placeOrderValidateBeforeCall(order, null);
|
||||||
|
Type localVarReturnType = new TypeToken<Order>(){}.getType();
|
||||||
|
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place an order for a pet (asynchronously)
|
||||||
|
*
|
||||||
|
* @param order order placed for purchasing the pet (required)
|
||||||
|
* @param _callback The callback to be executed when the API call finishes
|
||||||
|
* @return The request call
|
||||||
|
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
|
||||||
|
* @http.response.details
|
||||||
|
<table border="1">
|
||||||
|
<caption>Response Details</caption>
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 200 </td><td> successful operation </td><td> - </td></tr>
|
||||||
|
<tr><td> 400 </td><td> Invalid Order </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public okhttp3.Call placeOrderAsync(@javax.annotation.Nonnull Order order, final ApiCallback<Order> _callback) throws ApiException {
|
||||||
|
|
||||||
|
okhttp3.Call localVarCall = placeOrderValidateBeforeCall(order, _callback);
|
||||||
|
Type localVarReturnType = new TypeToken<Order>(){}.getType();
|
||||||
|
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
|
||||||
|
return localVarCall;
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,314 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.openapitools.client.model;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Locale;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.annotations.JsonAdapter;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonDeserializationContext;
|
||||||
|
import com.google.gson.JsonDeserializer;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.google.gson.TypeAdapterFactory;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.openapitools.client.JSON;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A category for a pet
|
||||||
|
*/
|
||||||
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0-SNAPSHOT")
|
||||||
|
public class Category {
|
||||||
|
public static final String SERIALIZED_NAME_ID = "id";
|
||||||
|
@SerializedName(SERIALIZED_NAME_ID)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_NAME = "name";
|
||||||
|
@SerializedName(SERIALIZED_NAME_NAME)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public Category() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Category id(@javax.annotation.Nullable Long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id
|
||||||
|
* @return id
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(@javax.annotation.Nullable Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Category name(@javax.annotation.Nullable String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get name
|
||||||
|
* @return name
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(@javax.annotation.Nullable String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A container for additional, undeclared properties.
|
||||||
|
* This is a holder for any undeclared properties as specified with
|
||||||
|
* the 'additionalProperties' keyword in the OAS document.
|
||||||
|
*/
|
||||||
|
private Map<String, Object> additionalProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the additional (undeclared) property with the specified name and value.
|
||||||
|
* If the property does not already exist, create it otherwise replace it.
|
||||||
|
*
|
||||||
|
* @param key name of the property
|
||||||
|
* @param value value of the property
|
||||||
|
* @return the Category instance itself
|
||||||
|
*/
|
||||||
|
public Category putAdditionalProperty(String key, Object value) {
|
||||||
|
if (this.additionalProperties == null) {
|
||||||
|
this.additionalProperties = new HashMap<String, Object>();
|
||||||
|
}
|
||||||
|
this.additionalProperties.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the additional (undeclared) property.
|
||||||
|
*
|
||||||
|
* @return a map of objects
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getAdditionalProperties() {
|
||||||
|
return additionalProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the additional (undeclared) property with the specified name.
|
||||||
|
*
|
||||||
|
* @param key name of the property
|
||||||
|
* @return an object
|
||||||
|
*/
|
||||||
|
public Object getAdditionalProperty(String key) {
|
||||||
|
if (this.additionalProperties == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this.additionalProperties.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Category category = (Category) o;
|
||||||
|
return Objects.equals(this.id, category.id) &&
|
||||||
|
Objects.equals(this.name, category.name)&&
|
||||||
|
Objects.equals(this.additionalProperties, category.additionalProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, name, additionalProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class Category {\n");
|
||||||
|
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||||
|
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||||
|
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||||
|
sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given object to string with each line indented by 4 spaces
|
||||||
|
* (except the first line).
|
||||||
|
*/
|
||||||
|
private String toIndentedString(Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return o.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static HashSet<String> openapiFields;
|
||||||
|
public static HashSet<String> openapiRequiredFields;
|
||||||
|
|
||||||
|
static {
|
||||||
|
// a set of all properties/fields (JSON key names)
|
||||||
|
openapiFields = new HashSet<String>(Arrays.asList("id", "name"));
|
||||||
|
|
||||||
|
// a set of required properties/fields (JSON key names)
|
||||||
|
openapiRequiredFields = new HashSet<String>(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates the JSON Element and throws an exception if issues found
|
||||||
|
*
|
||||||
|
* @param jsonElement JSON Element
|
||||||
|
* @throws IOException if the JSON Element is invalid with respect to Category
|
||||||
|
*/
|
||||||
|
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||||
|
if (jsonElement == null) {
|
||||||
|
if (!Category.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Category is not found in the empty JSON string", Category.openapiRequiredFields.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||||
|
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||||
|
if (!Category.class.isAssignableFrom(type.getRawType())) {
|
||||||
|
return null; // this class only serializes 'Category' and its subtypes
|
||||||
|
}
|
||||||
|
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||||
|
final TypeAdapter<Category> thisAdapter
|
||||||
|
= gson.getDelegateAdapter(this, TypeToken.get(Category.class));
|
||||||
|
|
||||||
|
return (TypeAdapter<T>) new TypeAdapter<Category>() {
|
||||||
|
@Override
|
||||||
|
public void write(JsonWriter out, Category value) throws IOException {
|
||||||
|
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||||
|
obj.remove("additionalProperties");
|
||||||
|
// serialize additional properties
|
||||||
|
if (value.getAdditionalProperties() != null) {
|
||||||
|
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||||
|
if (entry.getValue() instanceof String)
|
||||||
|
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Number)
|
||||||
|
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Boolean)
|
||||||
|
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Character)
|
||||||
|
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||||
|
else {
|
||||||
|
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
|
||||||
|
if (jsonElement.isJsonArray()) {
|
||||||
|
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
|
||||||
|
} else {
|
||||||
|
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elementAdapter.write(out, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Category read(JsonReader in) throws IOException {
|
||||||
|
JsonElement jsonElement = elementAdapter.read(in);
|
||||||
|
validateJsonElement(jsonElement);
|
||||||
|
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||||
|
// store additional fields in the deserialized instance
|
||||||
|
Category instance = thisAdapter.fromJsonTree(jsonObj);
|
||||||
|
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||||
|
if (!openapiFields.contains(entry.getKey())) {
|
||||||
|
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||||
|
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||||
|
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||||
|
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||||
|
else
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||||
|
} else if (entry.getValue().isJsonArray()) {
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||||
|
} else { // JSON object
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
}.nullSafe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of Category given an JSON string
|
||||||
|
*
|
||||||
|
* @param jsonString JSON string
|
||||||
|
* @return An instance of Category
|
||||||
|
* @throws IOException if the JSON string is invalid with respect to Category
|
||||||
|
*/
|
||||||
|
public static Category fromJson(String jsonString) throws IOException {
|
||||||
|
return JSON.getGson().fromJson(jsonString, Category.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an instance of Category to an JSON string
|
||||||
|
*
|
||||||
|
* @return JSON string
|
||||||
|
*/
|
||||||
|
public String toJson() {
|
||||||
|
return JSON.getGson().toJson(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,343 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.openapitools.client.model;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Locale;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.annotations.JsonAdapter;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonDeserializationContext;
|
||||||
|
import com.google.gson.JsonDeserializer;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.google.gson.TypeAdapterFactory;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.openapitools.client.JSON;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes the result of uploading an image resource
|
||||||
|
*/
|
||||||
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0-SNAPSHOT")
|
||||||
|
public class ModelApiResponse {
|
||||||
|
public static final String SERIALIZED_NAME_CODE = "code";
|
||||||
|
@SerializedName(SERIALIZED_NAME_CODE)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_TYPE = "type";
|
||||||
|
@SerializedName(SERIALIZED_NAME_TYPE)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_MESSAGE = "message";
|
||||||
|
@SerializedName(SERIALIZED_NAME_MESSAGE)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public ModelApiResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModelApiResponse code(@javax.annotation.Nullable Integer code) {
|
||||||
|
this.code = code;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get code
|
||||||
|
* @return code
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public Integer getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(@javax.annotation.Nullable Integer code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ModelApiResponse type(@javax.annotation.Nullable String type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get type
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(@javax.annotation.Nullable String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ModelApiResponse message(@javax.annotation.Nullable String message) {
|
||||||
|
this.message = message;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get message
|
||||||
|
* @return message
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(@javax.annotation.Nullable String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A container for additional, undeclared properties.
|
||||||
|
* This is a holder for any undeclared properties as specified with
|
||||||
|
* the 'additionalProperties' keyword in the OAS document.
|
||||||
|
*/
|
||||||
|
private Map<String, Object> additionalProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the additional (undeclared) property with the specified name and value.
|
||||||
|
* If the property does not already exist, create it otherwise replace it.
|
||||||
|
*
|
||||||
|
* @param key name of the property
|
||||||
|
* @param value value of the property
|
||||||
|
* @return the ModelApiResponse instance itself
|
||||||
|
*/
|
||||||
|
public ModelApiResponse putAdditionalProperty(String key, Object value) {
|
||||||
|
if (this.additionalProperties == null) {
|
||||||
|
this.additionalProperties = new HashMap<String, Object>();
|
||||||
|
}
|
||||||
|
this.additionalProperties.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the additional (undeclared) property.
|
||||||
|
*
|
||||||
|
* @return a map of objects
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getAdditionalProperties() {
|
||||||
|
return additionalProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the additional (undeclared) property with the specified name.
|
||||||
|
*
|
||||||
|
* @param key name of the property
|
||||||
|
* @return an object
|
||||||
|
*/
|
||||||
|
public Object getAdditionalProperty(String key) {
|
||||||
|
if (this.additionalProperties == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this.additionalProperties.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ModelApiResponse _apiResponse = (ModelApiResponse) o;
|
||||||
|
return Objects.equals(this.code, _apiResponse.code) &&
|
||||||
|
Objects.equals(this.type, _apiResponse.type) &&
|
||||||
|
Objects.equals(this.message, _apiResponse.message)&&
|
||||||
|
Objects.equals(this.additionalProperties, _apiResponse.additionalProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(code, type, message, additionalProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class ModelApiResponse {\n");
|
||||||
|
sb.append(" code: ").append(toIndentedString(code)).append("\n");
|
||||||
|
sb.append(" type: ").append(toIndentedString(type)).append("\n");
|
||||||
|
sb.append(" message: ").append(toIndentedString(message)).append("\n");
|
||||||
|
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||||
|
sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given object to string with each line indented by 4 spaces
|
||||||
|
* (except the first line).
|
||||||
|
*/
|
||||||
|
private String toIndentedString(Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return o.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static HashSet<String> openapiFields;
|
||||||
|
public static HashSet<String> openapiRequiredFields;
|
||||||
|
|
||||||
|
static {
|
||||||
|
// a set of all properties/fields (JSON key names)
|
||||||
|
openapiFields = new HashSet<String>(Arrays.asList("code", "type", "message"));
|
||||||
|
|
||||||
|
// a set of required properties/fields (JSON key names)
|
||||||
|
openapiRequiredFields = new HashSet<String>(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates the JSON Element and throws an exception if issues found
|
||||||
|
*
|
||||||
|
* @param jsonElement JSON Element
|
||||||
|
* @throws IOException if the JSON Element is invalid with respect to ModelApiResponse
|
||||||
|
*/
|
||||||
|
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||||
|
if (jsonElement == null) {
|
||||||
|
if (!ModelApiResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ModelApiResponse is not found in the empty JSON string", ModelApiResponse.openapiRequiredFields.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||||
|
if ((jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) && !jsonObj.get("type").isJsonPrimitive()) {
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString()));
|
||||||
|
}
|
||||||
|
if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) {
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||||
|
if (!ModelApiResponse.class.isAssignableFrom(type.getRawType())) {
|
||||||
|
return null; // this class only serializes 'ModelApiResponse' and its subtypes
|
||||||
|
}
|
||||||
|
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||||
|
final TypeAdapter<ModelApiResponse> thisAdapter
|
||||||
|
= gson.getDelegateAdapter(this, TypeToken.get(ModelApiResponse.class));
|
||||||
|
|
||||||
|
return (TypeAdapter<T>) new TypeAdapter<ModelApiResponse>() {
|
||||||
|
@Override
|
||||||
|
public void write(JsonWriter out, ModelApiResponse value) throws IOException {
|
||||||
|
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||||
|
obj.remove("additionalProperties");
|
||||||
|
// serialize additional properties
|
||||||
|
if (value.getAdditionalProperties() != null) {
|
||||||
|
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||||
|
if (entry.getValue() instanceof String)
|
||||||
|
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Number)
|
||||||
|
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Boolean)
|
||||||
|
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Character)
|
||||||
|
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||||
|
else {
|
||||||
|
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
|
||||||
|
if (jsonElement.isJsonArray()) {
|
||||||
|
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
|
||||||
|
} else {
|
||||||
|
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elementAdapter.write(out, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ModelApiResponse read(JsonReader in) throws IOException {
|
||||||
|
JsonElement jsonElement = elementAdapter.read(in);
|
||||||
|
validateJsonElement(jsonElement);
|
||||||
|
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||||
|
// store additional fields in the deserialized instance
|
||||||
|
ModelApiResponse instance = thisAdapter.fromJsonTree(jsonObj);
|
||||||
|
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||||
|
if (!openapiFields.contains(entry.getKey())) {
|
||||||
|
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||||
|
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||||
|
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||||
|
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||||
|
else
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||||
|
} else if (entry.getValue().isJsonArray()) {
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||||
|
} else { // JSON object
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
}.nullSafe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of ModelApiResponse given an JSON string
|
||||||
|
*
|
||||||
|
* @param jsonString JSON string
|
||||||
|
* @return An instance of ModelApiResponse
|
||||||
|
* @throws IOException if the JSON string is invalid with respect to ModelApiResponse
|
||||||
|
*/
|
||||||
|
public static ModelApiResponse fromJson(String jsonString) throws IOException {
|
||||||
|
return JSON.getGson().fromJson(jsonString, ModelApiResponse.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an instance of ModelApiResponse to an JSON string
|
||||||
|
*
|
||||||
|
* @return JSON string
|
||||||
|
*/
|
||||||
|
public String toJson() {
|
||||||
|
return JSON.getGson().toJson(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,477 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.openapitools.client.model;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Locale;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.annotations.JsonAdapter;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonDeserializationContext;
|
||||||
|
import com.google.gson.JsonDeserializer;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.google.gson.TypeAdapterFactory;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.openapitools.client.JSON;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An order for a pets from the pet store
|
||||||
|
*/
|
||||||
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0-SNAPSHOT")
|
||||||
|
public class Order {
|
||||||
|
public static final String SERIALIZED_NAME_ID = "id";
|
||||||
|
@SerializedName(SERIALIZED_NAME_ID)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_PET_ID = "petId";
|
||||||
|
@SerializedName(SERIALIZED_NAME_PET_ID)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private Long petId;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_QUANTITY = "quantity";
|
||||||
|
@SerializedName(SERIALIZED_NAME_QUANTITY)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private Integer quantity;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_SHIP_DATE = "shipDate";
|
||||||
|
@SerializedName(SERIALIZED_NAME_SHIP_DATE)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private OffsetDateTime shipDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order Status
|
||||||
|
*/
|
||||||
|
@JsonAdapter(StatusEnum.Adapter.class)
|
||||||
|
public enum StatusEnum {
|
||||||
|
PLACED("placed"),
|
||||||
|
|
||||||
|
APPROVED("approved"),
|
||||||
|
|
||||||
|
DELIVERED("delivered");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
StatusEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.valueOf(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StatusEnum fromValue(String value) {
|
||||||
|
for (StatusEnum b : StatusEnum.values()) {
|
||||||
|
if (b.value.equals(value)) {
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Adapter extends TypeAdapter<StatusEnum> {
|
||||||
|
@Override
|
||||||
|
public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException {
|
||||||
|
jsonWriter.value(enumeration.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StatusEnum read(final JsonReader jsonReader) throws IOException {
|
||||||
|
String value = jsonReader.nextString();
|
||||||
|
return StatusEnum.fromValue(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||||
|
String value = jsonElement.getAsString();
|
||||||
|
StatusEnum.fromValue(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_STATUS = "status";
|
||||||
|
@SerializedName(SERIALIZED_NAME_STATUS)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private StatusEnum status;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_COMPLETE = "complete";
|
||||||
|
@SerializedName(SERIALIZED_NAME_COMPLETE)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private Boolean complete = false;
|
||||||
|
|
||||||
|
public Order() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Order id(@javax.annotation.Nullable Long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id
|
||||||
|
* @return id
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(@javax.annotation.Nullable Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Order petId(@javax.annotation.Nullable Long petId) {
|
||||||
|
this.petId = petId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get petId
|
||||||
|
* @return petId
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public Long getPetId() {
|
||||||
|
return petId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPetId(@javax.annotation.Nullable Long petId) {
|
||||||
|
this.petId = petId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Order quantity(@javax.annotation.Nullable Integer quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get quantity
|
||||||
|
* @return quantity
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public Integer getQuantity() {
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantity(@javax.annotation.Nullable Integer quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Order shipDate(@javax.annotation.Nullable OffsetDateTime shipDate) {
|
||||||
|
this.shipDate = shipDate;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get shipDate
|
||||||
|
* @return shipDate
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public OffsetDateTime getShipDate() {
|
||||||
|
return shipDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShipDate(@javax.annotation.Nullable OffsetDateTime shipDate) {
|
||||||
|
this.shipDate = shipDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Order status(@javax.annotation.Nullable StatusEnum status) {
|
||||||
|
this.status = status;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order Status
|
||||||
|
* @return status
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public StatusEnum getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(@javax.annotation.Nullable StatusEnum status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Order complete(@javax.annotation.Nullable Boolean complete) {
|
||||||
|
this.complete = complete;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get complete
|
||||||
|
* @return complete
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public Boolean getComplete() {
|
||||||
|
return complete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComplete(@javax.annotation.Nullable Boolean complete) {
|
||||||
|
this.complete = complete;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A container for additional, undeclared properties.
|
||||||
|
* This is a holder for any undeclared properties as specified with
|
||||||
|
* the 'additionalProperties' keyword in the OAS document.
|
||||||
|
*/
|
||||||
|
private Map<String, Object> additionalProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the additional (undeclared) property with the specified name and value.
|
||||||
|
* If the property does not already exist, create it otherwise replace it.
|
||||||
|
*
|
||||||
|
* @param key name of the property
|
||||||
|
* @param value value of the property
|
||||||
|
* @return the Order instance itself
|
||||||
|
*/
|
||||||
|
public Order putAdditionalProperty(String key, Object value) {
|
||||||
|
if (this.additionalProperties == null) {
|
||||||
|
this.additionalProperties = new HashMap<String, Object>();
|
||||||
|
}
|
||||||
|
this.additionalProperties.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the additional (undeclared) property.
|
||||||
|
*
|
||||||
|
* @return a map of objects
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getAdditionalProperties() {
|
||||||
|
return additionalProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the additional (undeclared) property with the specified name.
|
||||||
|
*
|
||||||
|
* @param key name of the property
|
||||||
|
* @return an object
|
||||||
|
*/
|
||||||
|
public Object getAdditionalProperty(String key) {
|
||||||
|
if (this.additionalProperties == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this.additionalProperties.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Order order = (Order) o;
|
||||||
|
return Objects.equals(this.id, order.id) &&
|
||||||
|
Objects.equals(this.petId, order.petId) &&
|
||||||
|
Objects.equals(this.quantity, order.quantity) &&
|
||||||
|
Objects.equals(this.shipDate, order.shipDate) &&
|
||||||
|
Objects.equals(this.status, order.status) &&
|
||||||
|
Objects.equals(this.complete, order.complete)&&
|
||||||
|
Objects.equals(this.additionalProperties, order.additionalProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, petId, quantity, shipDate, status, complete, additionalProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class Order {\n");
|
||||||
|
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||||
|
sb.append(" petId: ").append(toIndentedString(petId)).append("\n");
|
||||||
|
sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n");
|
||||||
|
sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n");
|
||||||
|
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||||
|
sb.append(" complete: ").append(toIndentedString(complete)).append("\n");
|
||||||
|
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||||
|
sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given object to string with each line indented by 4 spaces
|
||||||
|
* (except the first line).
|
||||||
|
*/
|
||||||
|
private String toIndentedString(Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return o.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static HashSet<String> openapiFields;
|
||||||
|
public static HashSet<String> openapiRequiredFields;
|
||||||
|
|
||||||
|
static {
|
||||||
|
// a set of all properties/fields (JSON key names)
|
||||||
|
openapiFields = new HashSet<String>(Arrays.asList("id", "petId", "quantity", "shipDate", "status", "complete"));
|
||||||
|
|
||||||
|
// a set of required properties/fields (JSON key names)
|
||||||
|
openapiRequiredFields = new HashSet<String>(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates the JSON Element and throws an exception if issues found
|
||||||
|
*
|
||||||
|
* @param jsonElement JSON Element
|
||||||
|
* @throws IOException if the JSON Element is invalid with respect to Order
|
||||||
|
*/
|
||||||
|
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||||
|
if (jsonElement == null) {
|
||||||
|
if (!Order.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Order is not found in the empty JSON string", Order.openapiRequiredFields.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||||
|
if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) {
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString()));
|
||||||
|
}
|
||||||
|
// validate the optional field `status`
|
||||||
|
if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) {
|
||||||
|
StatusEnum.validateJsonElement(jsonObj.get("status"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||||
|
if (!Order.class.isAssignableFrom(type.getRawType())) {
|
||||||
|
return null; // this class only serializes 'Order' and its subtypes
|
||||||
|
}
|
||||||
|
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||||
|
final TypeAdapter<Order> thisAdapter
|
||||||
|
= gson.getDelegateAdapter(this, TypeToken.get(Order.class));
|
||||||
|
|
||||||
|
return (TypeAdapter<T>) new TypeAdapter<Order>() {
|
||||||
|
@Override
|
||||||
|
public void write(JsonWriter out, Order value) throws IOException {
|
||||||
|
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||||
|
obj.remove("additionalProperties");
|
||||||
|
// serialize additional properties
|
||||||
|
if (value.getAdditionalProperties() != null) {
|
||||||
|
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||||
|
if (entry.getValue() instanceof String)
|
||||||
|
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Number)
|
||||||
|
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Boolean)
|
||||||
|
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Character)
|
||||||
|
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||||
|
else {
|
||||||
|
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
|
||||||
|
if (jsonElement.isJsonArray()) {
|
||||||
|
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
|
||||||
|
} else {
|
||||||
|
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elementAdapter.write(out, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Order read(JsonReader in) throws IOException {
|
||||||
|
JsonElement jsonElement = elementAdapter.read(in);
|
||||||
|
validateJsonElement(jsonElement);
|
||||||
|
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||||
|
// store additional fields in the deserialized instance
|
||||||
|
Order instance = thisAdapter.fromJsonTree(jsonObj);
|
||||||
|
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||||
|
if (!openapiFields.contains(entry.getKey())) {
|
||||||
|
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||||
|
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||||
|
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||||
|
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||||
|
else
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||||
|
} else if (entry.getValue().isJsonArray()) {
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||||
|
} else { // JSON object
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
}.nullSafe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of Order given an JSON string
|
||||||
|
*
|
||||||
|
* @param jsonString JSON string
|
||||||
|
* @return An instance of Order
|
||||||
|
* @throws IOException if the JSON string is invalid with respect to Order
|
||||||
|
*/
|
||||||
|
public static Order fromJson(String jsonString) throws IOException {
|
||||||
|
return JSON.getGson().fromJson(jsonString, Order.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an instance of Order to an JSON string
|
||||||
|
*
|
||||||
|
* @return JSON string
|
||||||
|
*/
|
||||||
|
public String toJson() {
|
||||||
|
return JSON.getGson().toJson(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,535 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.openapitools.client.model;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Locale;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.annotations.JsonAdapter;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import org.openapitools.client.model.Category;
|
||||||
|
import org.openapitools.client.model.Tag;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonDeserializationContext;
|
||||||
|
import com.google.gson.JsonDeserializer;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.google.gson.TypeAdapterFactory;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.openapitools.client.JSON;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A pet for sale in the pet store
|
||||||
|
*/
|
||||||
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0-SNAPSHOT")
|
||||||
|
public class Pet {
|
||||||
|
public static final String SERIALIZED_NAME_ID = "id";
|
||||||
|
@SerializedName(SERIALIZED_NAME_ID)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_CATEGORY = "category";
|
||||||
|
@SerializedName(SERIALIZED_NAME_CATEGORY)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private Category category;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_NAME = "name";
|
||||||
|
@SerializedName(SERIALIZED_NAME_NAME)
|
||||||
|
@javax.annotation.Nonnull
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_PHOTO_URLS = "photoUrls";
|
||||||
|
@SerializedName(SERIALIZED_NAME_PHOTO_URLS)
|
||||||
|
@javax.annotation.Nonnull
|
||||||
|
private List<String> photoUrls = new ArrayList<>();
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_TAGS = "tags";
|
||||||
|
@SerializedName(SERIALIZED_NAME_TAGS)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private List<Tag> tags = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pet status in the store
|
||||||
|
*/
|
||||||
|
@JsonAdapter(StatusEnum.Adapter.class)
|
||||||
|
public enum StatusEnum {
|
||||||
|
AVAILABLE("available"),
|
||||||
|
|
||||||
|
PENDING("pending"),
|
||||||
|
|
||||||
|
SOLD("sold");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
StatusEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.valueOf(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StatusEnum fromValue(String value) {
|
||||||
|
for (StatusEnum b : StatusEnum.values()) {
|
||||||
|
if (b.value.equals(value)) {
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Adapter extends TypeAdapter<StatusEnum> {
|
||||||
|
@Override
|
||||||
|
public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException {
|
||||||
|
jsonWriter.value(enumeration.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StatusEnum read(final JsonReader jsonReader) throws IOException {
|
||||||
|
String value = jsonReader.nextString();
|
||||||
|
return StatusEnum.fromValue(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||||
|
String value = jsonElement.getAsString();
|
||||||
|
StatusEnum.fromValue(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_STATUS = "status";
|
||||||
|
@Deprecated
|
||||||
|
@SerializedName(SERIALIZED_NAME_STATUS)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private StatusEnum status;
|
||||||
|
|
||||||
|
public Pet() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pet id(@javax.annotation.Nullable Long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id
|
||||||
|
* @return id
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(@javax.annotation.Nullable Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Pet category(@javax.annotation.Nullable Category category) {
|
||||||
|
this.category = category;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get category
|
||||||
|
* @return category
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public Category getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategory(@javax.annotation.Nullable Category category) {
|
||||||
|
this.category = category;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Pet name(@javax.annotation.Nonnull String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get name
|
||||||
|
* @return name
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nonnull
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(@javax.annotation.Nonnull String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Pet photoUrls(@javax.annotation.Nonnull List<String> photoUrls) {
|
||||||
|
this.photoUrls = photoUrls;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pet addPhotoUrlsItem(String photoUrlsItem) {
|
||||||
|
if (this.photoUrls == null) {
|
||||||
|
this.photoUrls = new ArrayList<>();
|
||||||
|
}
|
||||||
|
this.photoUrls.add(photoUrlsItem);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get photoUrls
|
||||||
|
* @return photoUrls
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nonnull
|
||||||
|
public List<String> getPhotoUrls() {
|
||||||
|
return photoUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhotoUrls(@javax.annotation.Nonnull List<String> photoUrls) {
|
||||||
|
this.photoUrls = photoUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Pet tags(@javax.annotation.Nullable List<Tag> tags) {
|
||||||
|
this.tags = tags;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pet addTagsItem(Tag tagsItem) {
|
||||||
|
if (this.tags == null) {
|
||||||
|
this.tags = new ArrayList<>();
|
||||||
|
}
|
||||||
|
this.tags.add(tagsItem);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get tags
|
||||||
|
* @return tags
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public List<Tag> getTags() {
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTags(@javax.annotation.Nullable List<Tag> tags) {
|
||||||
|
this.tags = tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public Pet status(@javax.annotation.Nullable StatusEnum status) {
|
||||||
|
this.status = status;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pet status in the store
|
||||||
|
* @return status
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public StatusEnum getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void setStatus(@javax.annotation.Nullable StatusEnum status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A container for additional, undeclared properties.
|
||||||
|
* This is a holder for any undeclared properties as specified with
|
||||||
|
* the 'additionalProperties' keyword in the OAS document.
|
||||||
|
*/
|
||||||
|
private Map<String, Object> additionalProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the additional (undeclared) property with the specified name and value.
|
||||||
|
* If the property does not already exist, create it otherwise replace it.
|
||||||
|
*
|
||||||
|
* @param key name of the property
|
||||||
|
* @param value value of the property
|
||||||
|
* @return the Pet instance itself
|
||||||
|
*/
|
||||||
|
public Pet putAdditionalProperty(String key, Object value) {
|
||||||
|
if (this.additionalProperties == null) {
|
||||||
|
this.additionalProperties = new HashMap<String, Object>();
|
||||||
|
}
|
||||||
|
this.additionalProperties.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the additional (undeclared) property.
|
||||||
|
*
|
||||||
|
* @return a map of objects
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getAdditionalProperties() {
|
||||||
|
return additionalProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the additional (undeclared) property with the specified name.
|
||||||
|
*
|
||||||
|
* @param key name of the property
|
||||||
|
* @return an object
|
||||||
|
*/
|
||||||
|
public Object getAdditionalProperty(String key) {
|
||||||
|
if (this.additionalProperties == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this.additionalProperties.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Pet pet = (Pet) o;
|
||||||
|
return Objects.equals(this.id, pet.id) &&
|
||||||
|
Objects.equals(this.category, pet.category) &&
|
||||||
|
Objects.equals(this.name, pet.name) &&
|
||||||
|
Objects.equals(this.photoUrls, pet.photoUrls) &&
|
||||||
|
Objects.equals(this.tags, pet.tags) &&
|
||||||
|
Objects.equals(this.status, pet.status)&&
|
||||||
|
Objects.equals(this.additionalProperties, pet.additionalProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, category, name, photoUrls, tags, status, additionalProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class Pet {\n");
|
||||||
|
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||||
|
sb.append(" category: ").append(toIndentedString(category)).append("\n");
|
||||||
|
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||||
|
sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n");
|
||||||
|
sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
|
||||||
|
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||||
|
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||||
|
sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given object to string with each line indented by 4 spaces
|
||||||
|
* (except the first line).
|
||||||
|
*/
|
||||||
|
private String toIndentedString(Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return o.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static HashSet<String> openapiFields;
|
||||||
|
public static HashSet<String> openapiRequiredFields;
|
||||||
|
|
||||||
|
static {
|
||||||
|
// a set of all properties/fields (JSON key names)
|
||||||
|
openapiFields = new HashSet<String>(Arrays.asList("id", "category", "name", "photoUrls", "tags", "status"));
|
||||||
|
|
||||||
|
// a set of required properties/fields (JSON key names)
|
||||||
|
openapiRequiredFields = new HashSet<String>(Arrays.asList("name", "photoUrls"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates the JSON Element and throws an exception if issues found
|
||||||
|
*
|
||||||
|
* @param jsonElement JSON Element
|
||||||
|
* @throws IOException if the JSON Element is invalid with respect to Pet
|
||||||
|
*/
|
||||||
|
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||||
|
if (jsonElement == null) {
|
||||||
|
if (!Pet.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Pet is not found in the empty JSON string", Pet.openapiRequiredFields.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check to make sure all required properties/fields are present in the JSON string
|
||||||
|
for (String requiredField : Pet.openapiRequiredFields) {
|
||||||
|
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||||
|
// validate the optional field `category`
|
||||||
|
if (jsonObj.get("category") != null && !jsonObj.get("category").isJsonNull()) {
|
||||||
|
Category.validateJsonElement(jsonObj.get("category"));
|
||||||
|
}
|
||||||
|
if (!jsonObj.get("name").isJsonPrimitive()) {
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
|
||||||
|
}
|
||||||
|
// ensure the required json array is present
|
||||||
|
if (jsonObj.get("photoUrls") == null) {
|
||||||
|
throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`");
|
||||||
|
} else if (!jsonObj.get("photoUrls").isJsonArray()) {
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `photoUrls` to be an array in the JSON string but got `%s`", jsonObj.get("photoUrls").toString()));
|
||||||
|
}
|
||||||
|
if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonNull()) {
|
||||||
|
JsonArray jsonArraytags = jsonObj.getAsJsonArray("tags");
|
||||||
|
if (jsonArraytags != null) {
|
||||||
|
// ensure the json data is an array
|
||||||
|
if (!jsonObj.get("tags").isJsonArray()) {
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate the optional field `tags` (array)
|
||||||
|
for (int i = 0; i < jsonArraytags.size(); i++) {
|
||||||
|
Tag.validateJsonElement(jsonArraytags.get(i));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) {
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString()));
|
||||||
|
}
|
||||||
|
// validate the optional field `status`
|
||||||
|
if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) {
|
||||||
|
StatusEnum.validateJsonElement(jsonObj.get("status"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||||
|
if (!Pet.class.isAssignableFrom(type.getRawType())) {
|
||||||
|
return null; // this class only serializes 'Pet' and its subtypes
|
||||||
|
}
|
||||||
|
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||||
|
final TypeAdapter<Pet> thisAdapter
|
||||||
|
= gson.getDelegateAdapter(this, TypeToken.get(Pet.class));
|
||||||
|
|
||||||
|
return (TypeAdapter<T>) new TypeAdapter<Pet>() {
|
||||||
|
@Override
|
||||||
|
public void write(JsonWriter out, Pet value) throws IOException {
|
||||||
|
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||||
|
obj.remove("additionalProperties");
|
||||||
|
// serialize additional properties
|
||||||
|
if (value.getAdditionalProperties() != null) {
|
||||||
|
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||||
|
if (entry.getValue() instanceof String)
|
||||||
|
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Number)
|
||||||
|
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Boolean)
|
||||||
|
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Character)
|
||||||
|
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||||
|
else {
|
||||||
|
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
|
||||||
|
if (jsonElement.isJsonArray()) {
|
||||||
|
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
|
||||||
|
} else {
|
||||||
|
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elementAdapter.write(out, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pet read(JsonReader in) throws IOException {
|
||||||
|
JsonElement jsonElement = elementAdapter.read(in);
|
||||||
|
validateJsonElement(jsonElement);
|
||||||
|
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||||
|
// store additional fields in the deserialized instance
|
||||||
|
Pet instance = thisAdapter.fromJsonTree(jsonObj);
|
||||||
|
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||||
|
if (!openapiFields.contains(entry.getKey())) {
|
||||||
|
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||||
|
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||||
|
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||||
|
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||||
|
else
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||||
|
} else if (entry.getValue().isJsonArray()) {
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||||
|
} else { // JSON object
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
}.nullSafe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of Pet given an JSON string
|
||||||
|
*
|
||||||
|
* @param jsonString JSON string
|
||||||
|
* @return An instance of Pet
|
||||||
|
* @throws IOException if the JSON string is invalid with respect to Pet
|
||||||
|
*/
|
||||||
|
public static Pet fromJson(String jsonString) throws IOException {
|
||||||
|
return JSON.getGson().fromJson(jsonString, Pet.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an instance of Pet to an JSON string
|
||||||
|
*
|
||||||
|
* @return JSON string
|
||||||
|
*/
|
||||||
|
public String toJson() {
|
||||||
|
return JSON.getGson().toJson(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,314 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.openapitools.client.model;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Locale;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.annotations.JsonAdapter;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonDeserializationContext;
|
||||||
|
import com.google.gson.JsonDeserializer;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.google.gson.TypeAdapterFactory;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.openapitools.client.JSON;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A tag for a pet
|
||||||
|
*/
|
||||||
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0-SNAPSHOT")
|
||||||
|
public class Tag {
|
||||||
|
public static final String SERIALIZED_NAME_ID = "id";
|
||||||
|
@SerializedName(SERIALIZED_NAME_ID)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_NAME = "name";
|
||||||
|
@SerializedName(SERIALIZED_NAME_NAME)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public Tag() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tag id(@javax.annotation.Nullable Long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id
|
||||||
|
* @return id
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(@javax.annotation.Nullable Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Tag name(@javax.annotation.Nullable String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get name
|
||||||
|
* @return name
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(@javax.annotation.Nullable String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A container for additional, undeclared properties.
|
||||||
|
* This is a holder for any undeclared properties as specified with
|
||||||
|
* the 'additionalProperties' keyword in the OAS document.
|
||||||
|
*/
|
||||||
|
private Map<String, Object> additionalProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the additional (undeclared) property with the specified name and value.
|
||||||
|
* If the property does not already exist, create it otherwise replace it.
|
||||||
|
*
|
||||||
|
* @param key name of the property
|
||||||
|
* @param value value of the property
|
||||||
|
* @return the Tag instance itself
|
||||||
|
*/
|
||||||
|
public Tag putAdditionalProperty(String key, Object value) {
|
||||||
|
if (this.additionalProperties == null) {
|
||||||
|
this.additionalProperties = new HashMap<String, Object>();
|
||||||
|
}
|
||||||
|
this.additionalProperties.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the additional (undeclared) property.
|
||||||
|
*
|
||||||
|
* @return a map of objects
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getAdditionalProperties() {
|
||||||
|
return additionalProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the additional (undeclared) property with the specified name.
|
||||||
|
*
|
||||||
|
* @param key name of the property
|
||||||
|
* @return an object
|
||||||
|
*/
|
||||||
|
public Object getAdditionalProperty(String key) {
|
||||||
|
if (this.additionalProperties == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this.additionalProperties.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Tag tag = (Tag) o;
|
||||||
|
return Objects.equals(this.id, tag.id) &&
|
||||||
|
Objects.equals(this.name, tag.name)&&
|
||||||
|
Objects.equals(this.additionalProperties, tag.additionalProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, name, additionalProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class Tag {\n");
|
||||||
|
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||||
|
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||||
|
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||||
|
sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given object to string with each line indented by 4 spaces
|
||||||
|
* (except the first line).
|
||||||
|
*/
|
||||||
|
private String toIndentedString(Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return o.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static HashSet<String> openapiFields;
|
||||||
|
public static HashSet<String> openapiRequiredFields;
|
||||||
|
|
||||||
|
static {
|
||||||
|
// a set of all properties/fields (JSON key names)
|
||||||
|
openapiFields = new HashSet<String>(Arrays.asList("id", "name"));
|
||||||
|
|
||||||
|
// a set of required properties/fields (JSON key names)
|
||||||
|
openapiRequiredFields = new HashSet<String>(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates the JSON Element and throws an exception if issues found
|
||||||
|
*
|
||||||
|
* @param jsonElement JSON Element
|
||||||
|
* @throws IOException if the JSON Element is invalid with respect to Tag
|
||||||
|
*/
|
||||||
|
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||||
|
if (jsonElement == null) {
|
||||||
|
if (!Tag.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Tag is not found in the empty JSON string", Tag.openapiRequiredFields.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||||
|
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||||
|
if (!Tag.class.isAssignableFrom(type.getRawType())) {
|
||||||
|
return null; // this class only serializes 'Tag' and its subtypes
|
||||||
|
}
|
||||||
|
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||||
|
final TypeAdapter<Tag> thisAdapter
|
||||||
|
= gson.getDelegateAdapter(this, TypeToken.get(Tag.class));
|
||||||
|
|
||||||
|
return (TypeAdapter<T>) new TypeAdapter<Tag>() {
|
||||||
|
@Override
|
||||||
|
public void write(JsonWriter out, Tag value) throws IOException {
|
||||||
|
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||||
|
obj.remove("additionalProperties");
|
||||||
|
// serialize additional properties
|
||||||
|
if (value.getAdditionalProperties() != null) {
|
||||||
|
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||||
|
if (entry.getValue() instanceof String)
|
||||||
|
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Number)
|
||||||
|
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Boolean)
|
||||||
|
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Character)
|
||||||
|
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||||
|
else {
|
||||||
|
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
|
||||||
|
if (jsonElement.isJsonArray()) {
|
||||||
|
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
|
||||||
|
} else {
|
||||||
|
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elementAdapter.write(out, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Tag read(JsonReader in) throws IOException {
|
||||||
|
JsonElement jsonElement = elementAdapter.read(in);
|
||||||
|
validateJsonElement(jsonElement);
|
||||||
|
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||||
|
// store additional fields in the deserialized instance
|
||||||
|
Tag instance = thisAdapter.fromJsonTree(jsonObj);
|
||||||
|
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||||
|
if (!openapiFields.contains(entry.getKey())) {
|
||||||
|
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||||
|
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||||
|
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||||
|
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||||
|
else
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||||
|
} else if (entry.getValue().isJsonArray()) {
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||||
|
} else { // JSON object
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
}.nullSafe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of Tag given an JSON string
|
||||||
|
*
|
||||||
|
* @param jsonString JSON string
|
||||||
|
* @return An instance of Tag
|
||||||
|
* @throws IOException if the JSON string is invalid with respect to Tag
|
||||||
|
*/
|
||||||
|
public static Tag fromJson(String jsonString) throws IOException {
|
||||||
|
return JSON.getGson().fromJson(jsonString, Tag.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an instance of Tag to an JSON string
|
||||||
|
*
|
||||||
|
* @return JSON string
|
||||||
|
*/
|
||||||
|
public String toJson() {
|
||||||
|
return JSON.getGson().toJson(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,485 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.openapitools.client.model;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Locale;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.annotations.JsonAdapter;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonDeserializationContext;
|
||||||
|
import com.google.gson.JsonDeserializer;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.google.gson.TypeAdapterFactory;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.openapitools.client.JSON;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A User who is purchasing from the pet store
|
||||||
|
*/
|
||||||
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0-SNAPSHOT")
|
||||||
|
public class User {
|
||||||
|
public static final String SERIALIZED_NAME_ID = "id";
|
||||||
|
@SerializedName(SERIALIZED_NAME_ID)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_USERNAME = "username";
|
||||||
|
@SerializedName(SERIALIZED_NAME_USERNAME)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_FIRST_NAME = "firstName";
|
||||||
|
@SerializedName(SERIALIZED_NAME_FIRST_NAME)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private String firstName;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_LAST_NAME = "lastName";
|
||||||
|
@SerializedName(SERIALIZED_NAME_LAST_NAME)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private String lastName;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_EMAIL = "email";
|
||||||
|
@SerializedName(SERIALIZED_NAME_EMAIL)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_PASSWORD = "password";
|
||||||
|
@SerializedName(SERIALIZED_NAME_PASSWORD)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_PHONE = "phone";
|
||||||
|
@SerializedName(SERIALIZED_NAME_PHONE)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
public static final String SERIALIZED_NAME_USER_STATUS = "userStatus";
|
||||||
|
@SerializedName(SERIALIZED_NAME_USER_STATUS)
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private Integer userStatus;
|
||||||
|
|
||||||
|
public User() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public User id(@javax.annotation.Nullable Long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id
|
||||||
|
* @return id
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(@javax.annotation.Nullable Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public User username(@javax.annotation.Nullable String username) {
|
||||||
|
this.username = username;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get username
|
||||||
|
* @return username
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(@javax.annotation.Nullable String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public User firstName(@javax.annotation.Nullable String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get firstName
|
||||||
|
* @return firstName
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(@javax.annotation.Nullable String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public User lastName(@javax.annotation.Nullable String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get lastName
|
||||||
|
* @return lastName
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(@javax.annotation.Nullable String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public User email(@javax.annotation.Nullable String email) {
|
||||||
|
this.email = email;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get email
|
||||||
|
* @return email
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(@javax.annotation.Nullable String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public User password(@javax.annotation.Nullable String password) {
|
||||||
|
this.password = password;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get password
|
||||||
|
* @return password
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(@javax.annotation.Nullable String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public User phone(@javax.annotation.Nullable String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get phone
|
||||||
|
* @return phone
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public String getPhone() {
|
||||||
|
return phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhone(@javax.annotation.Nullable String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public User userStatus(@javax.annotation.Nullable Integer userStatus) {
|
||||||
|
this.userStatus = userStatus;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User Status
|
||||||
|
* @return userStatus
|
||||||
|
*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
public Integer getUserStatus() {
|
||||||
|
return userStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserStatus(@javax.annotation.Nullable Integer userStatus) {
|
||||||
|
this.userStatus = userStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A container for additional, undeclared properties.
|
||||||
|
* This is a holder for any undeclared properties as specified with
|
||||||
|
* the 'additionalProperties' keyword in the OAS document.
|
||||||
|
*/
|
||||||
|
private Map<String, Object> additionalProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the additional (undeclared) property with the specified name and value.
|
||||||
|
* If the property does not already exist, create it otherwise replace it.
|
||||||
|
*
|
||||||
|
* @param key name of the property
|
||||||
|
* @param value value of the property
|
||||||
|
* @return the User instance itself
|
||||||
|
*/
|
||||||
|
public User putAdditionalProperty(String key, Object value) {
|
||||||
|
if (this.additionalProperties == null) {
|
||||||
|
this.additionalProperties = new HashMap<String, Object>();
|
||||||
|
}
|
||||||
|
this.additionalProperties.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the additional (undeclared) property.
|
||||||
|
*
|
||||||
|
* @return a map of objects
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getAdditionalProperties() {
|
||||||
|
return additionalProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the additional (undeclared) property with the specified name.
|
||||||
|
*
|
||||||
|
* @param key name of the property
|
||||||
|
* @return an object
|
||||||
|
*/
|
||||||
|
public Object getAdditionalProperty(String key) {
|
||||||
|
if (this.additionalProperties == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this.additionalProperties.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
User user = (User) o;
|
||||||
|
return Objects.equals(this.id, user.id) &&
|
||||||
|
Objects.equals(this.username, user.username) &&
|
||||||
|
Objects.equals(this.firstName, user.firstName) &&
|
||||||
|
Objects.equals(this.lastName, user.lastName) &&
|
||||||
|
Objects.equals(this.email, user.email) &&
|
||||||
|
Objects.equals(this.password, user.password) &&
|
||||||
|
Objects.equals(this.phone, user.phone) &&
|
||||||
|
Objects.equals(this.userStatus, user.userStatus)&&
|
||||||
|
Objects.equals(this.additionalProperties, user.additionalProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus, additionalProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class User {\n");
|
||||||
|
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||||
|
sb.append(" username: ").append(toIndentedString(username)).append("\n");
|
||||||
|
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
|
||||||
|
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
|
||||||
|
sb.append(" email: ").append(toIndentedString(email)).append("\n");
|
||||||
|
sb.append(" password: ").append(toIndentedString(password)).append("\n");
|
||||||
|
sb.append(" phone: ").append(toIndentedString(phone)).append("\n");
|
||||||
|
sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n");
|
||||||
|
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||||
|
sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given object to string with each line indented by 4 spaces
|
||||||
|
* (except the first line).
|
||||||
|
*/
|
||||||
|
private String toIndentedString(Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return o.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static HashSet<String> openapiFields;
|
||||||
|
public static HashSet<String> openapiRequiredFields;
|
||||||
|
|
||||||
|
static {
|
||||||
|
// a set of all properties/fields (JSON key names)
|
||||||
|
openapiFields = new HashSet<String>(Arrays.asList("id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus"));
|
||||||
|
|
||||||
|
// a set of required properties/fields (JSON key names)
|
||||||
|
openapiRequiredFields = new HashSet<String>(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates the JSON Element and throws an exception if issues found
|
||||||
|
*
|
||||||
|
* @param jsonElement JSON Element
|
||||||
|
* @throws IOException if the JSON Element is invalid with respect to User
|
||||||
|
*/
|
||||||
|
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||||
|
if (jsonElement == null) {
|
||||||
|
if (!User.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in User is not found in the empty JSON string", User.openapiRequiredFields.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||||
|
if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) {
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString()));
|
||||||
|
}
|
||||||
|
if ((jsonObj.get("firstName") != null && !jsonObj.get("firstName").isJsonNull()) && !jsonObj.get("firstName").isJsonPrimitive()) {
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `firstName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("firstName").toString()));
|
||||||
|
}
|
||||||
|
if ((jsonObj.get("lastName") != null && !jsonObj.get("lastName").isJsonNull()) && !jsonObj.get("lastName").isJsonPrimitive()) {
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `lastName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("lastName").toString()));
|
||||||
|
}
|
||||||
|
if ((jsonObj.get("email") != null && !jsonObj.get("email").isJsonNull()) && !jsonObj.get("email").isJsonPrimitive()) {
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `email` to be a primitive type in the JSON string but got `%s`", jsonObj.get("email").toString()));
|
||||||
|
}
|
||||||
|
if ((jsonObj.get("password") != null && !jsonObj.get("password").isJsonNull()) && !jsonObj.get("password").isJsonPrimitive()) {
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `password` to be a primitive type in the JSON string but got `%s`", jsonObj.get("password").toString()));
|
||||||
|
}
|
||||||
|
if ((jsonObj.get("phone") != null && !jsonObj.get("phone").isJsonNull()) && !jsonObj.get("phone").isJsonPrimitive()) {
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `phone` to be a primitive type in the JSON string but got `%s`", jsonObj.get("phone").toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||||
|
if (!User.class.isAssignableFrom(type.getRawType())) {
|
||||||
|
return null; // this class only serializes 'User' and its subtypes
|
||||||
|
}
|
||||||
|
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||||
|
final TypeAdapter<User> thisAdapter
|
||||||
|
= gson.getDelegateAdapter(this, TypeToken.get(User.class));
|
||||||
|
|
||||||
|
return (TypeAdapter<T>) new TypeAdapter<User>() {
|
||||||
|
@Override
|
||||||
|
public void write(JsonWriter out, User value) throws IOException {
|
||||||
|
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||||
|
obj.remove("additionalProperties");
|
||||||
|
// serialize additional properties
|
||||||
|
if (value.getAdditionalProperties() != null) {
|
||||||
|
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||||
|
if (entry.getValue() instanceof String)
|
||||||
|
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Number)
|
||||||
|
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Boolean)
|
||||||
|
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||||
|
else if (entry.getValue() instanceof Character)
|
||||||
|
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||||
|
else {
|
||||||
|
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
|
||||||
|
if (jsonElement.isJsonArray()) {
|
||||||
|
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
|
||||||
|
} else {
|
||||||
|
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elementAdapter.write(out, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User read(JsonReader in) throws IOException {
|
||||||
|
JsonElement jsonElement = elementAdapter.read(in);
|
||||||
|
validateJsonElement(jsonElement);
|
||||||
|
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||||
|
// store additional fields in the deserialized instance
|
||||||
|
User instance = thisAdapter.fromJsonTree(jsonObj);
|
||||||
|
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||||
|
if (!openapiFields.contains(entry.getKey())) {
|
||||||
|
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||||
|
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||||
|
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||||
|
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||||
|
else
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||||
|
} else if (entry.getValue().isJsonArray()) {
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||||
|
} else { // JSON object
|
||||||
|
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
}.nullSafe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of User given an JSON string
|
||||||
|
*
|
||||||
|
* @param jsonString JSON string
|
||||||
|
* @return An instance of User
|
||||||
|
* @throws IOException if the JSON string is invalid with respect to User
|
||||||
|
*/
|
||||||
|
public static User fromJson(String jsonString) throws IOException {
|
||||||
|
return JSON.getGson().fromJson(jsonString, User.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an instance of User to an JSON string
|
||||||
|
*
|
||||||
|
* @return JSON string
|
||||||
|
*/
|
||||||
|
public String toJson() {
|
||||||
|
return JSON.getGson().toJson(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.openapitools.client.api;
|
||||||
|
|
||||||
|
import org.openapitools.client.ApiException;
|
||||||
|
import org.openapitools.client.model.Order;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API tests for StoreApi
|
||||||
|
*/
|
||||||
|
@Disabled
|
||||||
|
public class StoreApiTest {
|
||||||
|
|
||||||
|
private final StoreApi api = new StoreApi();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete purchase order by ID
|
||||||
|
*
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
*
|
||||||
|
* @throws ApiException if the Api call fails
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void deleteOrderTest() throws ApiException {
|
||||||
|
String orderId = null;
|
||||||
|
api.deleteOrder(orderId);
|
||||||
|
// TODO: test validations
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns pet inventories by status
|
||||||
|
*
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
*
|
||||||
|
* @throws ApiException if the Api call fails
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void getInventoryTest() throws ApiException {
|
||||||
|
Map<String, Integer> response = api.getInventory();
|
||||||
|
// TODO: test validations
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find purchase order by ID
|
||||||
|
*
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||||
|
*
|
||||||
|
* @throws ApiException if the Api call fails
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void getOrderByIdTest() throws ApiException {
|
||||||
|
Long orderId = null;
|
||||||
|
Order response = api.getOrderById(orderId);
|
||||||
|
// TODO: test validations
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place an order for a pet
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @throws ApiException if the Api call fails
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void placeOrderTest() throws ApiException {
|
||||||
|
Order order = null;
|
||||||
|
Order response = api.placeOrder(order);
|
||||||
|
// TODO: test validations
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.openapitools.client.api;
|
||||||
|
|
||||||
|
import org.openapitools.client.ApiException;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import org.openapitools.client.model.User;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API tests for UserApi
|
||||||
|
*/
|
||||||
|
@Disabled
|
||||||
|
public class UserApiTest {
|
||||||
|
|
||||||
|
private final UserApi api = new UserApi();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create user
|
||||||
|
*
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
*
|
||||||
|
* @throws ApiException if the Api call fails
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void createUserTest() throws ApiException {
|
||||||
|
User user = null;
|
||||||
|
api.createUser(user);
|
||||||
|
// TODO: test validations
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @throws ApiException if the Api call fails
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void createUsersWithArrayInputTest() throws ApiException {
|
||||||
|
List<User> user = null;
|
||||||
|
api.createUsersWithArrayInput(user);
|
||||||
|
// TODO: test validations
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @throws ApiException if the Api call fails
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void createUsersWithListInputTest() throws ApiException {
|
||||||
|
List<User> user = null;
|
||||||
|
api.createUsersWithListInput(user);
|
||||||
|
// TODO: test validations
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete user
|
||||||
|
*
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
*
|
||||||
|
* @throws ApiException if the Api call fails
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void deleteUserTest() throws ApiException {
|
||||||
|
String username = null;
|
||||||
|
api.deleteUser(username);
|
||||||
|
// TODO: test validations
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get user by user name
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @throws ApiException if the Api call fails
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void getUserByNameTest() throws ApiException {
|
||||||
|
String username = null;
|
||||||
|
User response = api.getUserByName(username);
|
||||||
|
// TODO: test validations
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs user into the system
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @throws ApiException if the Api call fails
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void loginUserTest() throws ApiException {
|
||||||
|
String username = null;
|
||||||
|
String password = null;
|
||||||
|
String response = api.loginUser(username, password);
|
||||||
|
// TODO: test validations
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs out current logged in user session
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @throws ApiException if the Api call fails
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void logoutUserTest() throws ApiException {
|
||||||
|
api.logoutUser();
|
||||||
|
// TODO: test validations
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updated user
|
||||||
|
*
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
*
|
||||||
|
* @throws ApiException if the Api call fails
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void updateUserTest() throws ApiException {
|
||||||
|
String username = null;
|
||||||
|
User user = null;
|
||||||
|
api.updateUser(username, user);
|
||||||
|
// TODO: test validations
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.openapitools.client.model;
|
||||||
|
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.annotations.JsonAdapter;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model tests for Category
|
||||||
|
*/
|
||||||
|
public class CategoryTest {
|
||||||
|
private final Category model = new Category();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model tests for Category
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCategory() {
|
||||||
|
// TODO: test Category
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'id'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void idTest() {
|
||||||
|
// TODO: test id
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'name'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void nameTest() {
|
||||||
|
// TODO: test name
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.openapitools.client.model;
|
||||||
|
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.annotations.JsonAdapter;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model tests for ModelApiResponse
|
||||||
|
*/
|
||||||
|
public class ModelApiResponseTest {
|
||||||
|
private final ModelApiResponse model = new ModelApiResponse();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model tests for ModelApiResponse
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testModelApiResponse() {
|
||||||
|
// TODO: test ModelApiResponse
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'code'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void codeTest() {
|
||||||
|
// TODO: test code
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'type'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void typeTest() {
|
||||||
|
// TODO: test type
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'message'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void messageTest() {
|
||||||
|
// TODO: test message
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.openapitools.client.model;
|
||||||
|
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.annotations.JsonAdapter;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model tests for Order
|
||||||
|
*/
|
||||||
|
public class OrderTest {
|
||||||
|
private final Order model = new Order();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model tests for Order
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testOrder() {
|
||||||
|
// TODO: test Order
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'id'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void idTest() {
|
||||||
|
// TODO: test id
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'petId'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void petIdTest() {
|
||||||
|
// TODO: test petId
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'quantity'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void quantityTest() {
|
||||||
|
// TODO: test quantity
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'shipDate'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void shipDateTest() {
|
||||||
|
// TODO: test shipDate
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'status'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void statusTest() {
|
||||||
|
// TODO: test status
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'complete'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void completeTest() {
|
||||||
|
// TODO: test complete
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.openapitools.client.model;
|
||||||
|
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.annotations.JsonAdapter;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import org.openapitools.client.model.Category;
|
||||||
|
import org.openapitools.client.model.Tag;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model tests for Pet
|
||||||
|
*/
|
||||||
|
public class PetTest {
|
||||||
|
private final Pet model = new Pet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model tests for Pet
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testPet() {
|
||||||
|
// TODO: test Pet
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'id'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void idTest() {
|
||||||
|
// TODO: test id
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'category'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void categoryTest() {
|
||||||
|
// TODO: test category
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'name'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void nameTest() {
|
||||||
|
// TODO: test name
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'photoUrls'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void photoUrlsTest() {
|
||||||
|
// TODO: test photoUrls
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'tags'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void tagsTest() {
|
||||||
|
// TODO: test tags
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'status'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void statusTest() {
|
||||||
|
// TODO: test status
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.openapitools.client.model;
|
||||||
|
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.annotations.JsonAdapter;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model tests for Tag
|
||||||
|
*/
|
||||||
|
public class TagTest {
|
||||||
|
private final Tag model = new Tag();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model tests for Tag
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testTag() {
|
||||||
|
// TODO: test Tag
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'id'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void idTest() {
|
||||||
|
// TODO: test id
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'name'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void nameTest() {
|
||||||
|
// TODO: test name
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.openapitools.client.model;
|
||||||
|
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.annotations.JsonAdapter;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model tests for User
|
||||||
|
*/
|
||||||
|
public class UserTest {
|
||||||
|
private final User model = new User();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model tests for User
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testUser() {
|
||||||
|
// TODO: test User
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'id'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void idTest() {
|
||||||
|
// TODO: test id
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'username'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void usernameTest() {
|
||||||
|
// TODO: test username
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'firstName'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void firstNameTest() {
|
||||||
|
// TODO: test firstName
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'lastName'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void lastNameTest() {
|
||||||
|
// TODO: test lastName
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'email'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void emailTest() {
|
||||||
|
// TODO: test email
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'password'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void passwordTest() {
|
||||||
|
// TODO: test password
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'phone'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void phoneTest() {
|
||||||
|
// TODO: test phone
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the property 'userStatus'
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void userStatusTest() {
|
||||||
|
// TODO: test userStatus
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user