Added Kotlin Vert.x client (#13594)

* Initial version of Kotlin Vert.x client

* Initial version of Kotlin Vert.x client

* Initial version of Kotlin Vert.x client

* Fix for parseDateToQueryString issue in vert.x kotlin client

* Moved common methods from api to ApiClient in kotlin vert.x client

* Fixed issue with absolute URLs

* bearer auth for oauth

* empty request headers fix

* missing import and typo

* added uri template dependency

* added api abstractions to client generator

* added full import form infrastructure

* removed fail on unknown properties to response body parsing

* fixed error response parsing

* replace vertx client name to more unique

* multiline content type

* optional responses added to template

* additional annotations for kotlin client

* Added additionalModelTypeAnnotations parameter support to AbstractKotlinCodegen

* Updated samples and documents

* Fixed issues with gson and moshi serializers with kotlin-jvm-vertx client

* Added sample configs for kotlin-jvm-vertx clients with gson, jackson and moshi

* Added samples for kotlin-jvm-vertx clients with gson, jackson and moshi

* Included kotlin-jvm-vertx samples to test build

* Updated samples

Co-authored-by: Katja Danilova <katja.danilova@protonmail.com>
This commit is contained in:
Antti Leppä 2022-10-19 17:29:34 +03:00 committed by GitHub
parent 042e250efa
commit 11c43c3c2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
289 changed files with 15132 additions and 1 deletions

View File

@ -51,6 +51,11 @@ jobs:
- samples/client/petstore/kotlin-bigdecimal-default-okhttp4
- samples/client/petstore/kotlin-jvm-ktor-jackson
- samples/client/petstore/kotlin-jvm-ktor-gson
- samples/client/petstore/kotlin-jvm-ktor-gson
- samples/client/petstore/kotlin-jvm-vertx-gson
- samples/client/petstore/kotlin-jvm-vertx-jackson
- samples/client/petstore/kotlin-jvm-vertx-jackson-coroutines
- samples/client/petstore/kotlin-jvm-vertx-moshi
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3

View File

@ -0,0 +1,8 @@
generatorName: kotlin
outputDir: samples/client/petstore/kotlin-jvm-vertx-gson
library: jvm-vertx
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
additionalProperties:
artifactId: kotlin-petstore-jvm-vertx
serializationLibrary: "gson"

View File

@ -0,0 +1,9 @@
generatorName: kotlin
outputDir: samples/client/petstore/kotlin-jvm-vertx-jackson-coroutines
library: jvm-vertx
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
additionalProperties:
artifactId: kotlin-petstore-jvm-vertx
serializationLibrary: "jackson"
useCoroutines: "true"

View File

@ -0,0 +1,8 @@
generatorName: kotlin
outputDir: samples/client/petstore/kotlin-jvm-vertx-jackson
library: jvm-vertx
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
additionalProperties:
artifactId: kotlin-petstore-jvm-vertx
serializationLibrary: "jackson"

View File

@ -0,0 +1,8 @@
generatorName: kotlin
outputDir: samples/client/petstore/kotlin-jvm-vertx-moshi
library: jvm-vertx
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
additionalProperties:
artifactId: kotlin-petstore-jvm-vertx
serializationLibrary: "moshi"

View File

@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|apiSuffix|suffix for api classes| |Api|
|artifactId|Generated artifact id (name of jar).| |kotlin-server|
|artifactVersion|Generated artifact's package version.| |1.0.0|

View File

@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|annotationLibrary|Select the complementary documentation annotation library.|<dl><dt>**none**</dt><dd>Do not annotate Model and Api with complementary annotations.</dd><dt>**swagger1**</dt><dd>Annotate Model and Api using the Swagger Annotations 1.x library.</dd><dt>**swagger2**</dt><dd>Annotate Model and Api using the Swagger Annotations 2.x library.</dd></dl>|swagger2|
|apiPackage|api package for generated code| |org.openapitools.api|
|apiSuffix|suffix for api classes| |Api|

View File

@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|apiSuffix|suffix for api classes| |Api|
|artifactId|Generated artifact id (name of jar).| |null|
|artifactVersion|Generated artifact's package version.| |1.0.0|

View File

@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|apiSuffix|suffix for api classes| |Api|
|artifactId|Generated artifact id (name of jar).| |kotlin-client|
|artifactVersion|Generated artifact's package version.| |1.0.0|
@ -27,7 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|generateRoomModels|Generate Android Room database models in addition to API models (JVM Volley library only)| |false|
|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
|idea|Add IntellJ Idea plugin and mark Kotlin main and test folders as source folders.| |false|
|library|Library template (sub-template) to use|<dl><dt>**jvm-ktor**</dt><dd>Platform: Java Virtual Machine. HTTP client: Ktor 1.6.7. JSON processing: Gson, Jackson (default).</dd><dt>**jvm-okhttp4**</dt><dd>[DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-okhttp3**</dt><dd>Platform: Java Virtual Machine. HTTP client: OkHttp 3.12.4 (Android 2.3+ and Java 7+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-retrofit2**</dt><dd>Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.</dd><dt>**multiplatform**</dt><dd>Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1.</dd><dt>**jvm-volley**</dt><dd>Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9</dd></dl>|jvm-okhttp4|
|library|Library template (sub-template) to use|<dl><dt>**jvm-ktor**</dt><dd>Platform: Java Virtual Machine. HTTP client: Ktor 1.6.7. JSON processing: Gson, Jackson (default).</dd><dt>**jvm-okhttp4**</dt><dd>[DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-okhttp3**</dt><dd>Platform: Java Virtual Machine. HTTP client: OkHttp 3.12.4 (Android 2.3+ and Java 7+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-retrofit2**</dt><dd>Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.</dd><dt>**multiplatform**</dt><dd>Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1.</dd><dt>**jvm-volley**</dt><dd>Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9</dd><dt>**jvm-vertx**</dt><dd>Platform: Java Virtual Machine. HTTP client: Vert.x Web Client. JSON processing: Moshi, Gson or Jackson.</dd></dl>|jvm-okhttp4|
|modelMutable|Create mutable models| |false|
|moshiCodeGen|Whether to enable codegen with the Moshi library. Refer to the [official Moshi doc](https://github.com/square/moshi#codegen) for more info.| |false|
|omitGradlePluginVersions|Whether to declare Gradle plugin versions in build files.| |false|

View File

@ -19,6 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|addSurrogateKey|Adds the surrogate key for all models that don't already have a primary key (named by the above convention)| |false|
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|artifactId|Generated artifact id (name of jar).| |ktorm|
|artifactVersion|Generated artifact's package version.| |1.0.0|
|defaultDatabaseName|Default database name for all queries| |sqlite.db|

View File

@ -49,6 +49,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
public static final String MODEL_MUTABLE = "modelMutable";
public static final String MODEL_MUTABLE_DESC = "Create mutable models";
public static final String ADDITIONAL_MODEL_TYPE_ANNOTATIONS = "additionalModelTypeAnnotations";
private final Logger LOGGER = LoggerFactory.getLogger(AbstractKotlinCodegen.class);
@ -77,6 +78,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
protected Set<String> propertyAdditionalKeywords = new HashSet<>(Arrays.asList("entries", "keys", "size", "values"));
private final Map<String, String> schemaKeyToModelNameCache = new HashMap<>();
protected List<String> additionalModelTypeAnnotations = new LinkedList<>();
public AbstractKotlinCodegen() {
super();
@ -262,6 +264,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
cliOptions.add(new CliOption(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG, CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG_DESC));
cliOptions.add(CliOption.newBoolean(MODEL_MUTABLE, MODEL_MUTABLE_DESC, false));
cliOptions.add(CliOption.newString(ADDITIONAL_MODEL_TYPE_ANNOTATIONS, "Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)"));
}
@Override
@ -398,6 +401,21 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar);
}
@Override
public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs) {
objs = super.postProcessAllModels(objs);
objs = super.updateAllModels(objs);
if (!additionalModelTypeAnnotations.isEmpty()) {
for (String modelName : objs.keySet()) {
Map<String, Object> models = (Map<String, Object>) objs.get(modelName);
models.put(ADDITIONAL_MODEL_TYPE_ANNOTATIONS, additionalModelTypeAnnotations);
}
}
return objs;
}
@Override
public ModelsMap postProcessModels(ModelsMap objs) {
objs = super.postProcessModelsEnum(objs);
@ -506,6 +524,11 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
additionalProperties.put(CodegenConstants.NON_PUBLIC_API, nonPublicApi);
}
if (additionalProperties.containsKey(ADDITIONAL_MODEL_TYPE_ANNOTATIONS)) {
String additionalAnnotationsList = additionalProperties.get(ADDITIONAL_MODEL_TYPE_ANNOTATIONS).toString();
this.setAdditionalModelTypeAnnotations(Arrays.asList(additionalAnnotationsList.trim().split("\\s*(;|\\r?\\n)\\s*")));
}
additionalProperties.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, getSortParamsByRequiredFlag());
additionalProperties.put(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG, getSortModelPropertiesByRequiredFlag());
@ -1095,4 +1118,12 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
// process 'additionalProperties'
setAddProps(schema, m);
}
public List<String> getAdditionalModelTypeAnnotations() {
return additionalModelTypeAnnotations;
}
public void setAdditionalModelTypeAnnotations(final List<String> additionalModelTypeAnnotations) {
this.additionalModelTypeAnnotations = additionalModelTypeAnnotations;
}
}

View File

