|
| 1 | +# spring-swagger-codegen-api-client |
| 2 | + |
| 3 | +## Requirements |
| 4 | + |
| 5 | +Building the API client library requires [Maven](https://maven.apache.org/) to be installed. |
| 6 | + |
| 7 | +## Installation |
| 8 | + |
| 9 | +To install the API client library to your local Maven repository, simply execute: |
| 10 | + |
| 11 | +```shell |
| 12 | +mvn install |
| 13 | +``` |
| 14 | + |
| 15 | +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: |
| 16 | + |
| 17 | +```shell |
| 18 | +mvn deploy |
| 19 | +``` |
| 20 | + |
| 21 | +Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. |
| 22 | + |
| 23 | +### Maven users |
| 24 | + |
| 25 | +Add this dependency to your project's POM: |
| 26 | + |
| 27 | +```xml |
| 28 | +<dependency> |
| 29 | + <groupId>com.baeldung</groupId> |
| 30 | + <artifactId>spring-swagger-codegen-api-client</artifactId> |
| 31 | + <version>0.0.1-SNAPSHOT</version> |
| 32 | + <scope>compile</scope> |
| 33 | +</dependency> |
| 34 | +``` |
| 35 | + |
| 36 | +### Gradle users |
| 37 | + |
| 38 | +Add this dependency to your project's build file: |
| 39 | + |
| 40 | +```groovy |
| 41 | +compile "com.baeldung:spring-swagger-codegen-api-client:0.0.1-SNAPSHOT" |
| 42 | +``` |
| 43 | + |
| 44 | +### Others |
| 45 | + |
| 46 | +At first generate the JAR by executing: |
| 47 | + |
| 48 | + mvn package |
| 49 | + |
| 50 | +Then manually install the following JARs: |
| 51 | + |
| 52 | +* target/spring-swagger-codegen-api-client-0.0.1-SNAPSHOT.jar |
| 53 | +* target/lib/*.jar |
| 54 | + |
| 55 | +## Getting Started |
| 56 | + |
| 57 | +Please follow the [installation](#installation) instruction and execute the following Java code: |
| 58 | + |
| 59 | +```java |
| 60 | + |
| 61 | +import com.baeldung.petstore.client.invoker.*; |
| 62 | +import com.baeldung.petstore.client.invoker.auth.*; |
| 63 | +import com.baeldung.petstore.client.model.*; |
| 64 | +import com.baeldung.petstore.client.api.PetApi; |
| 65 | + |
| 66 | +import java.io.File; |
| 67 | +import java.util.*; |
| 68 | + |
| 69 | +public class PetApiExample { |
| 70 | + |
| 71 | + public static void main(String[] args) { |
| 72 | + ApiClient defaultClient = Configuration.getDefaultApiClient(); |
| 73 | + |
| 74 | + // Configure OAuth2 access token for authorization: petstore_auth |
| 75 | + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); |
| 76 | + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); |
| 77 | + |
| 78 | + PetApi apiInstance = new PetApi(); |
| 79 | + Pet body = new Pet(); // Pet | Pet object that needs to be added to the store |
| 80 | + try { |
| 81 | + apiInstance.addPet(body); |
| 82 | + } catch (ApiException e) { |
| 83 | + System.err.println("Exception when calling PetApi#addPet"); |
| 84 | + e.printStackTrace(); |
| 85 | + } |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +``` |
| 90 | + |
| 91 | +## Documentation for API Endpoints |
| 92 | + |
| 93 | +All URIs are relative to *http://petstore.swagger.io/v2* |
| 94 | + |
| 95 | +Class | Method | HTTP request | Description |
| 96 | +------------ | ------------- | ------------- | ------------- |
| 97 | +*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store |
| 98 | +*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet |
| 99 | +*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status |
| 100 | +*PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags |
| 101 | +*PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID |
| 102 | +*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet |
| 103 | +*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data |
| 104 | +*PetApi* | [**uploadFile**](docs/PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image |
| 105 | +*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID |
| 106 | +*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status |
| 107 | +*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID |
| 108 | +*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet |
| 109 | +*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user |
| 110 | +*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array |
| 111 | +*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array |
| 112 | +*UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user |
| 113 | +*UserApi* | [**getUserByName**](docs/UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name |
| 114 | +*UserApi* | [**loginUser**](docs/UserApi.md#loginUser) | **GET** /user/login | Logs user into the system |
| 115 | +*UserApi* | [**logoutUser**](docs/UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session |
| 116 | +*UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **PUT** /user/{username} | Updated user |
| 117 | + |
| 118 | + |
| 119 | +## Documentation for Models |
| 120 | + |
| 121 | + - [Category](docs/Category.md) |
| 122 | + - [ModelApiResponse](docs/ModelApiResponse.md) |
| 123 | + - [Order](docs/Order.md) |
| 124 | + - [Pet](docs/Pet.md) |
| 125 | + - [Tag](docs/Tag.md) |
| 126 | + - [User](docs/User.md) |
| 127 | + |
| 128 | + |
| 129 | +## Documentation for Authorization |
| 130 | + |
| 131 | +Authentication schemes defined for the API: |
| 132 | +### api_key |
| 133 | + |
| 134 | +- **Type**: API key |
| 135 | +- **API key parameter name**: api_key |
| 136 | +- **Location**: HTTP header |
| 137 | + |
| 138 | +### petstore_auth |
| 139 | + |
| 140 | +- **Type**: OAuth |
| 141 | +- **Flow**: implicit |
| 142 | +- **Authorization URL**: http://petstore.swagger.io/oauth/dialog |
| 143 | +- **Scopes**: |
| 144 | + - write:pets: modify pets in your account |
| 145 | + - read:pets: read your pets |
| 146 | + |
| 147 | + |
| 148 | +## Recommendation |
| 149 | + |
| 150 | +It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues. |
| 151 | + |
| 152 | +## Author |
| 153 | + |
| 154 | +apiteam@swagger.io |
| 155 | + |
0 commit comments