@ -63,6 +63,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
protected static final String JVM_RETROFIT2 = "jvm-retrofit2";
protected static final String MULTIPLATFORM = "multiplatform";
protected static final String JVM_VOLLEY = "jvm-volley";
protected static final String JVM_VERTX = "jvm-vertx";
public static final String USE_RX_JAVA = "useRxJava";
public static final String USE_RX_JAVA2 = "useRxJava2";
@ -215,6 +216,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
supportedLibraries.put(JVM_RETROFIT2, "Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.");
supportedLibraries.put(MULTIPLATFORM, "Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1.");
supportedLibraries.put(JVM_VOLLEY, "Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9");
supportedLibraries.put(JVM_VERTX, "Platform: Java Virtual Machine. HTTP client: Vert.x Web Client. JSON processing: Moshi, Gson or Jackson.");
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "Library template (sub-template) to use");
libraryOption.setEnum(supportedLibraries);
@ -441,6 +443,9 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
case MULTIPLATFORM:
processMultiplatformLibrary(infrastructureFolder);
break;
case JVM_VERTX:
processJVMVertXLibrary(infrastructureFolder);
break;
default:
break;
}
@ -666,6 +671,22 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
supportingFiles.add(new SupportingFile("auth/OAuth.kt.mustache", authFolder, "OAuth.kt"));
}
/**
* Process Vert.x client options
*
* @param infrastructureFolder infrastructure destination folder
*/
private void processJVMVertXLibrary(final String infrastructureFolder) {
supportingFiles.add(new SupportingFile("infrastructure/ApiAbstractions.kt.mustache", infrastructureFolder, "ApiAbstractions.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ApiClient.kt.mustache", infrastructureFolder, "ApiClient.kt"));
supportingFiles.add(new SupportingFile("infrastructure/Errors.kt.mustache", infrastructureFolder, "Errors.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ApiResponse.kt.mustache", infrastructureFolder, "ApiResponse.kt"));
addSupportingSerializerAdapters(infrastructureFolder);
additionalProperties.put(JVM, true);
additionalProperties.put(JVM_VERTX, true);
}
private void processJVMOkHttpLibrary(final String infrastructureFolder) {
commonJvmMultiplatformSupportingFiles(infrastructureFolder);
addSupportingSerializerAdapters(infrastructureFolder);

View File

@ -0,0 +1,2 @@
{{#additionalModelTypeAnnotations}}{{{.}}}
{{/additionalModelTypeAnnotations}}

View File

@ -25,6 +25,9 @@ buildscript {
{{#useRxJava3}}
ext.rxJava3Version = '3.0.12'
{{/useRxJava3}}
{{#jvm-vertx}}
ext.vertx_version = "4.3.3"
{{/jvm-vertx}}
repositories {
maven { url "https://repo1.maven.org/maven2" }
@ -149,6 +152,15 @@ dependencies {
implementation "com.squareup.retrofit2:converter-scalars:$retrofitVersion"
{{/jvm-retrofit2}}
testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
{{#jvm-vertx}}
implementation "io.vertx:vertx-web-client:$vertx_version"
implementation "io.vertx:vertx-core:$vertx_version"
implementation "io.vertx:vertx-lang-kotlin:$vertx_version"
implementation "io.vertx:vertx-uri-template:$vertx_version"
{{#useCoroutines}}
implementation "io.vertx:vertx-lang-kotlin-coroutines:$vertx_version"
{{/useCoroutines}}
{{/jvm-vertx}}
}
{{#kotlinx_serialization}}

View File

@ -61,6 +61,7 @@ import {{packageName}}.infrastructure.ITransformForStorage
{{#isDeprecated}}
@Deprecated(message = "This schema is deprecated.")
{{/isDeprecated}}
{{>additionalModelTypeAnnotations}}
{{#nonPublicApi}}internal {{/nonPublicApi}}{{#discriminator}}interface{{/discriminator}}{{^discriminator}}data class{{/discriminator}} {{classname}}{{^discriminator}} (
{{#allVars}}

View File

@ -0,0 +1,232 @@
{{>licenseInfo}}
package {{apiPackage}}
import java.io.IOException
{{#imports}}import {{import}}
{{/imports}}
{{#jackson}}
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.core.type.TypeReference
{{/jackson}}
{{#gson}}
import com.google.gson.reflect.TypeToken
import com.google.gson.annotations.SerializedName
{{/gson}}
{{#moshi}}
import com.squareup.moshi.Json
{{/moshi}}
import io.vertx.core.Vertx
import io.vertx.core.http.RequestOptions
import io.vertx.core.http.HttpMethod
import io.vertx.core.buffer.Buffer
import io.vertx.core.Future
import io.vertx.ext.web.client.WebClient
import io.vertx.uritemplate.UriTemplate
{{#useCoroutines}}
import io.vertx.kotlin.coroutines.await
import io.vertx.kotlin.coroutines.dispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
{{/useCoroutines}}
import {{packageName}}.infrastructure.*
@Suppress ("UNUSED")
{{#operations}}
{{#nonPublicApi}}internal {{/nonPublicApi}}class {{classname}}(basePath: kotlin.String = ApiClient.defaultBasePath, accessToken: String? = null, apiKey: MutableMap<String, String> = mutableMapOf(), apiKeyPrefix: MutableMap<String, String> = mutableMapOf(), username: String? = null, password: String? = null, vertx: Vertx): ApiClient(basePath, accessToken, apiKey, apiKeyPrefix, username, password, vertx) {
{{#operation}}
{{#allParams}}
{{#isEnum}}
/**
* enum for parameter {{paramName}}
*/
{{#nonPublicApi}}internal {{/nonPublicApi}}enum class {{enumName}}_{{operationId}}(val value: {{^isContainer}}{{dataType}}{{/isContainer}}{{#isContainer}}kotlin.String{{/isContainer}}) {
{{^enumUnknownDefaultCase}}
{{#allowableValues}}
{{#enumVars}}
{{#moshi}}
@Json(name = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}
{{/moshi}}
{{#gson}}
@SerializedName(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}
{{/gson}}
{{#jackson}}
@JsonProperty(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}
{{/jackson}}
{{#kotlinx_serialization}}
@SerialName(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}
{{/kotlinx_serialization}}
{{/enumVars}}
{{/allowableValues}}
{{/enumUnknownDefaultCase}}
{{#enumUnknownDefaultCase}}
{{#allowableValues}}
{{#enumVars}}
{{^-last}}
{{#moshi}}
@Json(name = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}),
{{/moshi}}
{{#gson}}
@SerializedName(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}),
{{/gson}}
{{#jackson}}
@JsonProperty(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}),
{{/jackson}}
{{#kotlinx_serialization}}
@SerialName(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}),
{{/kotlinx_serialization}}
{{/-last}}
{{/enumVars}}
{{/allowableValues}}
{{/enumUnknownDefaultCase}}
}
{{/isEnum}}
{{/allParams}}
/**
* {{summary}}
* {{notes}}
{{#allParams}}* @param {{{paramName}}} {{description}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}{{/required}}
{{/allParams}}* @return {{#returnType}}{{{returnType}}}{{#nullableReturnType}}{{^isResponseOptional}} or null{{/isResponseOptional}}{{/nullableReturnType}}{{#isResponseOptional}} or null{{/isResponseOptional}}{{/returnType}}{{^returnType}}void{{/returnType}}
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/{{#returnType}}
@Suppress("UNCHECKED_CAST"){{/returnType}}
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
{{#isDeprecated}}
@Deprecated(message = "This operation is deprecated.")
{{/isDeprecated}}
{{#useCoroutines}}suspend {{/useCoroutines}}fun {{operationId}}({{#allParams}}{{{paramName}}}: {{#isEnum}}{{#isContainer}}kotlin.collections.List<{{enumName}}_{{operationId}}>{{/isContainer}}{{^isContainer}}{{enumName}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#required}}{{#defaultValue}} = {{^isNumber}}{{{defaultValue}}}{{/isNumber}}{{#isNumber}}{{{dataType}}}("{{{defaultValue}}}"){{/isNumber}}{{/defaultValue}}{{/required}}{{^required}}?{{#defaultValue}} = {{^isNumber}}{{{defaultValue}}}{{/isNumber}}{{#isNumber}}{{{dataType}}}("{{{defaultValue}}}"){{/isNumber}}{{/defaultValue}}{{^defaultValue}} = null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) : {{^useCoroutines}}Future<{{/useCoroutines}}{{#returnType}}{{{returnType}}}{{#nullableReturnType}}{{^isResponseOptional}}?{{/isResponseOptional}}{{/nullableReturnType}}{{#isResponseOptional}}?{{/isResponseOptional}}{{/returnType}}{{^returnType}}Unit{{/returnType}}{{^useCoroutines}}>{{/useCoroutines}} {
return {{operationId}}WithHttpInfo({{#allParams}}{{{paramName}}} = {{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}}).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> {{#returnType}}(localVarResponse as Success<*>).data as {{{returnType}}}{{#nullableReturnType}}{{^isResponseOptional}}?{{/isResponseOptional}}{{/nullableReturnType}}{{#isResponseOptional}}?{{/isResponseOptional}}{{/returnType}}{{^returnType}}Unit{{/returnType}}
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}{{#useCoroutines}}.await(){{/useCoroutines}}
}
/**
* {{summary}}
* {{notes}}
{{#allParams}}* @param {{{paramName}}} {{description}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}{{/required}}
{{/allParams}}* @return ApiResponse<{{#returnType}}{{{returnType}}}?{{/returnType}}{{^returnType}}Unit?{{/returnType}}>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/{{#returnType}}
@Suppress("UNCHECKED_CAST"){{/returnType}}
@Throws(IllegalStateException::class, IOException::class)
{{#isDeprecated}}
@Deprecated(message = "This operation is deprecated.")
{{/isDeprecated}}
fun {{operationId}}WithHttpInfo({{#allParams}}{{{paramName}}}: {{#isEnum}}{{#isContainer}}kotlin.collections.List<{{enumName}}_{{operationId}}>{{/isContainer}}{{^isContainer}}{{enumName}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}?{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) : Future<ApiResponse<{{#returnType}}{{{returnType}}}?{{/returnType}}{{^returnType}}Unit?{{/returnType}}>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.{{httpMethod}}, UriTemplate.of("$basePath{{path}}"{{#pathParams}}.replace("{"+"{{baseName}}"+"}", encodeURIComponent({{#isContainer}}{{paramName}}.joinToString(","){{/isContainer}}{{^isContainer}}{{{paramName}}}{{#isEnum}}.value{{/isEnum}}.toString(){{/isContainer}})){{/pathParams}}))
{{#hasFormParams}}request.putHeader("Content-Type", {{^consumes}}"multipart/form-data"{{/consumes}}{{#consumes.0}}"{{{mediaType}}}"{{/consumes.0}}){{/hasFormParams}}
{{#headerParams}}{{{paramName}}}{{^required}}?{{/required}}.apply { request.putHeader("{{baseName}}", {{#isContainer}}this.joinToString(separator = collectionDelimiter("{{collectionFormat}}")){{/isContainer}}{{^isContainer}}this.toString(){{/isContainer}})}{{/headerParams}}
{{^hasFormParams}}{{#hasConsumes}}
{{#consumes}}
request.putHeader("Content-Type", "{{{mediaType}}}")
{{/consumes}}
{{/hasConsumes}}{{/hasFormParams}}
{{#hasProduces}}request.putHeader("Accept", "{{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}"){{/hasProduces}}
{{#hasFormParams}}
val form = io.vertx.core.MultiMap.caseInsensitiveMultiMap();
{{#formParams}}
{{{paramName}}}{{^required}}?{{/required}}.let { form.add("{{{baseName}}}", {{{paramName}}}{{#isEnum}}.value{{/isEnum}}{{^isString}}.toString(){{/isString}}) }
{{/formParams}}
{{/hasFormParams}}
{{#hasQueryParams}}
{{#queryParams}}
{{{paramName}}}{{^required}}?{{/required}}.let { request.queryParams().add("{{baseName}}", {{#isContainer}}toMultiValue(it.toList(), "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf({{#isDateTime}}parseDateToQueryString(it){{/isDateTime}}{{#isDate}}parseDateToQueryString(it){{/isDate}}{{^isDateTime}}{{^isDate}}it.toString(){{/isDate}}{{/isDateTime}}){{/isContainer}}) }
{{/queryParams}}
{{/hasQueryParams}}
{{#authMethods}}
{{#isApiKey}}
if (apiKey["{{keyParamName}}"] != null) {
if (apiKeyPrefix["{{keyParamName}}"] != null) {
{{#isKeyInHeader}}
request.putHeader("{{keyParamName}}", apiKeyPrefix["{{keyParamName}}"]!! + " " + apiKey["{{keyParamName}}"]!!)
{{/isKeyInHeader}}
{{#isKeyInQuery}}
request.queryParams().add("{{keyParamName}}", apiKeyPrefix["{{keyParamName}}"]!! + " " + apiKey["{{keyParamName}}"]!!)
{{/isKeyInQuery}}
} else {
{{#isKeyInHeader}}
request.putHeader("{{keyParamName}}", apiKey["{{keyParamName}}"]!!)
{{/isKeyInHeader}}
{{#isKeyInQuery}}
request.queryParams().add("{{keyParamName}}", apiKey["{{keyParamName}}"]!!)
{{/isKeyInQuery}}
}
}
{{/isApiKey}}
{{#isBasic}}
{{#isBasicBasic}}
username?.let { username ->
password?.let { password ->
request.basicAuthentication(username, password)
}
}
{{/isBasicBasic}}
{{#isBasicBearer}}
accessToken?.let { accessToken ->
request.bearerTokenAuthentication(accessToken)
}
{{/isBasicBearer}}
{{/isBasic}}
{{#isOAuth}}
accessToken?.let { accessToken ->
request.bearerTokenAuthentication(accessToken)
}
{{/isOAuth}}
{{/authMethods}}
return request
{{#hasBodyParam}}
.sendBuffer(responseBody({{#bodyParams}}{{{paramName}}}{{/bodyParams}}))
{{/hasBodyParam}}
{{^hasBodyParam}}
.send()
{{/hasBodyParam}}
.map {
val apiResponse: ApiResponse<{{#returnType}}{{{returnType}}}?{{/returnType}}{{^returnType}}Unit?{{/returnType}}> = handleResponse(it)
apiResponse
}
}
{{/operation}}
private inline fun <reified T: Any?> responseBody(body: T): Buffer {
{{#moshi}}
return Buffer.buffer(Serializer.moshi.adapter(T::class.java).toJson(body))
{{/moshi}}
{{#gson}}
return Buffer.buffer(Serializer.gson.toJson(body, T::class.java))
{{/gson}}
{{#jackson}}
return Buffer.buffer(Serializer.jacksonObjectMapper.writeValueAsBytes(body))
{{/jackson}}
}
}
{{/operations}}

View File

@ -0,0 +1,110 @@
package {{packageName}}.infrastructure
import io.vertx.core.Vertx
import io.vertx.core.buffer.Buffer
import java.nio.charset.StandardCharsets
{{#jackson}}
import com.fasterxml.jackson.core.type.TypeReference
{{/jackson}}
{{#gson}}
import com.google.gson.reflect.TypeToken
{{/gson}}
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient(val basePath: kotlin.String = defaultBasePath, val accessToken: String? = null, val apiKey: MutableMap<String, String> = mutableMapOf(), val apiKeyPrefix: MutableMap<String, String> = mutableMapOf(), var username: String? = null, var password: String? = null, val vertx: Vertx) {
companion object {
const val baseUrlKey = "{{packageName}}.baseUrl"
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty(baseUrlKey, "{{{basePath}}}")
}
}
protected inline fun <reified T: Any?> handleResponse(response: io.vertx.ext.web.client.HttpResponse<Buffer>): ApiResponse<T?> {
val code = response.statusCode()
val headers = response.headers().associate { it.key to listOf(it.value) }
val contentType = headers["Content-Type"]?.firstOrNull()?.substringBefore(";")?.lowercase(java.util.Locale.getDefault())
return when (code) {
in 100..199 -> Informational(
response.statusMessage(),
code,
headers
)
in 200 .. 299 -> Success(
responseBody<T>(response.body(), contentType),
code,
headers
)
in 300..399 -> Redirection(
code,
headers
)
in 400..499 -> ClientError(
response.statusMessage(),
response.bodyAsString(),
code,
headers
)
else -> ServerError(
response.statusMessage(),
response.bodyAsString(),
code,
headers
)
}
}
protected inline fun <reified T: Any?> responseBody(body: Buffer?, mediaType: String? = "application/json"): T? {
body ?: return null
val bodyContent = String(body.bytes, StandardCharsets.UTF_8)
if (bodyContent.isEmpty()) {
return null
}
return when {
mediaType==null || (mediaType.startsWith("application/") && mediaType.endsWith("json")) ->
{{#moshi}}Serializer.moshi.adapter(T::class.java).fromJson(bodyContent){{/moshi}}{{!
}}{{#gson}}Serializer.gson.fromJson(bodyContent, (object: TypeToken<T>(){}).getType()){{/gson}}{{!
}}{{#jackson}}Serializer.jacksonObjectMapper.readValue(bodyContent, object: TypeReference<T>() {}){{/jackson}}{{!
}}{{#kotlinx_serialization}}Serializer.kotlinxSerializationJson.decodeFromString<T>(bodyContent){{/kotlinx_serialization}}
else -> throw UnsupportedOperationException("responseBody currently only supports JSON body.")
}
}
protected fun encodeURIComponent(parameter: String): String {
return try {
java.net.URLEncoder.encode(parameter, java.nio.charset.StandardCharsets.UTF_8.name())
} catch (e: java.io.UnsupportedEncodingException) {
parameter
}
}
protected inline fun <reified T: Any> parseDateToQueryString(value : T): String {
{{#toJson}}
/*
.replace("\"", "") converts the json object string to an actual string for the query parameter.
The moshi or gson adapter allows a more generic solution instead of trying to use a native
formatter. It also easily allows to provide a simple way to define a custom date format pattern
inside a gson/moshi adapter.
*/
{{#moshi}}
return Serializer.moshi.adapter(T::class.java).toJson(value).replace("\"", "")
{{/moshi}}
{{#gson}}
return Serializer.gson.toJson(value, T::class.java).replace("\"", "")
{{/gson}}
{{#jackson}}
return Serializer.jacksonObjectMapper.writeValueAsString(value).replace("\"", "")
{{/jackson}}
{{#kotlinx_serialization}}
return Serializer.kotlinxSerializationJson.encodeToString(value).replace("\"", "")
{{/kotlinx_serialization}}
{{/toJson}}
{{^toJson}}
return value.toString()
{{/toJson}}
}
}

View File

@ -0,0 +1,43 @@
package {{packageName}}.infrastructure
{{#nonPublicApi}}internal {{/nonPublicApi}}enum class ResponseType {
Success, Informational, Redirection, ClientError, ServerError
}
{{#nonPublicApi}}internal {{/nonPublicApi}}interface Response
{{#nonPublicApi}}internal {{/nonPublicApi}}abstract class ApiResponse<T>(val responseType: ResponseType): Response {
abstract val statusCode: Int
abstract val headers: Map<String,List<String>>
}
{{#nonPublicApi}}internal {{/nonPublicApi}}class Success<T>(
val data: T{{#nullableReturnType}}?{{/nullableReturnType}},
override val statusCode: Int = -1,
override val headers: Map<String, List<String>> = mapOf()
): ApiResponse<T>(ResponseType.Success)
{{#nonPublicApi}}internal {{/nonPublicApi}}class Informational<T>(
val statusText: String,
override val statusCode: Int = -1,
override val headers: Map<String, List<String>> = mapOf()
) : ApiResponse<T>(ResponseType.Informational)
{{#nonPublicApi}}internal {{/nonPublicApi}}class Redirection<T>(
override val statusCode: Int = -1,
override val headers: Map<String, List<String>> = mapOf()
) : ApiResponse<T>(ResponseType.Redirection)
{{#nonPublicApi}}internal {{/nonPublicApi}}class ClientError<T>(
val message: String? = null,
val body: Any? = null,
override val statusCode: Int = -1,
override val headers: Map<String, List<String>> = mapOf()
) : ApiResponse<T>(ResponseType.ClientError)
{{#nonPublicApi}}internal {{/nonPublicApi}}class ServerError<T>(
val message: String? = null,
val body: Any? = null,
override val statusCode: Int = -1,
override val headers: Map<String, List<String>>
): ApiResponse<T>(ResponseType.ServerError)

View File

@ -0,0 +1,18 @@
@file:Suppress("unused")
package {{packageName}}.infrastructure
import java.lang.RuntimeException
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ClientException(message: kotlin.String? = null, val statusCode: Int = -1, val response: Response? = null) : RuntimeException(message) {
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
private const val serialVersionUID: Long = 123L
}
}
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ServerException(message: kotlin.String? = null, val statusCode: Int = -1, val response: Response? = null) : RuntimeException(message) {
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
private const val serialVersionUID: Long = 456L
}
}

View File

@ -24,6 +24,7 @@ import com.squareup.moshi.Json
* @param id
*/
interface Animal {
@Json(name = "id")

View File

@ -26,6 +26,7 @@ import com.squareup.moshi.Json
* @param featherType
*/
data class Bird (
@Json(name = "id")

View File

@ -24,6 +24,7 @@ import com.squareup.moshi.Json
* @param featherType
*/
data class BirdAllOf (
@Json(name = "featherType")

View File

@ -31,6 +31,7 @@ import kotlinx.serialization.encoding.*
* @param gepa
*/
@Serializable
data class Apa (
@SerialName(value = "bepa") @Required val bepa: kotlin.Double = (0).toDouble(),

View File

@ -29,6 +29,7 @@ import com.squareup.moshi.Json
* @param gepa
*/
data class Apa (
@Json(name = "bepa")

View File

@ -27,6 +27,7 @@ import com.squareup.moshi.Json
* @param n1
*/
data class Apa (
@Json(name = "i0")

View File

@ -27,6 +27,7 @@ import com.squareup.moshi.Json
* @param n1
*/
data class Apa (
@Json(name = "i0")

View File

@ -27,6 +27,7 @@ import com.squareup.moshi.Json
* @param n1
*/
data class Apa (
@Json(name = "i0")

View File

@ -29,6 +29,7 @@ import org.openapitools.client.infrastructure.ITransformForStorage
* @param n1
*/
data class Apa (
@SerializedName("i0")

View File

@ -29,6 +29,7 @@ import kotlinx.serialization.encoding.*
* @param n1
*/
@Serializable
data class Apa (
@SerialName(value = "i0") @Required val i0: kotlin.Int,

View File

@ -31,6 +31,7 @@ import com.google.gson.annotations.SerializedName
* @param propertyDouble3
*/
data class ModelWithPropertyHavingDefault (
@SerializedName("propertyInt")

View File

@ -25,6 +25,7 @@ import java.io.Serializable
* @param propertyName
*/
data class ModelWithEnumPropertyHavingDefault (
@Json(name = "propertyName")

View File

@ -25,6 +25,7 @@ import com.google.gson.annotations.SerializedName
* @param name
*/
data class Category (
@SerializedName("id")

View File

@ -26,6 +26,7 @@ import com.google.gson.annotations.SerializedName
* @param message
*/
data class ModelApiResponse (
@SerializedName("code")

View File

@ -29,6 +29,7 @@ import com.google.gson.annotations.SerializedName
* @param complete
*/
data class Order (
@SerializedName("id")

View File

@ -31,6 +31,7 @@ import com.google.gson.annotations.SerializedName
* @param status pet status in the store
*/
data class Pet (
@SerializedName("name")

View File

@ -25,6 +25,7 @@ import com.google.gson.annotations.SerializedName
* @param name
*/
data class Tag (
@SerializedName("id")

View File

@ -31,6 +31,7 @@ import com.google.gson.annotations.SerializedName
* @param userStatus User Status
*/
data class User (
@SerializedName("id")

View File

@ -25,6 +25,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
* @param name
*/
data class Category (
@field:JsonProperty("id")

View File

@ -26,6 +26,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
* @param message
*/
data class ModelApiResponse (
@field:JsonProperty("code")

View File

@ -29,6 +29,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
* @param complete
*/
data class Order (
@field:JsonProperty("id")

View File

@ -31,6 +31,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
* @param status pet status in the store
*/
data class Pet (
@field:JsonProperty("name")

View File

@ -25,6 +25,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
* @param name
*/
data class Tag (
@field:JsonProperty("id")

View File

@ -31,6 +31,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
* @param userStatus User Status
*/
data class User (
@field:JsonProperty("id")

View File

@ -35,6 +35,7 @@ import kotlinx.parcelize.Parcelize
*/
@Parcelize
@Serializable
data class Category (
@SerialName(value = "id")

View File

@ -36,6 +36,7 @@ import kotlinx.parcelize.Parcelize
*/
@Parcelize
@Serializable
data class ModelApiResponse (
@SerialName(value = "code")

View File

@ -39,6 +39,7 @@ import kotlinx.parcelize.Parcelize
*/
@Parcelize
@Serializable
data class Order (
@SerialName(value = "id")

View File

@ -41,6 +41,7 @@ import kotlinx.parcelize.Parcelize
*/
@Parcelize
@Serializable
data class Pet (
@SerialName(value = "name")

View File

@ -35,6 +35,7 @@ import kotlinx.parcelize.Parcelize
*/
@Parcelize
@Serializable
data class Tag (
@SerialName(value = "id")

View File

@ -41,6 +41,7 @@ import kotlinx.parcelize.Parcelize
*/
@Parcelize
@Serializable
data class User (
@SerialName(value = "id")

View File

@ -25,6 +25,7 @@ import com.google.gson.annotations.SerializedName
* @param name
*/
data class Category (
@SerializedName("id")

View File

@ -26,6 +26,7 @@ import com.google.gson.annotations.SerializedName
* @param message
*/
data class ModelApiResponse (
@SerializedName("code")

View File

@ -29,6 +29,7 @@ import com.google.gson.annotations.SerializedName
* @param complete
*/
data class Order (
@SerializedName("id")

View File

@ -31,6 +31,7 @@ import com.google.gson.annotations.SerializedName
* @param status pet status in the store
*/
data class Pet (
@SerializedName("name")

View File

@ -25,6 +25,7 @@ import com.google.gson.annotations.SerializedName
* @param name
*/
data class Tag (
@SerializedName("id")

View File

@ -31,6 +31,7 @@ import com.google.gson.annotations.SerializedName
* @param userStatus User Status
*/
data class User (
@SerializedName("id")

View File

@ -25,6 +25,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
* @param name
*/
data class Category (
@field:JsonProperty("id")

View File

@ -26,6 +26,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
* @param message
*/
data class ModelApiResponse (
@field:JsonProperty("code")

View File

@ -29,6 +29,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
* @param complete
*/
data class Order (
@field:JsonProperty("id")

View File

@ -31,6 +31,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
* @param status pet status in the store
*/
data class Pet (
@field:JsonProperty("name")

View File

@ -25,6 +25,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
* @param name
*/
data class Tag (
@field:JsonProperty("id")

View File

@ -31,6 +31,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
* @param userStatus User Status
*/
data class User (
@field:JsonProperty("id")

View File

@ -26,6 +26,7 @@ import java.io.Serializable
* @param name
*/
data class Category (
@SerializedName("id")

View File

@ -27,6 +27,7 @@ import java.io.Serializable
* @param message
*/
data class ModelApiResponse (
@SerializedName("code")

View File

@ -30,6 +30,7 @@ import java.io.Serializable
* @param complete
*/
data class Order (
@SerializedName("id")

View File

@ -32,6 +32,7 @@ import java.io.Serializable
* @param status pet status in the store
*/
data class Pet (
@SerializedName("name")

View File

@ -26,6 +26,7 @@ import java.io.Serializable
* @param name
*/
data class Tag (
@SerializedName("id")

View File

@ -32,6 +32,7 @@ import java.io.Serializable
* @param userStatus User Status
*/
data class User (
@SerializedName("id")

View File

@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@ -0,0 +1,34 @@
README.md
build.gradle
docs/ApiResponse.md
docs/Category.md
docs/Order.md
docs/Pet.md
docs/PetApi.md
docs/StoreApi.md
docs/Tag.md
docs/User.md
docs/UserApi.md
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties
gradlew
gradlew.bat
settings.gradle
src/main/kotlin/org/openapitools/client/apis/PetApi.kt
src/main/kotlin/org/openapitools/client/apis/StoreApi.kt
src/main/kotlin/org/openapitools/client/apis/UserApi.kt
src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt
src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt
src/main/kotlin/org/openapitools/client/infrastructure/ApiResponse.kt
src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
src/main/kotlin/org/openapitools/client/models/Category.kt
src/main/kotlin/org/openapitools/client/models/ModelApiResponse.kt
src/main/kotlin/org/openapitools/client/models/Order.kt
src/main/kotlin/org/openapitools/client/models/Pet.kt
src/main/kotlin/org/openapitools/client/models/Tag.kt
src/main/kotlin/org/openapitools/client/models/User.kt

View File

@ -0,0 +1 @@
6.2.1-SNAPSHOT

View File

@ -0,0 +1,99 @@
# org.openapitools.client - Kotlin client library for 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.
## Overview
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate an API client.
- API version: 1.0.0
- Package version:
- Build package: org.openapitools.codegen.languages.KotlinClientCodegen
## Requires
* Kotlin 1.6.10
* Gradle 7.5
## Build
First, create the gradle wrapper script:
```
gradle wrapper
```
Then, run:
```
./gradlew check assemble
```
This runs all tests and packages the library.
## Features/Implementation Notes
* Supports JSON inputs/outputs, File inputs, and Form inputs.
* Supports collection formats for query parameters: csv, tsv, ssv, pipes.
* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in OpenAPI definitions.
* Implementation of ApiClient is intended to reduce method counts, specifically to benefit Android targets.
<a name="documentation-for-api-endpoints"></a>
## Documentation for API Endpoints
All URIs are relative to *http://petstore.swagger.io/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
*PetApi* | [**deletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
*PetApi* | [**findPetsByTags**](docs/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags
*PetApi* | [**getPetById**](docs/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID
*PetApi* | [**updatePet**](docs/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet
*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
*PetApi* | [**uploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
*StoreApi* | [**getInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
*StoreApi* | [**getOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID
*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet
*UserApi* | [**createUser**](docs/UserApi.md#createuser) | **POST** /user | Create user
*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array
*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array
*UserApi* | [**deleteUser**](docs/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user
*UserApi* | [**getUserByName**](docs/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name
*UserApi* | [**loginUser**](docs/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system
*UserApi* | [**logoutUser**](docs/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session
*UserApi* | [**updateUser**](docs/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user
<a name="documentation-for-models"></a>
## Documentation for Models
- [org.openapitools.client.models.Category](docs/Category.md)
- [org.openapitools.client.models.ModelApiResponse](docs/ModelApiResponse.md)
- [org.openapitools.client.models.Order](docs/Order.md)
- [org.openapitools.client.models.Pet](docs/Pet.md)
- [org.openapitools.client.models.Tag](docs/Tag.md)
- [org.openapitools.client.models.User](docs/User.md)
<a name="documentation-for-authorization"></a>
## Documentation for Authorization
<a name="api_key"></a>
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
<a name="petstore_auth"></a>
### petstore_auth
- **Type**: OAuth
- **Flow**: implicit
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
- **Scopes**:
- write:pets: modify pets in your account
- read:pets: read your pets

View File

@ -0,0 +1,39 @@
group 'org.openapitools'
version '1.0.0'
wrapper {
gradleVersion = '7.5'
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}
buildscript {
ext.kotlin_version = '1.6.10'
ext.vertx_version = "4.3.3"
repositories {
maven { url "https://repo1.maven.org/maven2" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'kotlin'
repositories {
maven { url "https://repo1.maven.org/maven2" }
}
test {
useJUnitPlatform()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "com.google.code.gson:gson:2.9.0"
testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
implementation "io.vertx:vertx-web-client:$vertx_version"
implementation "io.vertx:vertx-core:$vertx_version"
implementation "io.vertx:vertx-lang-kotlin:$vertx_version"
implementation "io.vertx:vertx-uri-template:$vertx_version"
}

View File

@ -0,0 +1,12 @@
# ModelApiResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**code** | **kotlin.Int** | | [optional]
**type** | **kotlin.String** | | [optional]
**message** | **kotlin.String** | | [optional]

View File

@ -0,0 +1,11 @@
# Category
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **kotlin.Long** | | [optional]
**name** | **kotlin.String** | | [optional]

View File

@ -0,0 +1,22 @@
# Order
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **kotlin.Long** | | [optional]
**petId** | **kotlin.Long** | | [optional]
**quantity** | **kotlin.Int** | | [optional]
**shipDate** | [**java.time.OffsetDateTime**](java.time.OffsetDateTime.md) | | [optional]
**status** | [**inline**](#Status) | Order Status | [optional]
**complete** | **kotlin.Boolean** | | [optional]
<a name="Status"></a>
## Enum: status
Name | Value
---- | -----
status | placed, approved, delivered

View File

@ -0,0 +1,22 @@
# Pet
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **kotlin.String** | |
**photoUrls** | **kotlin.collections.List&lt;kotlin.String&gt;** | |
**id** | **kotlin.Long** | | [optional]
**category** | [**Category**](Category.md) | | [optional]
**tags** | [**kotlin.collections.List&lt;Tag&gt;**](Tag.md) | | [optional]
**status** | [**inline**](#Status) | pet status in the store | [optional]
<a name="Status"></a>
## Enum: status
Name | Value
---- | -----
status | available, pending, sold

View File

@ -0,0 +1,417 @@
# PetApi
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store
[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet
[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID
[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet
[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
<a name="addPet"></a>
# **addPet**
> Pet addPet(pet)
Add a new pet to the store
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = PetApi()
val pet : Pet = // Pet | Pet object that needs to be added to the store
try {
val result : Pet = apiInstance.addPet(pet)
println(result)
} catch (e: ClientException) {
println("4xx response calling PetApi#addPet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#addPet")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type
[**Pet**](Pet.md)
### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers
- **Content-Type**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="deletePet"></a>
# **deletePet**
> deletePet(petId, apiKey)
Deletes a pet
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = PetApi()
val petId : kotlin.Long = 789 // kotlin.Long | Pet id to delete
val apiKey : kotlin.String = apiKey_example // kotlin.String |
try {
apiInstance.deletePet(petId, apiKey)
} catch (e: ClientException) {
println("4xx response calling PetApi#deletePet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#deletePet")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **kotlin.Long**| Pet id to delete |
**apiKey** | **kotlin.String**| | [optional]
### Return type
null (empty response body)
### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
<a name="findPetsByStatus"></a>
# **findPetsByStatus**
> kotlin.collections.List&lt;Pet&gt; findPetsByStatus(status)
Finds Pets by status
Multiple status values can be provided with comma separated strings
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = PetApi()
val status : kotlin.collections.List<kotlin.String> = // kotlin.collections.List<kotlin.String> | Status values that need to be considered for filter
try {
val result : kotlin.collections.List<Pet> = apiInstance.findPetsByStatus(status)
println(result)
} catch (e: ClientException) {
println("4xx response calling PetApi#findPetsByStatus")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#findPetsByStatus")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**status** | [**kotlin.collections.List&lt;kotlin.String&gt;**](kotlin.String.md)| Status values that need to be considered for filter | [enum: available, pending, sold]
### Return type
[**kotlin.collections.List&lt;Pet&gt;**](Pet.md)
### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
<a name="findPetsByTags"></a>
# **findPetsByTags**
> kotlin.collections.List&lt;Pet&gt; findPetsByTags(tags)
Finds Pets by tags
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = PetApi()
val tags : kotlin.collections.List<kotlin.String> = // kotlin.collections.List<kotlin.String> | Tags to filter by
try {
val result : kotlin.collections.List<Pet> = apiInstance.findPetsByTags(tags)
println(result)
} catch (e: ClientException) {
println("4xx response calling PetApi#findPetsByTags")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#findPetsByTags")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**tags** | [**kotlin.collections.List&lt;kotlin.String&gt;**](kotlin.String.md)| Tags to filter by |
### Return type
[**kotlin.collections.List&lt;Pet&gt;**](Pet.md)
### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
<a name="getPetById"></a>
# **getPetById**
> Pet getPetById(petId)
Find pet by ID
Returns a single pet
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = PetApi()
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to return
try {
val result : Pet = apiInstance.getPetById(petId)
println(result)
} catch (e: ClientException) {
println("4xx response calling PetApi#getPetById")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#getPetById")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **kotlin.Long**| ID of pet to return |
### Return type
[**Pet**](Pet.md)
### Authorization
Configure api_key:
ApiClient.apiKey["api_key"] = ""
ApiClient.apiKeyPrefix["api_key"] = ""
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
<a name="updatePet"></a>
# **updatePet**
> Pet updatePet(pet)
Update an existing pet
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = PetApi()
val pet : Pet = // Pet | Pet object that needs to be added to the store
try {
val result : Pet = apiInstance.updatePet(pet)
println(result)
} catch (e: ClientException) {
println("4xx response calling PetApi#updatePet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#updatePet")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type
[**Pet**](Pet.md)
### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers
- **Content-Type**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="updatePetWithForm"></a>
# **updatePetWithForm**
> updatePetWithForm(petId, name, status)
Updates a pet in the store with form data
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = PetApi()
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be updated
val name : kotlin.String = name_example // kotlin.String | Updated name of the pet
val status : kotlin.String = status_example // kotlin.String | Updated status of the pet
try {
apiInstance.updatePetWithForm(petId, name, status)
} catch (e: ClientException) {
println("4xx response calling PetApi#updatePetWithForm")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#updatePetWithForm")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **kotlin.Long**| ID of pet that needs to be updated |
**name** | **kotlin.String**| Updated name of the pet | [optional]
**status** | **kotlin.String**| Updated status of the pet | [optional]
### Return type
null (empty response body)
### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers
- **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined
<a name="uploadFile"></a>
# **uploadFile**
> ModelApiResponse uploadFile(petId, additionalMetadata, file)
uploads an image
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = PetApi()
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to update
val additionalMetadata : kotlin.String = additionalMetadata_example // kotlin.String | Additional data to pass to server
val file : java.io.File = BINARY_DATA_HERE // java.io.File | file to upload
try {
val result : ModelApiResponse = apiInstance.uploadFile(petId, additionalMetadata, file)
println(result)
} catch (e: ClientException) {
println("4xx response calling PetApi#uploadFile")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#uploadFile")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **kotlin.Long**| ID of pet to update |
**additionalMetadata** | **kotlin.String**| Additional data to pass to server | [optional]
**file** | **java.io.File**| file to upload | [optional]
### Return type
[**ModelApiResponse**](ModelApiResponse.md)
### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: application/json

View File

@ -0,0 +1,198 @@
# 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 name="deleteOrder"></a>
# **deleteOrder**
> deleteOrder(orderId)
Delete purchase order by ID
For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = StoreApi()
val orderId : kotlin.String = orderId_example // kotlin.String | ID of the order that needs to be deleted
try {
apiInstance.deleteOrder(orderId)
} catch (e: ClientException) {
println("4xx response calling StoreApi#deleteOrder")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling StoreApi#deleteOrder")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **kotlin.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
<a name="getInventory"></a>
# **getInventory**
> kotlin.collections.Map&lt;kotlin.String, kotlin.Int&gt; getInventory()
Returns pet inventories by status
Returns a map of status codes to quantities
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = StoreApi()
try {
val result : kotlin.collections.Map<kotlin.String, kotlin.Int> = apiInstance.getInventory()
println(result)
} catch (e: ClientException) {
println("4xx response calling StoreApi#getInventory")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling StoreApi#getInventory")
e.printStackTrace()
}
```
### Parameters
This endpoint does not need any parameter.
### Return type
**kotlin.collections.Map&lt;kotlin.String, kotlin.Int&gt;**
### Authorization
Configure api_key:
ApiClient.apiKey["api_key"] = ""
ApiClient.apiKeyPrefix["api_key"] = ""
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
<a name="getOrderById"></a>
# **getOrderById**
> Order getOrderById(orderId)
Find purchase order by ID
For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = StoreApi()
val orderId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be fetched
try {
val result : Order = apiInstance.getOrderById(orderId)
println(result)
} catch (e: ClientException) {
println("4xx response calling StoreApi#getOrderById")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling StoreApi#getOrderById")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **kotlin.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
<a name="placeOrder"></a>
# **placeOrder**
> Order placeOrder(order)
Place an order for a pet
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = StoreApi()
val order : Order = // Order | order placed for purchasing the pet
try {
val result : Order = apiInstance.placeOrder(order)
println(result)
} catch (e: ClientException) {
println("4xx response calling StoreApi#placeOrder")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling StoreApi#placeOrder")
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

View File

@ -0,0 +1,11 @@
# Tag
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **kotlin.Long** | | [optional]
**name** | **kotlin.String** | | [optional]

View File

@ -0,0 +1,17 @@
# User
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **kotlin.Long** | | [optional]
**username** | **kotlin.String** | | [optional]
**firstName** | **kotlin.String** | | [optional]
**lastName** | **kotlin.String** | | [optional]
**email** | **kotlin.String** | | [optional]
**password** | **kotlin.String** | | [optional]
**phone** | **kotlin.String** | | [optional]
**userStatus** | **kotlin.Int** | User Status | [optional]

View File

@ -0,0 +1,404 @@
# 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 name="createUser"></a>
# **createUser**
> createUser(user)
Create user
This can only be done by the logged in user.
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = UserApi()
val user : User = // User | Created user object
try {
apiInstance.createUser(user)
} catch (e: ClientException) {
println("4xx response calling UserApi#createUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#createUser")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**User**](User.md)| Created user object |
### Return type
null (empty response body)
### Authorization
Configure api_key:
ApiClient.apiKey["api_key"] = ""
ApiClient.apiKeyPrefix["api_key"] = ""
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: Not defined
<a name="createUsersWithArrayInput"></a>
# **createUsersWithArrayInput**
> createUsersWithArrayInput(user)
Creates list of users with given input array
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = UserApi()
val user : kotlin.collections.List<User> = // kotlin.collections.List<User> | List of user object
try {
apiInstance.createUsersWithArrayInput(user)
} catch (e: ClientException) {
println("4xx response calling UserApi#createUsersWithArrayInput")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#createUsersWithArrayInput")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**kotlin.collections.List&lt;User&gt;**](User.md)| List of user object |
### Return type
null (empty response body)
### Authorization
Configure api_key:
ApiClient.apiKey["api_key"] = ""
ApiClient.apiKeyPrefix["api_key"] = ""
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: Not defined
<a name="createUsersWithListInput"></a>
# **createUsersWithListInput**
> createUsersWithListInput(user)
Creates list of users with given input array
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = UserApi()
val user : kotlin.collections.List<User> = // kotlin.collections.List<User> | List of user object
try {
apiInstance.createUsersWithListInput(user)
} catch (e: ClientException) {
println("4xx response calling UserApi#createUsersWithListInput")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#createUsersWithListInput")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**kotlin.collections.List&lt;User&gt;**](User.md)| List of user object |
### Return type
null (empty response body)
### Authorization
Configure api_key:
ApiClient.apiKey["api_key"] = ""
ApiClient.apiKeyPrefix["api_key"] = ""
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: Not defined
<a name="deleteUser"></a>
# **deleteUser**
> deleteUser(username)
Delete user
This can only be done by the logged in user.
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = UserApi()
val username : kotlin.String = username_example // kotlin.String | The name that needs to be deleted
try {
apiInstance.deleteUser(username)
} catch (e: ClientException) {
println("4xx response calling UserApi#deleteUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#deleteUser")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **kotlin.String**| The name that needs to be deleted |
### Return type
null (empty response body)
### Authorization
Configure api_key:
ApiClient.apiKey["api_key"] = ""
ApiClient.apiKeyPrefix["api_key"] = ""
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
<a name="getUserByName"></a>
# **getUserByName**
> User getUserByName(username)
Get user by user name
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = UserApi()
val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing.
try {
val result : User = apiInstance.getUserByName(username)
println(result)
} catch (e: ClientException) {
println("4xx response calling UserApi#getUserByName")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#getUserByName")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **kotlin.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
<a name="loginUser"></a>
# **loginUser**
> kotlin.String loginUser(username, password)
Logs user into the system
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = UserApi()
val username : kotlin.String = username_example // kotlin.String | The user name for login
val password : kotlin.String = password_example // kotlin.String | The password for login in clear text
try {
val result : kotlin.String = apiInstance.loginUser(username, password)
println(result)
} catch (e: ClientException) {
println("4xx response calling UserApi#loginUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#loginUser")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **kotlin.String**| The user name for login |
**password** | **kotlin.String**| The password for login in clear text |
### Return type
**kotlin.String**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
<a name="logoutUser"></a>
# **logoutUser**
> logoutUser()
Logs out current logged in user session
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = UserApi()
try {
apiInstance.logoutUser()
} catch (e: ClientException) {
println("4xx response calling UserApi#logoutUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#logoutUser")
e.printStackTrace()
}
```
### Parameters
This endpoint does not need any parameter.
### Return type
null (empty response body)
### Authorization
Configure api_key:
ApiClient.apiKey["api_key"] = ""
ApiClient.apiKeyPrefix["api_key"] = ""
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
<a name="updateUser"></a>
# **updateUser**
> updateUser(username, user)
Updated user
This can only be done by the logged in user.
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = UserApi()
val username : kotlin.String = username_example // kotlin.String | name that need to be deleted
val user : User = // User | Updated user object
try {
apiInstance.updateUser(username, user)
} catch (e: ClientException) {
println("4xx response calling UserApi#updateUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#updateUser")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **kotlin.String**| name that need to be deleted |
**user** | [**User**](User.md)| Updated user object |
### Return type
null (empty response body)
### Authorization
Configure api_key:
ApiClient.apiKey["api_key"] = ""
ApiClient.apiKeyPrefix["api_key"] = ""
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: Not defined

View File

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -0,0 +1,185 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

View File

@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -0,0 +1,2 @@
rootProject.name = 'kotlin-petstore-jvm-vertx'

View File

@ -0,0 +1,591 @@
/**
*
* Please note:
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit this file manually.
*
*/
@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport"
)
package org.openapitools.client.apis
import java.io.IOException
import org.openapitools.client.models.ModelApiResponse
import org.openapitools.client.models.Pet
import com.google.gson.reflect.TypeToken
import com.google.gson.annotations.SerializedName
import io.vertx.core.Vertx
import io.vertx.core.http.RequestOptions
import io.vertx.core.http.HttpMethod
import io.vertx.core.buffer.Buffer
import io.vertx.core.Future
import io.vertx.ext.web.client.WebClient
import io.vertx.uritemplate.UriTemplate
import org.openapitools.client.infrastructure.*
@Suppress ("UNUSED")
class PetApi(basePath: kotlin.String = ApiClient.defaultBasePath, accessToken: String? = null, apiKey: MutableMap<String, String> = mutableMapOf(), apiKeyPrefix: MutableMap<String, String> = mutableMapOf(), username: String? = null, password: String? = null, vertx: Vertx): ApiClient(basePath, accessToken, apiKey, apiKeyPrefix, username, password, vertx) {
/**
* Add a new pet to the store
*
* @param pet Pet object that needs to be added to the store
* @return Pet
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun addPet(pet: Pet) : Future<Pet> {
return addPetWithHttpInfo(pet = pet).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as Pet
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Add a new pet to the store
*
* @param pet Pet object that needs to be added to the store
* @return ApiResponse<Pet?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class)
fun addPetWithHttpInfo(pet: Pet) : Future<ApiResponse<Pet?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.POST, UriTemplate.of("$basePath/pet"))
request.putHeader("Content-Type", "application/json")
request.putHeader("Content-Type", "application/xml")
request.putHeader("Accept", "application/xml, application/json")
accessToken?.let { accessToken ->
request.bearerTokenAuthentication(accessToken)
}
return request
.sendBuffer(responseBody(pet))
.map {
val apiResponse: ApiResponse<Pet?> = handleResponse(it)
apiResponse
}
}
/**
* Deletes a pet
*
* @param petId Pet id to delete
* @param apiKey (optional)
* @return void
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun deletePet(petId: kotlin.Long, apiKey: kotlin.String? = null) : Future<Unit> {
return deletePetWithHttpInfo(petId = petId, apiKey = apiKey).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> Unit
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Deletes a pet
*
* @param petId Pet id to delete
* @param apiKey (optional)
* @return ApiResponse<Unit?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Throws(IllegalStateException::class, IOException::class)
fun deletePetWithHttpInfo(petId: kotlin.Long, apiKey: kotlin.String?) : Future<ApiResponse<Unit?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.DELETE, UriTemplate.of("$basePath/pet/{petId}".replace("{"+"petId"+"}", encodeURIComponent(petId.toString()))))
apiKey?.apply { request.putHeader("api_key", this.toString())}
accessToken?.let { accessToken ->
request.bearerTokenAuthentication(accessToken)
}
return request
.send()
.map {
val apiResponse: ApiResponse<Unit?> = handleResponse(it)
apiResponse
}
}
/**
* enum for parameter status
*/
enum class Status_findPetsByStatus(val value: kotlin.String) {
@SerializedName(value = "available") available("available"),
@SerializedName(value = "pending") pending("pending"),
@SerializedName(value = "sold") sold("sold")
}
/**
* Finds Pets by status
* Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter
* @return kotlin.collections.List<Pet>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun findPetsByStatus(status: kotlin.collections.List<Status_findPetsByStatus>) : Future<kotlin.collections.List<Pet>> {
return findPetsByStatusWithHttpInfo(status = status).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.collections.List<Pet>
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Finds Pets by status
* Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter
* @return ApiResponse<kotlin.collections.List<Pet>?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class)
fun findPetsByStatusWithHttpInfo(status: kotlin.collections.List<Status_findPetsByStatus>) : Future<ApiResponse<kotlin.collections.List<Pet>?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.GET, UriTemplate.of("$basePath/pet/findByStatus"))
request.putHeader("Accept", "application/xml, application/json")
status.let { request.queryParams().add("status", toMultiValue(it.toList(), "csv")) }
accessToken?.let { accessToken ->
request.bearerTokenAuthentication(accessToken)
}
return request
.send()
.map {
val apiResponse: ApiResponse<kotlin.collections.List<Pet>?> = handleResponse(it)
apiResponse
}
}
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by
* @return kotlin.collections.List<Pet>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
@Deprecated(message = "This operation is deprecated.")
fun findPetsByTags(tags: kotlin.collections.List<kotlin.String>) : Future<kotlin.collections.List<Pet>> {
return findPetsByTagsWithHttpInfo(tags = tags).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.collections.List<Pet>
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by
* @return ApiResponse<kotlin.collections.List<Pet>?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class)
@Deprecated(message = "This operation is deprecated.")
fun findPetsByTagsWithHttpInfo(tags: kotlin.collections.List<kotlin.String>) : Future<ApiResponse<kotlin.collections.List<Pet>?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.GET, UriTemplate.of("$basePath/pet/findByTags"))
request.putHeader("Accept", "application/xml, application/json")
tags.let { request.queryParams().add("tags", toMultiValue(it.toList(), "csv")) }
accessToken?.let { accessToken ->
request.bearerTokenAuthentication(accessToken)
}
return request
.send()
.map {
val apiResponse: ApiResponse<kotlin.collections.List<Pet>?> = handleResponse(it)
apiResponse
}
}
/**
* Find pet by ID
* Returns a single pet
* @param petId ID of pet to return
* @return Pet
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun getPetById(petId: kotlin.Long) : Future<Pet> {
return getPetByIdWithHttpInfo(petId = petId).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as Pet
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Find pet by ID
* Returns a single pet
* @param petId ID of pet to return
* @return ApiResponse<Pet?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class)
fun getPetByIdWithHttpInfo(petId: kotlin.Long) : Future<ApiResponse<Pet?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.GET, UriTemplate.of("$basePath/pet/{petId}".replace("{"+"petId"+"}", encodeURIComponent(petId.toString()))))
request.putHeader("Accept", "application/xml, application/json")
if (apiKey["api_key"] != null) {
if (apiKeyPrefix["api_key"] != null) {
request.putHeader("api_key", apiKeyPrefix["api_key"]!! + " " + apiKey["api_key"]!!)
} else {
request.putHeader("api_key", apiKey["api_key"]!!)
}
}
return request
.send()
.map {
val apiResponse: ApiResponse<Pet?> = handleResponse(it)
apiResponse
}
}
/**
* Update an existing pet
*
* @param pet Pet object that needs to be added to the store
* @return Pet
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun updatePet(pet: Pet) : Future<Pet> {
return updatePetWithHttpInfo(pet = pet).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as Pet
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Update an existing pet
*
* @param pet Pet object that needs to be added to the store
* @return ApiResponse<Pet?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class)
fun updatePetWithHttpInfo(pet: Pet) : Future<ApiResponse<Pet?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.PUT, UriTemplate.of("$basePath/pet"))
request.putHeader("Content-Type", "application/json")
request.putHeader("Content-Type", "application/xml")
request.putHeader("Accept", "application/xml, application/json")
accessToken?.let { accessToken ->
request.bearerTokenAuthentication(accessToken)
}
return request
.sendBuffer(responseBody(pet))
.map {
val apiResponse: ApiResponse<Pet?> = handleResponse(it)
apiResponse
}
}
/**
* Updates a pet in the store with form data
*
* @param petId ID of pet that needs to be updated
* @param name Updated name of the pet (optional)
* @param status Updated status of the pet (optional)
* @return void
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String? = null, status: kotlin.String? = null) : Future<Unit> {
return updatePetWithFormWithHttpInfo(petId = petId, name = name, status = status).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> Unit
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Updates a pet in the store with form data
*
* @param petId ID of pet that needs to be updated
* @param name Updated name of the pet (optional)
* @param status Updated status of the pet (optional)
* @return ApiResponse<Unit?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Throws(IllegalStateException::class, IOException::class)
fun updatePetWithFormWithHttpInfo(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?) : Future<ApiResponse<Unit?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.POST, UriTemplate.of("$basePath/pet/{petId}".replace("{"+"petId"+"}", encodeURIComponent(petId.toString()))))
request.putHeader("Content-Type", "application/x-www-form-urlencoded")
val form = io.vertx.core.MultiMap.caseInsensitiveMultiMap();
name?.let { form.add("name", name) }
status?.let { form.add("status", status) }
accessToken?.let { accessToken ->
request.bearerTokenAuthentication(accessToken)
}
return request
.send()
.map {
val apiResponse: ApiResponse<Unit?> = handleResponse(it)
apiResponse
}
}
/**
* uploads an image
*
* @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server (optional)
* @param file file to upload (optional)
* @return ModelApiResponse
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String? = null, file: java.io.File? = null) : Future<ModelApiResponse> {
return uploadFileWithHttpInfo(petId = petId, additionalMetadata = additionalMetadata, file = file).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as ModelApiResponse
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* uploads an image
*
* @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server (optional)
* @param file file to upload (optional)
* @return ApiResponse<ModelApiResponse?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class)
fun uploadFileWithHttpInfo(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: java.io.File?) : Future<ApiResponse<ModelApiResponse?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.POST, UriTemplate.of("$basePath/pet/{petId}/uploadImage".replace("{"+"petId"+"}", encodeURIComponent(petId.toString()))))
request.putHeader("Content-Type", "multipart/form-data")
request.putHeader("Accept", "application/json")
val form = io.vertx.core.MultiMap.caseInsensitiveMultiMap();
additionalMetadata?.let { form.add("additionalMetadata", additionalMetadata) }
file?.let { form.add("file", file.toString()) }
accessToken?.let { accessToken ->
request.bearerTokenAuthentication(accessToken)
}
return request
.send()
.map {
val apiResponse: ApiResponse<ModelApiResponse?> = handleResponse(it)
apiResponse
}
}
private inline fun <reified T: Any?> responseBody(body: T): Buffer {
return Buffer.buffer(Serializer.gson.toJson(body, T::class.java))
}
}

View File

@ -0,0 +1,292 @@
/**
*
* Please note:
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit this file manually.
*
*/
@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport"
)
package org.openapitools.client.apis
import java.io.IOException
import org.openapitools.client.models.Order
import com.google.gson.reflect.TypeToken
import com.google.gson.annotations.SerializedName
import io.vertx.core.Vertx
import io.vertx.core.http.RequestOptions
import io.vertx.core.http.HttpMethod
import io.vertx.core.buffer.Buffer
import io.vertx.core.Future
import io.vertx.ext.web.client.WebClient
import io.vertx.uritemplate.UriTemplate
import org.openapitools.client.infrastructure.*
@Suppress ("UNUSED")
class StoreApi(basePath: kotlin.String = ApiClient.defaultBasePath, accessToken: String? = null, apiKey: MutableMap<String, String> = mutableMapOf(), apiKeyPrefix: MutableMap<String, String> = mutableMapOf(), username: String? = null, password: String? = null, vertx: Vertx): ApiClient(basePath, accessToken, apiKey, apiKeyPrefix, username, password, vertx) {
/**
* Delete purchase order by ID
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
* @param orderId ID of the order that needs to be deleted
* @return void
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun deleteOrder(orderId: kotlin.String) : Future<Unit> {
return deleteOrderWithHttpInfo(orderId = orderId).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> Unit
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Delete purchase order by ID
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
* @param orderId ID of the order that needs to be deleted
* @return ApiResponse<Unit?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Throws(IllegalStateException::class, IOException::class)
fun deleteOrderWithHttpInfo(orderId: kotlin.String) : Future<ApiResponse<Unit?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.DELETE, UriTemplate.of("$basePath/store/order/{orderId}".replace("{"+"orderId"+"}", encodeURIComponent(orderId.toString()))))
return request
.send()
.map {
val apiResponse: ApiResponse<Unit?> = handleResponse(it)
apiResponse
}
}
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
* @return kotlin.collections.Map<kotlin.String, kotlin.Int>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun getInventory() : Future<kotlin.collections.Map<kotlin.String, kotlin.Int>> {
return getInventoryWithHttpInfo().map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.collections.Map<kotlin.String, kotlin.Int>
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
* @return ApiResponse<kotlin.collections.Map<kotlin.String, kotlin.Int>?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class)
fun getInventoryWithHttpInfo() : Future<ApiResponse<kotlin.collections.Map<kotlin.String, kotlin.Int>?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.GET, UriTemplate.of("$basePath/store/inventory"))
request.putHeader("Accept", "application/json")
if (apiKey["api_key"] != null) {
if (apiKeyPrefix["api_key"] != null) {
request.putHeader("api_key", apiKeyPrefix["api_key"]!! + " " + apiKey["api_key"]!!)
} else {
request.putHeader("api_key", apiKey["api_key"]!!)
}
}
return request
.send()
.map {
val apiResponse: ApiResponse<kotlin.collections.Map<kotlin.String, kotlin.Int>?> = handleResponse(it)
apiResponse
}
}
/**
* Find purchase order by ID
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched
* @return Order
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun getOrderById(orderId: kotlin.Long) : Future<Order> {
return getOrderByIdWithHttpInfo(orderId = orderId).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as Order
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Find purchase order by ID
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched
* @return ApiResponse<Order?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class)
fun getOrderByIdWithHttpInfo(orderId: kotlin.Long) : Future<ApiResponse<Order?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.GET, UriTemplate.of("$basePath/store/order/{orderId}".replace("{"+"orderId"+"}", encodeURIComponent(orderId.toString()))))
request.putHeader("Accept", "application/xml, application/json")
return request
.send()
.map {
val apiResponse: ApiResponse<Order?> = handleResponse(it)
apiResponse
}
}
/**
* Place an order for a pet
*
* @param order order placed for purchasing the pet
* @return Order
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun placeOrder(order: Order) : Future<Order> {
return placeOrderWithHttpInfo(order = order).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as Order
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Place an order for a pet
*
* @param order order placed for purchasing the pet
* @return ApiResponse<Order?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class)
fun placeOrderWithHttpInfo(order: Order) : Future<ApiResponse<Order?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.POST, UriTemplate.of("$basePath/store/order"))
request.putHeader("Content-Type", "application/json")
request.putHeader("Accept", "application/xml, application/json")
return request
.sendBuffer(responseBody(order))
.map {
val apiResponse: ApiResponse<Order?> = handleResponse(it)
apiResponse
}
}
private inline fun <reified T: Any?> responseBody(body: T): Buffer {
return Buffer.buffer(Serializer.gson.toJson(body, T::class.java))
}
}

View File

@ -0,0 +1,573 @@
/**
*
* Please note:
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit this file manually.
*
*/
@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport"
)
package org.openapitools.client.apis
import java.io.IOException
import org.openapitools.client.models.User
import com.google.gson.reflect.TypeToken
import com.google.gson.annotations.SerializedName
import io.vertx.core.Vertx
import io.vertx.core.http.RequestOptions
import io.vertx.core.http.HttpMethod
import io.vertx.core.buffer.Buffer
import io.vertx.core.Future
import io.vertx.ext.web.client.WebClient
import io.vertx.uritemplate.UriTemplate
import org.openapitools.client.infrastructure.*
@Suppress ("UNUSED")
class UserApi(basePath: kotlin.String = ApiClient.defaultBasePath, accessToken: String? = null, apiKey: MutableMap<String, String> = mutableMapOf(), apiKeyPrefix: MutableMap<String, String> = mutableMapOf(), username: String? = null, password: String? = null, vertx: Vertx): ApiClient(basePath, accessToken, apiKey, apiKeyPrefix, username, password, vertx) {
/**
* Create user
* This can only be done by the logged in user.
* @param user Created user object
* @return void
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun createUser(user: User) : Future<Unit> {
return createUserWithHttpInfo(user = user).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> Unit
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Create user
* This can only be done by the logged in user.
* @param user Created user object
* @return ApiResponse<Unit?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Throws(IllegalStateException::class, IOException::class)
fun createUserWithHttpInfo(user: User) : Future<ApiResponse<Unit?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.POST, UriTemplate.of("$basePath/user"))
request.putHeader("Content-Type", "application/json")
if (apiKey["api_key"] != null) {
if (apiKeyPrefix["api_key"] != null) {
request.putHeader("api_key", apiKeyPrefix["api_key"]!! + " " + apiKey["api_key"]!!)
} else {
request.putHeader("api_key", apiKey["api_key"]!!)
}
}
return request
.sendBuffer(responseBody(user))
.map {
val apiResponse: ApiResponse<Unit?> = handleResponse(it)
apiResponse
}
}
/**
* Creates list of users with given input array
*
* @param user List of user object
* @return void
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun createUsersWithArrayInput(user: kotlin.collections.List<User>) : Future<Unit> {
return createUsersWithArrayInputWithHttpInfo(user = user).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> Unit
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Creates list of users with given input array
*
* @param user List of user object
* @return ApiResponse<Unit?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Throws(IllegalStateException::class, IOException::class)
fun createUsersWithArrayInputWithHttpInfo(user: kotlin.collections.List<User>) : Future<ApiResponse<Unit?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.POST, UriTemplate.of("$basePath/user/createWithArray"))
request.putHeader("Content-Type", "application/json")
if (apiKey["api_key"] != null) {
if (apiKeyPrefix["api_key"] != null) {
request.putHeader("api_key", apiKeyPrefix["api_key"]!! + " " + apiKey["api_key"]!!)
} else {
request.putHeader("api_key", apiKey["api_key"]!!)
}
}
return request
.sendBuffer(responseBody(user))
.map {
val apiResponse: ApiResponse<Unit?> = handleResponse(it)
apiResponse
}
}
/**
* Creates list of users with given input array
*
* @param user List of user object
* @return void
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun createUsersWithListInput(user: kotlin.collections.List<User>) : Future<Unit> {
return createUsersWithListInputWithHttpInfo(user = user).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> Unit
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Creates list of users with given input array
*
* @param user List of user object
* @return ApiResponse<Unit?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Throws(IllegalStateException::class, IOException::class)
fun createUsersWithListInputWithHttpInfo(user: kotlin.collections.List<User>) : Future<ApiResponse<Unit?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.POST, UriTemplate.of("$basePath/user/createWithList"))
request.putHeader("Content-Type", "application/json")
if (apiKey["api_key"] != null) {
if (apiKeyPrefix["api_key"] != null) {
request.putHeader("api_key", apiKeyPrefix["api_key"]!! + " " + apiKey["api_key"]!!)
} else {
request.putHeader("api_key", apiKey["api_key"]!!)
}
}
return request
.sendBuffer(responseBody(user))
.map {
val apiResponse: ApiResponse<Unit?> = handleResponse(it)
apiResponse
}
}
/**
* Delete user
* This can only be done by the logged in user.
* @param username The name that needs to be deleted
* @return void
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun deleteUser(username: kotlin.String) : Future<Unit> {
return deleteUserWithHttpInfo(username = username).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> Unit
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Delete user
* This can only be done by the logged in user.
* @param username The name that needs to be deleted
* @return ApiResponse<Unit?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Throws(IllegalStateException::class, IOException::class)
fun deleteUserWithHttpInfo(username: kotlin.String) : Future<ApiResponse<Unit?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.DELETE, UriTemplate.of("$basePath/user/{username}".replace("{"+"username"+"}", encodeURIComponent(username.toString()))))
if (apiKey["api_key"] != null) {
if (apiKeyPrefix["api_key"] != null) {
request.putHeader("api_key", apiKeyPrefix["api_key"]!! + " " + apiKey["api_key"]!!)
} else {
request.putHeader("api_key", apiKey["api_key"]!!)
}
}
return request
.send()
.map {
val apiResponse: ApiResponse<Unit?> = handleResponse(it)
apiResponse
}
}
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @return User
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun getUserByName(username: kotlin.String) : Future<User> {
return getUserByNameWithHttpInfo(username = username).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as User
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @return ApiResponse<User?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class)
fun getUserByNameWithHttpInfo(username: kotlin.String) : Future<ApiResponse<User?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.GET, UriTemplate.of("$basePath/user/{username}".replace("{"+"username"+"}", encodeURIComponent(username.toString()))))
request.putHeader("Accept", "application/xml, application/json")
return request
.send()
.map {
val apiResponse: ApiResponse<User?> = handleResponse(it)
apiResponse
}
}
/**
* Logs user into the system
*
* @param username The user name for login
* @param password The password for login in clear text
* @return kotlin.String
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun loginUser(username: kotlin.String, password: kotlin.String) : Future<kotlin.String> {
return loginUserWithHttpInfo(username = username, password = password).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.String
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Logs user into the system
*
* @param username The user name for login
* @param password The password for login in clear text
* @return ApiResponse<kotlin.String?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class)
fun loginUserWithHttpInfo(username: kotlin.String, password: kotlin.String) : Future<ApiResponse<kotlin.String?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.GET, UriTemplate.of("$basePath/user/login"))
request.putHeader("Accept", "application/xml, application/json")
username.let { request.queryParams().add("username", listOf(it.toString())) }
password.let { request.queryParams().add("password", listOf(it.toString())) }
return request
.send()
.map {
val apiResponse: ApiResponse<kotlin.String?> = handleResponse(it)
apiResponse
}
}
/**
* Logs out current logged in user session
*
* @return void
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun logoutUser() : Future<Unit> {
return logoutUserWithHttpInfo().map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> Unit
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Logs out current logged in user session
*
* @return ApiResponse<Unit?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Throws(IllegalStateException::class, IOException::class)
fun logoutUserWithHttpInfo() : Future<ApiResponse<Unit?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.GET, UriTemplate.of("$basePath/user/logout"))
if (apiKey["api_key"] != null) {
if (apiKeyPrefix["api_key"] != null) {
request.putHeader("api_key", apiKeyPrefix["api_key"]!! + " " + apiKey["api_key"]!!)
} else {
request.putHeader("api_key", apiKey["api_key"]!!)
}
}
return request
.send()
.map {
val apiResponse: ApiResponse<Unit?> = handleResponse(it)
apiResponse
}
}
/**
* Updated user
* This can only be done by the logged in user.
* @param username name that need to be deleted
* @param user Updated user object
* @return void
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun updateUser(username: kotlin.String, user: User) : Future<Unit> {
return updateUserWithHttpInfo(username = username, user = user).map { localVarResponse ->
when (localVarResponse.responseType) {
ResponseType.Success -> Unit
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
}
/**
* Updated user
* This can only be done by the logged in user.
* @param username name that need to be deleted
* @param user Updated user object
* @return ApiResponse<Unit?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Throws(IllegalStateException::class, IOException::class)
fun updateUserWithHttpInfo(username: kotlin.String, user: User) : Future<ApiResponse<Unit?>> {
val vertxClient = WebClient.create(vertx)
val request = vertxClient.requestAbs(HttpMethod.PUT, UriTemplate.of("$basePath/user/{username}".replace("{"+"username"+"}", encodeURIComponent(username.toString()))))
request.putHeader("Content-Type", "application/json")
if (apiKey["api_key"] != null) {
if (apiKeyPrefix["api_key"] != null) {
request.putHeader("api_key", apiKeyPrefix["api_key"]!! + " " + apiKey["api_key"]!!)
} else {
request.putHeader("api_key", apiKey["api_key"]!!)
}
}
return request
.sendBuffer(responseBody(user))
.map {
val apiResponse: ApiResponse<Unit?> = handleResponse(it)
apiResponse
}
}
private inline fun <reified T: Any?> responseBody(body: T): Buffer {
return Buffer.buffer(Serializer.gson.toJson(body, T::class.java))
}
}

View File

@ -0,0 +1,23 @@
package org.openapitools.client.infrastructure
typealias MultiValueMap = MutableMap<String,List<String>>
fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
"csv" -> ","
"tsv" -> "\t"
"pipe" -> "|"
"space" -> " "
else -> ""
}
val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
fun <T : Any?> toMultiValue(items: Array<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter)
= toMultiValue(items.asIterable(), collectionFormat, map)
fun <T : Any?> toMultiValue(items: Iterable<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List<String> {
return when(collectionFormat) {
"multi" -> items.map(map)
else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map))
}
}

View File

@ -0,0 +1,86 @@
package org.openapitools.client.infrastructure
import io.vertx.core.Vertx
import io.vertx.core.buffer.Buffer
import java.nio.charset.StandardCharsets
import com.google.gson.reflect.TypeToken
open class ApiClient(val basePath: kotlin.String = defaultBasePath, val accessToken: String? = null, val apiKey: MutableMap<String, String> = mutableMapOf(), val apiKeyPrefix: MutableMap<String, String> = mutableMapOf(), var username: String? = null, var password: String? = null, val vertx: Vertx) {
companion object {
const val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty(baseUrlKey, "http://petstore.swagger.io/v2")
}
}
protected inline fun <reified T: Any?> handleResponse(response: io.vertx.ext.web.client.HttpResponse<Buffer>): ApiResponse<T?> {
val code = response.statusCode()
val headers = response.headers().associate { it.key to listOf(it.value) }
val contentType = headers["Content-Type"]?.firstOrNull()?.substringBefore(";")?.lowercase(java.util.Locale.getDefault())
return when (code) {
in 100..199 -> Informational(
response.statusMessage(),
code,
headers
)
in 200 .. 299 -> Success(
responseBody<T>(response.body(), contentType),
code,
headers
)
in 300..399 -> Redirection(
code,
headers
)
in 400..499 -> ClientError(
response.statusMessage(),
response.bodyAsString(),
code,
headers
)
else -> ServerError(
response.statusMessage(),
response.bodyAsString(),
code,
headers
)
}
}
protected inline fun <reified T: Any?> responseBody(body: Buffer?, mediaType: String? = "application/json"): T? {
body ?: return null
val bodyContent = String(body.bytes, StandardCharsets.UTF_8)
if (bodyContent.isEmpty()) {
return null
}
return when {
mediaType==null || (mediaType.startsWith("application/") && mediaType.endsWith("json")) ->
Serializer.gson.fromJson(bodyContent, (object: TypeToken<T>(){}).getType())
else -> throw UnsupportedOperationException("responseBody currently only supports JSON body.")
}
}
protected fun encodeURIComponent(parameter: String): String {
return try {
java.net.URLEncoder.encode(parameter, java.nio.charset.StandardCharsets.UTF_8.name())
} catch (e: java.io.UnsupportedEncodingException) {
parameter
}
}
protected inline fun <reified T: Any> parseDateToQueryString(value : T): String {
/*
.replace("\"", "") converts the json object string to an actual string for the query parameter.
The moshi or gson adapter allows a more generic solution instead of trying to use a native
formatter. It also easily allows to provide a simple way to define a custom date format pattern
inside a gson/moshi adapter.
*/
return Serializer.gson.toJson(value, T::class.java).replace("\"", "")
}
}

View File

@ -0,0 +1,43 @@
package org.openapitools.client.infrastructure
enum class ResponseType {
Success, Informational, Redirection, ClientError, ServerError
}
interface Response
abstract class ApiResponse<T>(val responseType: ResponseType): Response {
abstract val statusCode: Int
abstract val headers: Map<String,List<String>>
}
class Success<T>(
val data: T,
override val statusCode: Int = -1,
override val headers: Map<String, List<String>> = mapOf()
): ApiResponse<T>(ResponseType.Success)
class Informational<T>(
val statusText: String,
override val statusCode: Int = -1,
override val headers: Map<String, List<String>> = mapOf()
) : ApiResponse<T>(ResponseType.Informational)
class Redirection<T>(
override val statusCode: Int = -1,
override val headers: Map<String, List<String>> = mapOf()
) : ApiResponse<T>(ResponseType.Redirection)
class ClientError<T>(
val message: String? = null,
val body: Any? = null,
override val statusCode: Int = -1,
override val headers: Map<String, List<String>> = mapOf()
) : ApiResponse<T>(ResponseType.ClientError)
class ServerError<T>(
val message: String? = null,
val body: Any? = null,
override val statusCode: Int = -1,
override val headers: Map<String, List<String>>
): ApiResponse<T>(ResponseType.ServerError)

View File

@ -0,0 +1,33 @@
package org.openapitools.client.infrastructure
import com.google.gson.TypeAdapter
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonWriter
import com.google.gson.stream.JsonToken.NULL
import java.io.IOException
class ByteArrayAdapter : TypeAdapter<ByteArray>() {
@Throws(IOException::class)
override fun write(out: JsonWriter?, value: ByteArray?) {
if (value == null) {
out?.nullValue()
} else {
out?.value(String(value))
}
}
@Throws(IOException::class)
override fun read(out: JsonReader?): ByteArray? {
out ?: return null
when (out.peek()) {
NULL -> {
out.nextNull()
return null
}
else -> {
return out.nextString().toByteArray()
}
}
}
}

View File

@ -0,0 +1,18 @@
@file:Suppress("unused")
package org.openapitools.client.infrastructure
import java.lang.RuntimeException
open class ClientException(message: kotlin.String? = null, val statusCode: Int = -1, val response: Response? = null) : RuntimeException(message) {
companion object {
private const val serialVersionUID: Long = 123L
}
}
open class ServerException(message: kotlin.String? = null, val statusCode: Int = -1, val response: Response? = null) : RuntimeException(message) {
companion object {
private const val serialVersionUID: Long = 456L
}
}

View File

@ -0,0 +1,35 @@
package org.openapitools.client.infrastructure
import com.google.gson.TypeAdapter
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonWriter
import com.google.gson.stream.JsonToken.NULL
import java.io.IOException
import java.time.LocalDate
import java.time.format.DateTimeFormatter
class LocalDateAdapter(private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE) : TypeAdapter<LocalDate>() {
@Throws(IOException::class)
override fun write(out: JsonWriter?, value: LocalDate?) {
if (value == null) {
out?.nullValue()
} else {
out?.value(formatter.format(value))
}
}
@Throws(IOException::class)
override fun read(out: JsonReader?): LocalDate? {
out ?: return null
when (out.peek()) {
NULL -> {
out.nextNull()
return null
}
else -> {
return LocalDate.parse(out.nextString(), formatter)
}
}
}
}

View File

@ -0,0 +1,35 @@
package org.openapitools.client.infrastructure
import com.google.gson.TypeAdapter
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonWriter
import com.google.gson.stream.JsonToken.NULL
import java.io.IOException
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
class LocalDateTimeAdapter(private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME) : TypeAdapter<LocalDateTime>() {
@Throws(IOException::class)
override fun write(out: JsonWriter?, value: LocalDateTime?) {
if (value == null) {
out?.nullValue()
} else {
out?.value(formatter.format(value))
}
}
@Throws(IOException::class)
override fun read(out: JsonReader?): LocalDateTime? {
out ?: return null
when (out.peek()) {
NULL -> {
out.nextNull()
return null
}
else -> {
return LocalDateTime.parse(out.nextString(), formatter)
}
}
}
}

View File

@ -0,0 +1,35 @@
package org.openapitools.client.infrastructure
import com.google.gson.TypeAdapter
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonWriter
import com.google.gson.stream.JsonToken.NULL
import java.io.IOException
import java.time.OffsetDateTime
import java.time.format.DateTimeFormatter
class OffsetDateTimeAdapter(private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME) : TypeAdapter<OffsetDateTime>() {
@Throws(IOException::class)
override fun write(out: JsonWriter?, value: OffsetDateTime?) {
if (value == null) {
out?.nullValue()
} else {
out?.value(formatter.format(value))
}
}
@Throws(IOException::class)
override fun read(out: JsonReader?): OffsetDateTime? {
out ?: return null
when (out.peek()) {
NULL -> {
out.nextNull()
return null
}
else -> {
return OffsetDateTime.parse(out.nextString(), formatter)
}
}
}
}

View File

@ -0,0 +1,22 @@
package org.openapitools.client.infrastructure
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.OffsetDateTime
import java.util.UUID
object Serializer {
@JvmStatic
val gsonBuilder: GsonBuilder = GsonBuilder()
.registerTypeAdapter(OffsetDateTime::class.java, OffsetDateTimeAdapter())
.registerTypeAdapter(LocalDateTime::class.java, LocalDateTimeAdapter())
.registerTypeAdapter(LocalDate::class.java, LocalDateAdapter())
.registerTypeAdapter(ByteArray::class.java, ByteArrayAdapter())
@JvmStatic
val gson: Gson by lazy {
gsonBuilder.create()
}
}

View File

@ -0,0 +1,38 @@
/**
*
* Please note:
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit this file manually.
*
*/
@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport"
)
package org.openapitools.client.models
import com.google.gson.annotations.SerializedName
/**
* A category for a pet
*
* @param id
* @param name
*/
data class Category (
@SerializedName("id")
val id: kotlin.Long? = null,
@SerializedName("name")
val name: kotlin.String? = null
)

View File

@ -0,0 +1,42 @@
/**
*
* Please note:
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit this file manually.
*
*/
@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport"
)
package org.openapitools.client.models
import com.google.gson.annotations.SerializedName
/**
* Describes the result of uploading an image resource
*
* @param code
* @param type
* @param message
*/
data class ModelApiResponse (
@SerializedName("code")
val code: kotlin.Int? = null,
@SerializedName("type")
val type: kotlin.String? = null,
@SerializedName("message")
val message: kotlin.String? = null
)

Some files were not shown because too many files have changed in this diff Show More