Enhancement/kotlin/apiclient and auth (#6585)

* Add multiple auth methods to ApiClient. ApiClient more configurable

* Fixed missing close tag for isMultipart in api.mustache

* Generated samples ./bin/kotlin-client-all.sh

* Generated samples./bin/openapi3/kotlin-client-petstore-all.sh

* Use of better way to add supporting files based on conditions

* Fixed missing check for retrofit generating auth files

* Generated samples

Co-authored-by: Alexander Karkossa <alexander.karkossa@dataport.de>
This commit is contained in:
Alexander Karkossa
2020-06-11 16:09:13 +02:00
committed by GitHub
parent 3b9cb14025
commit 2128f2875e
131 changed files with 5844 additions and 2516 deletions

View File

@@ -17,6 +17,7 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants; import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.CodegenModel;
@@ -28,6 +29,7 @@ import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.meta.features.*; import org.openapitools.codegen.meta.features.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.openapitools.codegen.utils.ProcessUtils;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
@@ -68,6 +70,8 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
// (mustache does not allow for boolean operators so we need this extra field) // (mustache does not allow for boolean operators so we need this extra field)
protected boolean doNotUseRxAndCoroutines = true; protected boolean doNotUseRxAndCoroutines = true;
protected String authFolder;
public enum DateLibrary { public enum DateLibrary {
STRING("string"), STRING("string"),
THREETENBP("threetenbp"), THREETENBP("threetenbp"),
@@ -300,6 +304,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
// infrastructure destination folder // infrastructure destination folder
final String infrastructureFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", "/"); final String infrastructureFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", "/");
authFolder = (sourceFolder + File.separator + packageName + File.separator + "auth").replace(".", "/");
// additional properties // additional properties
if (additionalProperties.containsKey(DATE_LIBRARY)) { if (additionalProperties.containsKey(DATE_LIBRARY)) {
@@ -339,6 +344,23 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
typeMapping.put("list", "kotlin.collections.List"); typeMapping.put("list", "kotlin.collections.List");
additionalProperties.put("isList", true); additionalProperties.put("isList", true);
} }
if(usesRetrofit2Library()) {
if (ProcessUtils.hasOAuthMethods(openAPI)) {
supportingFiles.add(new SupportingFile("auth/ApiKeyAuth.kt.mustache", authFolder, "ApiKeyAuth.kt"));
supportingFiles.add(new SupportingFile("auth/OAuth.kt.mustache", authFolder, "OAuth.kt"));
supportingFiles.add(new SupportingFile("auth/OAuthFlow.kt.mustache", authFolder, "OAuthFlow.kt"));
supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.kt.mustache", authFolder, "OAuthOkHttpClient.kt"));
}
if(ProcessUtils.hasHttpBearerMethods(openAPI)) {
supportingFiles.add(new SupportingFile("auth/HttpBearerAuth.kt.mustache", authFolder, "HttpBearerAuth.kt"));
}
if(ProcessUtils.hasHttpBasicMethods(openAPI)) {
supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.kt.mustache", authFolder, "HttpBasicAuth.kt"));
}
}
} }
private void processDateLibrary() { private void processDateLibrary() {
@@ -403,6 +425,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
additionalProperties.put(JVM, true); additionalProperties.put(JVM, true);
additionalProperties.put(JVM_RETROFIT2, true); additionalProperties.put(JVM_RETROFIT2, true);
supportingFiles.add(new SupportingFile("infrastructure/ApiClient.kt.mustache", infrastructureFolder, "ApiClient.kt")); supportingFiles.add(new SupportingFile("infrastructure/ApiClient.kt.mustache", infrastructureFolder, "ApiClient.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ResponseExt.kt.mustache", infrastructureFolder, "ResponseExt.kt"));
supportingFiles.add(new SupportingFile("infrastructure/CollectionFormats.kt.mustache", infrastructureFolder, "CollectionFormats.kt")); supportingFiles.add(new SupportingFile("infrastructure/CollectionFormats.kt.mustache", infrastructureFolder, "CollectionFormats.kt"));
addSupportingSerializerAdapters(infrastructureFolder); addSupportingSerializerAdapters(infrastructureFolder);
} }
@@ -494,7 +517,6 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
supportingFiles.add(new SupportingFile("infrastructure/OctetByteArray.kt.mustache", infrastructureFolder, "OctetByteArray.kt")); supportingFiles.add(new SupportingFile("infrastructure/OctetByteArray.kt.mustache", infrastructureFolder, "OctetByteArray.kt"));
// multiplatform specific auth // multiplatform specific auth
final String authFolder = (sourceFolder + File.separator + packageName + File.separator + "auth").replace(".", "/");
supportingFiles.add(new SupportingFile("auth/ApiKeyAuth.kt.mustache", authFolder, "ApiKeyAuth.kt")); supportingFiles.add(new SupportingFile("auth/ApiKeyAuth.kt.mustache", authFolder, "ApiKeyAuth.kt"));
supportingFiles.add(new SupportingFile("auth/Authentication.kt.mustache", authFolder, "Authentication.kt")); supportingFiles.add(new SupportingFile("auth/Authentication.kt.mustache", authFolder, "Authentication.kt"));
supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.kt.mustache", authFolder, "HttpBasicAuth.kt")); supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.kt.mustache", authFolder, "HttpBasicAuth.kt"));
@@ -558,6 +580,10 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
return objects; return objects;
} }
private boolean usesRetrofit2Library() {
return getLibrary() != null && getLibrary().contains(JVM_RETROFIT2);
}
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) { public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
@@ -574,6 +600,10 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
} }
} }
if (usesRetrofit2Library() && StringUtils.isNotEmpty(operation.path) && operation.path.startsWith("/")) {
operation.path = operation.path.substring(1);
}
// modify the data type of binary form parameters to a more friendly type for multiplatform builds // modify the data type of binary form parameters to a more friendly type for multiplatform builds
if (MULTIPLATFORM.equals(getLibrary()) && operation.allParams != null) { if (MULTIPLATFORM.equals(getLibrary()) && operation.allParams != null) {
for (CodegenParameter param : operation.allParams) { for (CodegenParameter param : operation.allParams) {

View File

@@ -3,6 +3,7 @@ package org.openapitools.codegen.utils;
import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.security.SecurityScheme; import io.swagger.v3.oas.models.security.SecurityScheme;
import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenProperty; import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenSecurity; import org.openapitools.codegen.CodegenSecurity;
@@ -81,7 +82,7 @@ public class ProcessUtils {
} }
/** /**
* Returns true if the specified OAS model has at least one operation with the HTTP signature * Returns true if the specified OAS model has at least one operation with the HTTP basic
* security scheme. * security scheme.
* The HTTP signature scheme is defined in https://datatracker.ietf.org/doc/draft-cavage-http-signatures/ * The HTTP signature scheme is defined in https://datatracker.ietf.org/doc/draft-cavage-http-signatures/
* *

View File

@@ -3,7 +3,7 @@
## Requires ## Requires
{{#jvm}} {{#jvm}}
* Kotlin 1.3.41 * Kotlin 1.3.61
* Gradle 4.9 * Gradle 4.9
{{/jvm}} {{/jvm}}
{{#multiplatform}} {{#multiplatform}}

View File

@@ -41,6 +41,9 @@ test {
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
{{#hasOAuthMethods}}
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0"
{{/hasOAuthMethods}}
{{#moshi}} {{#moshi}}
{{^moshiCodeGen}} {{^moshiCodeGen}}
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
@@ -81,6 +84,7 @@ dependencies {
{{/modeCodeGen}} {{/modeCodeGen}}
{{/moshi}} {{/moshi}}
compile "com.squareup.okhttp3:okhttp:4.2.2" compile "com.squareup.okhttp3:okhttp:4.2.2"
compile "com.squareup.okhttp3:logging-interceptor:4.4.0"
{{/jvm-okhttp4}} {{/jvm-okhttp4}}
{{#threetenbp}} {{#threetenbp}}
compile "org.threeten:threetenbp:1.4.0" compile "org.threeten:threetenbp:1.4.0"

View File

@@ -5,9 +5,18 @@ import retrofit2.http.*
{{#doNotUseRxAndCoroutines}} {{#doNotUseRxAndCoroutines}}
import retrofit2.Call import retrofit2.Call
{{/doNotUseRxAndCoroutines}} {{/doNotUseRxAndCoroutines}}
{{^doNotUseRxAndCoroutines}}
{{#useCoroutines}}
import retrofit2.Response
{{/useCoroutines}}
{{/doNotUseRxAndCoroutines}}
import okhttp3.RequestBody import okhttp3.RequestBody
{{#isResponseFile}}
import okhttp3.ResponseBody import okhttp3.ResponseBody
{{/isResponseFile}}
{{#isMultipart}}
import okhttp3.MultipartBody import okhttp3.MultipartBody
{{/isMultipart}}
{{^doNotUseRxAndCoroutines}} {{^doNotUseRxAndCoroutines}}
{{#useRxJava}} {{#useRxJava}}
import rx.Observable import rx.Observable
@@ -28,6 +37,17 @@ import io.reactivex.Completable
{{#operations}} {{#operations}}
interface {{classname}} { interface {{classname}} {
{{#operation}} {{#operation}}
/**
* {{summary}}
* {{notes}}
* Responses:{{#responses}}
* - {{code}}: {{{message}}}{{/responses}}
*
{{#allParams}}
* @param {{paramName}} {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}}
* @return {{^useCoroutines}}[Call]<{{/useCoroutines}}{{#isResponseFile}}[ResponseBody]{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}[{{{returnType}}}]{{/returnType}}{{^returnType}}[Unit]{{/returnType}}{{/isResponseFile}}{{^useCoroutines}}>{{/useCoroutines}}
*/
{{#isDeprecated}} {{#isDeprecated}}
@Deprecated("This api was deprecated") @Deprecated("This api was deprecated")
{{/isDeprecated}} {{/isDeprecated}}
@@ -46,7 +66,7 @@ interface {{classname}} {
{{/prioritizedContentTypes}} {{/prioritizedContentTypes}}
{{/formParams}} {{/formParams}}
@{{httpMethod}}("{{{path}}}") @{{httpMethod}}("{{{path}}}")
{{^doNotUseRxAndCoroutines}}{{#useCoroutines}}suspend {{/useCoroutines}}{{/doNotUseRxAndCoroutines}}fun {{operationId}}({{^allParams}}){{/allParams}}{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}){{/hasMore}}{{/allParams}}: {{^doNotUseRxAndCoroutines}}{{#useRxJava}}Observable<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}{{/isResponseFile}}>{{/useRxJava}}{{#useRxJava2}}{{#returnType}}Single<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}>{{/returnType}}{{^returnType}}Completable{{/returnType}}{{/useRxJava2}}{{#useCoroutines}}{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}{{/isResponseFile}}{{/useCoroutines}}{{/doNotUseRxAndCoroutines}}{{#doNotUseRxAndCoroutines}}Call<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}{{/isResponseFile}}>{{/doNotUseRxAndCoroutines}} {{^doNotUseRxAndCoroutines}}{{#useCoroutines}}suspend {{/useCoroutines}}{{/doNotUseRxAndCoroutines}}fun {{operationId}}({{^allParams}}){{/allParams}}{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}){{/hasMore}}{{/allParams}}: {{^doNotUseRxAndCoroutines}}{{#useRxJava}}Observable<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}{{/isResponseFile}}>{{/useRxJava}}{{#useRxJava2}}{{#returnType}}Single<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}>{{/returnType}}{{^returnType}}Completable{{/returnType}}{{/useRxJava2}}{{#useCoroutines}}Response<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}{{/isResponseFile}}>{{/useCoroutines}}{{/doNotUseRxAndCoroutines}}{{#doNotUseRxAndCoroutines}}Call<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}{{/isResponseFile}}>{{/doNotUseRxAndCoroutines}}
{{/operation}} {{/operation}}
} }

View File

@@ -0,0 +1,83 @@
# {{classname}}{{#description}}
{{description}}{{/description}}
All URIs are relative to *{{basePath}}*
Method | HTTP request | Description
------------- | ------------- | -------------
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
{{/operation}}{{/operations}}
{{#operations}}
{{#operation}}
{{summary}}{{#notes}}
{{notes}}{{/notes}}
### Example
```kotlin
// Import classes:
//import {{{packageName}}}.*
//import {{{packageName}}}.infrastructure.*
//import {{{modelPackage}}}.*
val apiClient = ApiClient()
{{#authMethods}}
{{#isBasic}}
{{#isBasicBasic}}
apiClient.setCredentials("USERNAME", "PASSWORD")
{{/isBasicBasic}}
{{#isBasicBearer}}
apiClient.setBearerToken("TOKEN")
{{/isBasicBearer}}
{{/isBasic}}
{{/authMethods}}
val webService = apiClient.createWebservice({{{classname}}}::class.java)
{{#allParams}}
val {{{paramName}}} : {{{dataType}}} = {{{example}}} // {{{dataType}}} | {{{description}}}
{{/allParams}}
{{#useCoroutines}}
launch(Dispatchers.IO) {
{{/useCoroutines}}
{{#useCoroutines}} {{/useCoroutines}}{{#returnType}}val result : {{{returnType}}}{{#nullableReturnType}}?{{/nullableReturnType}} = {{/returnType}}webService.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
{{#useCoroutines}}
}
{{/useCoroutines}}
```
### Parameters
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#generateModelDocs}}[**{{dataType}}**]({{baseType}}.md){{/generateModelDocs}}{{^generateModelDocs}}**{{dataType}}**{{/generateModelDocs}}{{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}}
{{/allParams}}
### Return type
{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}{{#generateModelDocs}}[**{{returnType}}**]({{returnBaseType}}.md){{/generateModelDocs}}{{^generateModelDocs}}**{{returnType}}**{{/generateModelDocs}}{{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}null (empty response body){{/returnType}}
### Authorization
{{^authMethods}}No authorization required{{/authMethods}}
{{#authMethods}}
{{#isBasic}}
{{#isBasicBasic}}
Configure {{name}}:
ApiClient().setCredentials("USERNAME", "PASSWORD")
{{/isBasicBasic}}
{{#isBasicBearer}}
Configure {{name}}:
ApiClient().setBearerToken("TOKEN")
{{/isBasicBearer}}
{{/isBasic}}
{{/authMethods}}
### HTTP request headers
- **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
{{/operation}}
{{/operations}}

View File

@@ -0,0 +1,50 @@
package {{packageName}}.auth
import java.io.IOException
import java.net.URI
import java.net.URISyntaxException
import okhttp3.Interceptor
import okhttp3.Response
class ApiKeyAuth(
private val location: String = "",
private val paramName: String = "",
private var apiKey: String = ""
) : Interceptor {
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {
var request = chain.request()
if ("query" == location) {
var newQuery = request.url.toUri().query
val paramValue = "$paramName=$apiKey"
if (newQuery == null) {
newQuery = paramValue
} else {
newQuery += "&$paramValue"
}
val newUri: URI
try {
val oldUri = request.url.toUri()
newUri = URI(oldUri.scheme, oldUri.authority,
oldUri.path, newQuery, oldUri.fragment)
} catch (e: URISyntaxException) {
throw IOException(e)
}
request = request.newBuilder().url(newUri.toURL()).build()
} else if ("header" == location) {
request = request.newBuilder()
.addHeader(paramName, apiKey)
.build()
} else if ("cookie" == location) {
request = request.newBuilder()
.addHeader("Cookie", "$paramName=$apiKey")
.build()
}
return chain.proceed(request)
}
}

View File

@@ -0,0 +1,33 @@
package {{packageName}}.auth
import java.io.IOException
import kotlin.jvm.Throws
import okhttp3.Interceptor
import okhttp3.Interceptor.Chain
import okhttp3.Response
import okhttp3.Credentials
class HttpBasicAuth(
private var username: String = "",
private var password: String = ""
) : Interceptor {
fun setCredentials(username: String, password: String) {
this.username = username
this.password = password
}
@Throws(IOException::class)
override fun intercept(chain: Chain): Response {
var request = chain.request()
// If the request already have an authorization (eg. Basic auth), do nothing
if (request.header("Authorization") == null && username.isNotBlank() && password.isNotBlank()) {
request = request.newBuilder()
.addHeader("Authorization", Credentials.basic(username, password))
.build()
}
return chain.proceed(request)
}
}

View File

@@ -0,0 +1,39 @@
package {{packageName}}.auth
import java.io.IOException
import okhttp3.Interceptor
import okhttp3.Interceptor.Chain
import okhttp3.Response
class HttpBearerAuth(
private var schema: String = "",
var bearerToken: String = ""
) : Interceptor {
@Throws(IOException::class)
override fun intercept(chain: Chain): Response {
var request = chain.request()
// If the request already have an authorization (eg. Basic auth), do nothing
if (request.header("Authorization") == null && bearerToken.isNotBlank()) {
request = request.newBuilder()
.addHeader("Authorization", headerValue())
.build()
}
return chain.proceed(request)
}
private fun headerValue(): String {
return if (schema.isNotBlank()) {
"${upperCaseBearer()} $bearerToken"
} else {
bearerToken
}
}
private fun upperCaseBearer(): String {
return if (schema.toLowerCase().equals("bearer")) "Bearer" else schema
}
}

View File

@@ -0,0 +1,151 @@
package {{packageName}}.auth
import java.net.HttpURLConnection.HTTP_UNAUTHORIZED
import java.net.HttpURLConnection.HTTP_FORBIDDEN
import java.io.IOException
import org.apache.oltu.oauth2.client.OAuthClient
import org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest
import org.apache.oltu.oauth2.client.request.OAuthClientRequest
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder
import org.apache.oltu.oauth2.common.exception.OAuthProblemException
import org.apache.oltu.oauth2.common.exception.OAuthSystemException
import org.apache.oltu.oauth2.common.message.types.GrantType
import org.apache.oltu.oauth2.common.token.BasicOAuthToken
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.Response
class OAuth(
client: OkHttpClient,
var tokenRequestBuilder: TokenRequestBuilder
) : Interceptor {
interface AccessTokenListener {
fun notify(token: BasicOAuthToken)
}
private var oauthClient: OAuthClient = OAuthClient(OAuthOkHttpClient(client))
@Volatile
private var accessToken: String? = null
var authenticationRequestBuilder: AuthenticationRequestBuilder? = null
private var accessTokenListener: AccessTokenListener? = null
constructor(
requestBuilder: TokenRequestBuilder
) : this(
OkHttpClient(),
requestBuilder
)
constructor(
flow: OAuthFlow,
authorizationUrl: String,
tokenUrl: String,
scopes: String
) : this(
OAuthClientRequest.tokenLocation(tokenUrl).setScope(scopes)
) {
setFlow(flow);
authenticationRequestBuilder = OAuthClientRequest.authorizationLocation(authorizationUrl);
}
fun setFlow(flow: OAuthFlow) {
when (flow) {
OAuthFlow.accessCode, OAuthFlow.implicit ->
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE)
OAuthFlow.password ->
tokenRequestBuilder.setGrantType(GrantType.PASSWORD)
OAuthFlow.application ->
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS)
}
}
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {
return retryingIntercept(chain, true)
}
@Throws(IOException::class)
private fun retryingIntercept(chain: Interceptor.Chain, updateTokenAndRetryOnAuthorizationFailure: Boolean): Response {
var request = chain.request()
// If the request already have an authorization (eg. Basic auth), do nothing
if (request.header("Authorization") != null) {
return chain.proceed(request)
}
// If first time, get the token
val oAuthRequest: OAuthClientRequest
if (accessToken == null) {
updateAccessToken(null)
}
if (accessToken != null) {
// Build the request
val rb = request.newBuilder()
val requestAccessToken = accessToken
try {
oAuthRequest = OAuthBearerClientRequest(request.url.toString())
.setAccessToken(requestAccessToken)
.buildHeaderMessage()
} catch (e: OAuthSystemException) {
throw IOException(e)
}
oAuthRequest.headers.entries.forEach { header ->
rb.addHeader(header.key, header.value)
}
rb.url(oAuthRequest.locationUri)
//Execute the request
val response = chain.proceed(rb.build())
// 401/403 most likely indicates that access token has expired. Unless it happens two times in a row.
if ((response.code == HTTP_UNAUTHORIZED || response.code == HTTP_FORBIDDEN) && updateTokenAndRetryOnAuthorizationFailure) {
try {
if (updateAccessToken(requestAccessToken)) {
response.body?.close()
return retryingIntercept(chain, false)
}
} catch (e: Exception) {
response.body?.close()
throw e
}
}
return response
} else {
return chain.proceed(chain.request())
}
}
/**
* Returns true if the access token has been updated
*/
@Throws(IOException::class)
@Synchronized
fun updateAccessToken(requestAccessToken: String?): Boolean {
if (accessToken == null || accessToken.equals(requestAccessToken)) {
return try {
val accessTokenResponse = oauthClient.accessToken(this.tokenRequestBuilder.buildBodyMessage())
if (accessTokenResponse != null && accessTokenResponse.accessToken != null) {
accessToken = accessTokenResponse.accessToken
accessTokenListener?.notify(accessTokenResponse.oAuthToken as BasicOAuthToken)
!accessToken.equals(requestAccessToken)
} else {
false
}
} catch (e: OAuthSystemException) {
throw IOException(e)
} catch (e: OAuthProblemException) {
throw IOException(e)
}
}
return true;
}
}

View File

@@ -0,0 +1,5 @@
package {{packageName}}.auth
enum class OAuthFlow {
accessCode, implicit, password, application
}

View File

@@ -0,0 +1,61 @@
package {{packageName}}.auth
import java.io.IOException
import org.apache.oltu.oauth2.client.HttpClient
import org.apache.oltu.oauth2.client.request.OAuthClientRequest
import org.apache.oltu.oauth2.client.response.OAuthClientResponse
import org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory
import org.apache.oltu.oauth2.common.exception.OAuthProblemException
import org.apache.oltu.oauth2.common.exception.OAuthSystemException
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
class OAuthOkHttpClient(
private var client: OkHttpClient
) : HttpClient {
constructor() : this(OkHttpClient())
@Throws(OAuthSystemException::class, OAuthProblemException::class)
override fun <T : OAuthClientResponse?> execute(
request: OAuthClientRequest,
headers: Map<String, String>?,
requestMethod: String,
responseClass: Class<T>?): T {
var mediaType = "application/json".toMediaTypeOrNull()
val requestBuilder = Request.Builder().url(request.locationUri)
headers?.forEach { entry ->
if (entry.key.equals("Content-Type", true)) {
mediaType = entry.value.toMediaTypeOrNull()
} else {
requestBuilder.addHeader(entry.key, entry.value)
}
}
val body: RequestBody? = if (request.body != null) RequestBody.create(mediaType, request.body) else null
requestBuilder.method(requestMethod, body)
try {
val response = client.newCall(requestBuilder.build()).execute()
return OAuthClientResponseFactory.createCustomResponse(
response.body?.string(),
response.body?.contentType()?.toString(),
response.code,
responseClass)
} catch (e: IOException) {
throw OAuthSystemException(e)
}
}
override fun shutdown() {
// Nothing to do here
}
}

View File

@@ -1 +1 @@
{{#isBodyParam}}@Body {{{paramName}}}: {{{dataType}}}{{/isBodyParam}} {{#isBodyParam}}@Body {{{paramName}}}: {{{dataType}}}{{^required}}? = null{{/required}}{{/isBodyParam}}

View File

@@ -1,7 +1,30 @@
package {{packageName}}.infrastructure package {{packageName}}.infrastructure
{{#hasOAuthMethods}}
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder
import {{packageName}}.auth.ApiKeyAuth
import {{packageName}}.auth.OAuth
import {{packageName}}.auth.OAuth.AccessTokenListener
import {{packageName}}.auth.OAuthFlow
{{/hasOAuthMethods}}
{{#hasAuthMethods}}
{{#authMethods}}
{{#isBasic}}
{{#isBasicBasic}}
import {{packageName}}.auth.HttpBasicAuth
{{/isBasicBasic}}
{{#isBasicBearer}}
import {{packageName}}.auth.HttpBearerAuth
{{/isBasicBearer}}
{{/isBasic}}
{{/authMethods}}
{{/hasAuthMethods}}
import okhttp3.Interceptor
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import retrofit2.Retrofit import retrofit2.Retrofit
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.converter.scalars.ScalarsConverterFactory import retrofit2.converter.scalars.ScalarsConverterFactory
{{#useRxJava}} {{#useRxJava}}
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory
@@ -10,48 +33,255 @@ import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
{{/useRxJava2}} {{/useRxJava2}}
{{#gson}} {{#gson}}
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import retrofit2.converter.gson.GsonConverterFactory import retrofit2.converter.gson.GsonConverterFactory
{{/gson}} {{/gson}}
{{#moshi}} {{#moshi}}
import com.squareup.moshi.Moshi
import retrofit2.converter.moshi.MoshiConverterFactory import retrofit2.converter.moshi.MoshiConverterFactory
{{/moshi}} {{/moshi}}
{{#nonPublicApi}}internal {{/nonPublicApi}}class ApiClient( {{#nonPublicApi}}internal {{/nonPublicApi}}class ApiClient(
private var baseUrl: String = defaultBasePath, private var baseUrl: String = defaultBasePath,
private var okHttpClient: OkHttpClient private val okHttpClientBuilder: OkHttpClient.Builder? = null,
private val serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder
) { ) {
companion object { private val apiAuthorizations = mutableMapOf<String, Interceptor>()
@JvmStatic var logger: ((String) -> Unit)? = null
val defaultBasePath: String by lazy {
System.getProperties().getProperty("{{packageName}}.baseUrl", "{{{basePath}}}") private val retrofitBuilder: Retrofit.Builder by lazy {
} Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(ScalarsConverterFactory.create())
{{#gson}}
.addConverterFactory(GsonConverterFactory.create(serializerBuilder.create()))
{{/gson}}
{{#useRxJava}}
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
{{/useRxJava}}
{{#useRxJava2}}
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
{{/useRxJava2}}
{{#moshi}}
.addConverterFactory(MoshiConverterFactory.create(serializerBuilder.build()))
{{/moshi}}
}
private val clientBuilder: OkHttpClient.Builder by lazy {
okHttpClientBuilder ?: defaultClientBuilder
}
private val defaultClientBuilder: OkHttpClient.Builder by lazy {
OkHttpClient()
.newBuilder()
.addInterceptor(HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger {
override fun log(message: String) {
logger?.invoke(message)
}
}).apply {
level = HttpLoggingInterceptor.Level.BODY
})
} }
init { init {
normalizeBaseUrl() normalizeBaseUrl()
} }
val retrofitBuilder: Retrofit.Builder by lazy { {{#hasAuthMethods}}
constructor(
baseUrl: String = defaultBasePath,
okHttpClientBuilder: OkHttpClient.Builder? = null,
serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder,
authNames: Array<String>
) : this(baseUrl, okHttpClientBuilder, serializerBuilder) {
authNames.forEach { authName ->
val auth = when (authName) {
{{#authMethods}}"{{name}}" -> {{#isBasic}}{{#isBasicBasic}}HttpBasicAuth(){{/isBasicBasic}}{{#isBasicBearer}}HttpBearerAuth("{{scheme}}"){{/isBasicBearer}}{{/isBasic}}{{#isApiKey}}ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"){{/isApiKey}}{{#isOAuth}}OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{#hasMore}}, {{/hasMore}}{{/scopes}}"){{/isOAuth}}{{/authMethods}}
else -> throw RuntimeException("auth name $authName not found in available auth names")
}
addAuthorization(authName, auth);
}
}
Retrofit.Builder() {{#authMethods}}
.baseUrl(baseUrl) {{#isBasic}}
.addConverterFactory(ScalarsConverterFactory.create()) {{#isBasicBasic}}
{{#gson}} constructor(
.addConverterFactory(GsonConverterFactory.create(Serializer.gson)) baseUrl: String = defaultBasePath,
{{/gson}} okHttpClientBuilder: OkHttpClient.Builder? = null,
{{#useRxJava}} serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder,
.addCallAdapterFactory(RxJavaCallAdapterFactory.create()) authName: String,
{{/useRxJava}} username: String,
{{#useRxJava2}} password: String
.addCallAdapterFactory(RxJava2CallAdapterFactory.create()) ) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) {
{{/useRxJava2}} setCredentials(username, password)
{{#moshi}} }
.addConverterFactory(MoshiConverterFactory.create(Serializer.moshi))
{{/moshi}} {{/isBasicBasic}}
{{#isBasicBearer}}
constructor(
baseUrl: String = defaultBasePath,
okHttpClientBuilder: OkHttpClient.Builder? = null,
serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder,
authName: String,
bearerToken: String
) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) {
setBearerToken(bearerToken)
}
{{/isBasicBearer}}
{{/isBasic}}
{{/authMethods}}
{{#hasOAuthMethods}}
constructor(
baseUrl: String = defaultBasePath,
okHttpClientBuilder: OkHttpClient.Builder? = null,
serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder,
authName: String,
clientId: String,
secret: String,
username: String,
password: String
) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) {
getTokenEndPoint()
?.setClientId(clientId)
?.setClientSecret(secret)
?.setUsername(username)
?.setPassword(password)
}
{{/hasOAuthMethods}}
{{#authMethods}}
{{#isBasic}}
{{#isBasicBasic}}
fun setCredentials(username: String, password: String): ApiClient {
apiAuthorizations.values.runOnFirst<Interceptor, HttpBasicAuth> {
setCredentials(username, password);
}
{{#hasOAuthMethods}}
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
tokenRequestBuilder.setUsername(username).setPassword(password)
}
{{/hasOAuthMethods}}
return this
}
{{/isBasicBasic}}
{{^isBasicBasic}}
{{#hasOAuthMethods}}
fun setCredentials(username: String, password: String): ApiClient {
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
tokenRequestBuilder.setUsername(username).setPassword(password)
}
return this
}
{{/hasOAuthMethods}}
{{/isBasicBasic}}
{{#isBasicBearer}}
fun setBearerToken(bearerToken: String): ApiClient {
apiAuthorizations.values.runOnFirst<Interceptor, HttpBearerAuth> {
this.bearerToken = bearerToken
}
return this
}
{{/isBasicBearer}}
{{/isBasic}}
{{/authMethods}}
{{/hasAuthMethods}}
{{#hasOAuthMethods}}
/**
* Helper method to configure the token endpoint of the first oauth found in the apiAuthorizations (there should be only one)
* @return Token request builder
*/
fun getTokenEndPoint(): TokenRequestBuilder? {
var result: TokenRequestBuilder? = null
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
result = tokenRequestBuilder
}
return result
}
/**
* Helper method to configure authorization endpoint of the first oauth found in the apiAuthorizations (there should be only one)
* @return Authentication request builder
*/
fun getAuthorizationEndPoint(): AuthenticationRequestBuilder? {
var result: AuthenticationRequestBuilder? = null
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
result = authenticationRequestBuilder
}
return result
}
/**
* Helper method to pre-set the oauth access token of the first oauth found in the apiAuthorizations (there should be only one)
* @param accessToken Access token
* @return ApiClient
*/
fun setAccessToken(accessToken: String): ApiClient {
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
setAccessToken(accessToken)
}
return this
}
/**
* Helper method to configure the oauth accessCode/implicit flow parameters
* @param clientId Client ID
* @param clientSecret Client secret
* @param redirectURI Redirect URI
* @return ApiClient
*/
fun configureAuthorizationFlow(clientId: String, clientSecret: String, redirectURI: String): ApiClient {
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
tokenRequestBuilder
.setClientId(clientId)
.setClientSecret(clientSecret)
.setRedirectURI(redirectURI)
authenticationRequestBuilder
?.setClientId(clientId)
?.setRedirectURI(redirectURI)
}
return this;
}
/**
* Configures a listener which is notified when a new access token is received.
* @param accessTokenListener Access token listener
* @return ApiClient
*/
fun registerAccessTokenListener(accessTokenListener: AccessTokenListener): ApiClient {
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
registerAccessTokenListener(accessTokenListener)
}
return this;
}
{{/hasOAuthMethods}}
/**
* Adds an authorization to be used by the client
* @param authName Authentication name
* @param authorization Authorization interceptor
* @return ApiClient
*/
fun addAuthorization(authName: String, authorization: Interceptor): ApiClient {
if (apiAuthorizations.containsKey(authName)) {
throw RuntimeException("auth name $authName already in api authorizations")
}
apiAuthorizations[authName] = authorization
clientBuilder.addInterceptor(authorization)
return this
}
fun setLogger(logger: (String) -> Unit): ApiClient {
this.logger = logger
return this
} }
fun <S> createService(serviceClass: Class<S>): S { fun <S> createService(serviceClass: Class<S>): S {
return retrofitBuilder.client(okHttpClient).build().create(serviceClass) return retrofitBuilder.client(clientBuilder.build()).build().create(serviceClass)
} }
private fun normalizeBaseUrl() { private fun normalizeBaseUrl() {
@@ -59,4 +289,20 @@ import retrofit2.converter.moshi.MoshiConverterFactory
baseUrl += "/" baseUrl += "/"
} }
} }
private inline fun <T, reified U> Iterable<T>.runOnFirst(callback: U.() -> Unit) {
for (element in this) {
if (element is U) {
callback.invoke(element)
break
}
}
}
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("{{packageName}}.baseUrl", "{{{basePath}}}")
}
}
} }

View File

@@ -0,0 +1,35 @@
package {{packageName}}.infrastructure
{{#moshi}}
import com.squareup.moshi.JsonDataException
import com.squareup.moshi.Moshi
{{/moshi}}
{{#gson}}
import com.google.gson.GsonBuilder
import com.google.gson.JsonParseException
{{/gson}}
import retrofit2.Response
{{#moshi}}
@Throws(JsonDataException::class)
inline fun <reified T> Response<*>.getErrorResponse(serializerBuilder: Moshi.Builder = Serializer.moshiBuilder): T? {
val serializer = serializerBuilder.build()
val parser = serializer.adapter(T::class.java)
val response = errorBody()?.string()
if(response != null) {
return parser.fromJson(response)
}
return null
}
{{/moshi}}
{{#gson}}
@Throws(JsonParseException::class)
inline fun <reified T> Response<*>.getErrorResponse(serializerBuilder: GsonBuilder = Serializer.gsonBuilder): T? {
val serializer = serializerBuilder.create()
val reader = errorBody()?.charStream()
if(reader != null) {
return serializer.fromJson(reader, T::class.java)
}
return null
}
{{/gson}}

View File

@@ -2,7 +2,7 @@
## Requires ## Requires
* Kotlin 1.3.41 * Kotlin 1.3.61
* Gradle 4.9 * Gradle 4.9
## Build ## Build

View File

@@ -29,8 +29,10 @@ test {
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0"
compile "com.google.code.gson:gson:2.8.6" compile "com.google.code.gson:gson:2.8.6"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.okhttp3:okhttp:4.2.2" compile "com.squareup.okhttp3:okhttp:4.2.2"
compile "com.squareup.okhttp3:logging-interceptor:4.4.0"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0"
} }

View File

@@ -2,7 +2,7 @@
## Requires ## Requires
* Kotlin 1.3.41 * Kotlin 1.3.61
* Gradle 4.9 * Gradle 4.9
## Build ## Build

View File

@@ -29,10 +29,12 @@ test {
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0"
compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.10.2" compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.10.2"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.2" compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.2"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.2" compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.2"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.okhttp3:okhttp:4.2.2" compile "com.squareup.okhttp3:okhttp:4.2.2"
compile "com.squareup.okhttp3:logging-interceptor:4.4.0"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0"
} }

View File

@@ -2,7 +2,7 @@
## Requires ## Requires
* Kotlin 1.3.41 * Kotlin 1.3.61
* Gradle 4.9 * Gradle 4.9
## Build ## Build

View File

@@ -29,9 +29,11 @@ test {
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.9.2" compile "com.squareup.moshi:moshi-kotlin:1.9.2"
compile "com.squareup.moshi:moshi-adapters:1.9.2" compile "com.squareup.moshi:moshi-adapters:1.9.2"
compile "com.squareup.okhttp3:okhttp:4.2.2" compile "com.squareup.okhttp3:okhttp:4.2.2"
compile "com.squareup.okhttp3:logging-interceptor:4.4.0"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0"
} }

View File

@@ -2,7 +2,7 @@
## Requires ## Requires
* Kotlin 1.3.41 * Kotlin 1.3.61
* Gradle 4.9 * Gradle 4.9
## Build ## Build

View File

@@ -29,8 +29,10 @@ test {
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0"
compile "com.google.code.gson:gson:2.8.6" compile "com.google.code.gson:gson:2.8.6"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.okhttp3:okhttp:4.2.2" compile "com.squareup.okhttp3:okhttp:4.2.2"
compile "com.squareup.okhttp3:logging-interceptor:4.4.0"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0"
} }

View File

@@ -2,7 +2,7 @@
## Requires ## Requires
* Kotlin 1.3.41 * Kotlin 1.3.61
* Gradle 4.9 * Gradle 4.9
## Build ## Build

View File

@@ -30,9 +30,11 @@ test {
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0"
compile "com.squareup.moshi:moshi-adapters:1.9.2" compile "com.squareup.moshi:moshi-adapters:1.9.2"
compile "com.squareup.moshi:moshi:1.9.2" compile "com.squareup.moshi:moshi:1.9.2"
kapt "com.squareup.moshi:moshi-kotlin-codegen:1.9.2" kapt "com.squareup.moshi:moshi-kotlin-codegen:1.9.2"
compile "com.squareup.okhttp3:okhttp:4.2.2" compile "com.squareup.okhttp3:okhttp:4.2.2"
compile "com.squareup.okhttp3:logging-interceptor:4.4.0"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0"
} }

View File

@@ -2,7 +2,7 @@
## Requires ## Requires
* Kotlin 1.3.41 * Kotlin 1.3.61
* Gradle 4.9 * Gradle 4.9
## Build ## Build

View File

@@ -29,9 +29,11 @@ test {
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.9.2" compile "com.squareup.moshi:moshi-kotlin:1.9.2"
compile "com.squareup.moshi:moshi-adapters:1.9.2" compile "com.squareup.moshi:moshi-adapters:1.9.2"
compile "com.squareup.okhttp3:okhttp:4.2.2" compile "com.squareup.okhttp3:okhttp:4.2.2"
compile "com.squareup.okhttp3:logging-interceptor:4.4.0"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0"
} }

View File

@@ -2,7 +2,7 @@
## Requires ## Requires
* Kotlin 1.3.41 * Kotlin 1.3.61
* Gradle 4.9 * Gradle 4.9
## Build ## Build

View File

@@ -29,9 +29,11 @@ test {
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.9.2" compile "com.squareup.moshi:moshi-kotlin:1.9.2"
compile "com.squareup.moshi:moshi-adapters:1.9.2" compile "com.squareup.moshi:moshi-adapters:1.9.2"
compile "com.squareup.okhttp3:okhttp:4.2.2" compile "com.squareup.okhttp3:okhttp:4.2.2"
compile "com.squareup.okhttp3:logging-interceptor:4.4.0"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0"
} }

View File

@@ -2,7 +2,7 @@
## Requires ## Requires
* Kotlin 1.3.41 * Kotlin 1.3.61
* Gradle 4.9 * Gradle 4.9
## Build ## Build

View File

@@ -29,6 +29,7 @@ test {
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.9.2" compile "com.squareup.moshi:moshi-kotlin:1.9.2"
compile "com.squareup.moshi:moshi-adapters:1.9.2" compile "com.squareup.moshi:moshi-adapters:1.9.2"

View File

@@ -13,12 +13,17 @@ settings.gradle
src/main/kotlin/org/openapitools/client/apis/PetApi.kt 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/StoreApi.kt
src/main/kotlin/org/openapitools/client/apis/UserApi.kt src/main/kotlin/org/openapitools/client/apis/UserApi.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt
src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.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/LocalDateTimeAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/ResponseExt.kt
src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt
src/main/kotlin/org/openapitools/client/models/ApiResponse.kt src/main/kotlin/org/openapitools/client/models/ApiResponse.kt

View File

@@ -2,7 +2,7 @@
## Requires ## Requires
* Kotlin 1.3.41 * Kotlin 1.3.61
* Gradle 4.9 * Gradle 4.9
## Build ## Build
@@ -35,26 +35,26 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Class | Method | HTTP request | Description Class | Method | HTTP request | Description
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
*PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store *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* | [**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* | [**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* | [**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* | [**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* | [**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* | [**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 *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* | [**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* | [**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* | [**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 *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* | [**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* | [**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* | [**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* | [**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* | [**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* | [**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* | [**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 *UserApi* | [**updateUser**](docs/UserApi.md#updateuser) | **PUT** user/{username} | Updated user
<a name="documentation-for-models"></a> <a name="documentation-for-models"></a>

View File

@@ -30,6 +30,7 @@ test {
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.9.2" compile "com.squareup.moshi:moshi-kotlin:1.9.2"
compile "com.squareup.moshi:moshi-adapters:1.9.2" compile "com.squareup.moshi:moshi-adapters:1.9.2"

View File

@@ -4,39 +4,31 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store [**addPet**](PetApi.md#addPet) | **POST** pet | Add a new pet to the store
[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet [**deletePet**](PetApi.md#deletePet) | **DELETE** pet/{petId} | Deletes a pet
[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status [**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** pet/findByStatus | Finds Pets by status
[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags [**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** pet/findByTags | Finds Pets by tags
[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID [**getPetById**](PetApi.md#getPetById) | **GET** pet/{petId} | Find pet by ID
[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**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 [**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 [**uploadFile**](PetApi.md#uploadFile) | **POST** pet/{petId}/uploadImage | uploads an image
<a name="addPet"></a>
# **addPet**
> addPet(body)
Add a new pet to the store Add a new pet to the store
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val body : Pet = // Pet | Pet object that needs to be added to the store val body : Pet = // Pet | Pet object that needs to be added to the store
try {
apiInstance.addPet(body) webService.addPet(body)
} catch (e: ClientException) {
println("4xx response calling PetApi#addPet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#addPet")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -52,38 +44,28 @@ null (empty response body)
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: application/json, application/xml - **Content-Type**: application/json, application/xml
- **Accept**: Not defined - **Accept**: Not defined
<a name="deletePet"></a>
# **deletePet**
> deletePet(petId, apiKey)
Deletes a pet Deletes a pet
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val petId : kotlin.Long = 789 // kotlin.Long | Pet id to delete val petId : kotlin.Long = 789 // kotlin.Long | Pet id to delete
val apiKey : kotlin.String = apiKey_example // kotlin.String | val apiKey : kotlin.String = apiKey_example // kotlin.String |
try {
apiInstance.deletePet(petId, apiKey) webService.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 ### Parameters
@@ -100,17 +82,12 @@ null (empty response body)
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: Not defined - **Accept**: Not defined
<a name="findPetsByStatus"></a>
# **findPetsByStatus**
> kotlin.Array&lt;Pet&gt; findPetsByStatus(status)
Finds Pets by status Finds Pets by status
@@ -119,21 +96,15 @@ Multiple status values can be provided with comma separated strings
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val status : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Status values that need to be considered for filter val status : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Status values that need to be considered for filter
try {
val result : kotlin.Array<Pet> = apiInstance.findPetsByStatus(status) val result : kotlin.Array<Pet> = webService.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 ### Parameters
@@ -149,17 +120,12 @@ Name | Type | Description | Notes
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="findPetsByTags"></a>
# **findPetsByTags**
> kotlin.Array&lt;Pet&gt; findPetsByTags(tags)
Finds Pets by tags Finds Pets by tags
@@ -168,21 +134,15 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val tags : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Tags to filter by val tags : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Tags to filter by
try {
val result : kotlin.Array<Pet> = apiInstance.findPetsByTags(tags) val result : kotlin.Array<Pet> = webService.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 ### Parameters
@@ -198,17 +158,12 @@ Name | Type | Description | Notes
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="getPetById"></a>
# **getPetById**
> Pet getPetById(petId)
Find pet by ID Find pet by ID
@@ -217,21 +172,15 @@ Returns a single pet
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to return val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to return
try {
val result : Pet = apiInstance.getPetById(petId) val result : Pet = webService.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 ### Parameters
@@ -247,38 +196,27 @@ Name | Type | Description | Notes
### Authorization ### Authorization
Configure api_key:
ApiClient.apiKey["api_key"] = ""
ApiClient.apiKeyPrefix["api_key"] = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="updatePet"></a>
# **updatePet**
> updatePet(body)
Update an existing pet Update an existing pet
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val body : Pet = // Pet | Pet object that needs to be added to the store val body : Pet = // Pet | Pet object that needs to be added to the store
try {
apiInstance.updatePet(body) webService.updatePet(body)
} catch (e: ClientException) {
println("4xx response calling PetApi#updatePet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#updatePet")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -294,39 +232,29 @@ null (empty response body)
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: application/json, application/xml - **Content-Type**: application/json, application/xml
- **Accept**: Not defined - **Accept**: Not defined
<a name="updatePetWithForm"></a>
# **updatePetWithForm**
> updatePetWithForm(petId, name, status)
Updates a pet in the store with form data Updates a pet in the store with form data
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be updated 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 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 val status : kotlin.String = status_example // kotlin.String | Updated status of the pet
try {
apiInstance.updatePetWithForm(petId, name, status) webService.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 ### Parameters
@@ -344,40 +272,29 @@ null (empty response body)
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: application/x-www-form-urlencoded - **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined - **Accept**: Not defined
<a name="uploadFile"></a>
# **uploadFile**
> ApiResponse uploadFile(petId, additionalMetadata, file)
uploads an image uploads an image
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to update 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 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 val file : java.io.File = BINARY_DATA_HERE // java.io.File | file to upload
try {
val result : ApiResponse = apiInstance.uploadFile(petId, additionalMetadata, file) val result : ApiResponse = webService.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 ### Parameters
@@ -395,8 +312,6 @@ Name | Type | Description | Notes
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers

View File

@@ -4,15 +4,12 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID [**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 [**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 [**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 [**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 Delete purchase order by ID
@@ -21,20 +18,15 @@ For valid response try integer IDs with value &lt; 1000. Anything above 1000 or
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = StoreApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(StoreApi::class.java)
val orderId : kotlin.String = orderId_example // kotlin.String | ID of the order that needs to be deleted val orderId : kotlin.String = orderId_example // kotlin.String | ID of the order that needs to be deleted
try {
apiInstance.deleteOrder(orderId) webService.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 ### Parameters
@@ -56,9 +48,6 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: 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 pet inventories by status
@@ -67,20 +56,14 @@ Returns a map of status codes to quantities
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = StoreApi() val apiClient = ApiClient()
try { val webService = apiClient.createWebservice(StoreApi::class.java)
val result : kotlin.collections.Map<kotlin.String, kotlin.Int> = apiInstance.getInventory()
println(result) val result : kotlin.collections.Map<kotlin.String, kotlin.Int> = webService.getInventory()
} catch (e: ClientException) {
println("4xx response calling StoreApi#getInventory")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling StoreApi#getInventory")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -93,18 +76,12 @@ This endpoint does not need any parameter.
### Authorization ### Authorization
Configure api_key:
ApiClient.apiKey["api_key"] = ""
ApiClient.apiKeyPrefix["api_key"] = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/json - **Accept**: application/json
<a name="getOrderById"></a>
# **getOrderById**
> Order getOrderById(orderId)
Find purchase order by ID Find purchase order by ID
@@ -113,21 +90,15 @@ For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other val
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = StoreApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(StoreApi::class.java)
val orderId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be fetched val orderId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be fetched
try {
val result : Order = apiInstance.getOrderById(orderId) val result : Order = webService.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 ### Parameters
@@ -149,30 +120,21 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="placeOrder"></a>
# **placeOrder**
> Order placeOrder(body)
Place an order for a pet Place an order for a pet
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = StoreApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(StoreApi::class.java)
val body : Order = // Order | order placed for purchasing the pet val body : Order = // Order | order placed for purchasing the pet
try {
val result : Order = apiInstance.placeOrder(body) val result : Order = webService.placeOrder(body)
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 ### Parameters

View File

@@ -4,19 +4,16 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**createUser**](UserApi.md#createUser) | **POST** /user | Create user [**createUser**](UserApi.md#createUser) | **POST** user | Create user
[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array [**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 [**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** user/createWithList | Creates list of users with given input array
[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user [**deleteUser**](UserApi.md#deleteUser) | **DELETE** user/{username} | Delete user
[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name [**getUserByName**](UserApi.md#getUserByName) | **GET** user/{username} | Get user by user name
[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system [**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 [**logoutUser**](UserApi.md#logoutUser) | **GET** user/logout | Logs out current logged in user session
[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user [**updateUser**](UserApi.md#updateUser) | **PUT** user/{username} | Updated user
<a name="createUser"></a>
# **createUser**
> createUser(body)
Create user Create user
@@ -25,20 +22,15 @@ This can only be done by the logged in user.
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val body : User = // User | Created user object val body : User = // User | Created user object
try {
apiInstance.createUser(body) webService.createUser(body)
} catch (e: ClientException) {
println("4xx response calling UserApi#createUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#createUser")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -60,29 +52,21 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: Not defined - **Accept**: Not defined
<a name="createUsersWithArrayInput"></a>
# **createUsersWithArrayInput**
> createUsersWithArrayInput(body)
Creates list of users with given input array Creates list of users with given input array
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val body : kotlin.Array<User> = // kotlin.Array<User> | List of user object val body : kotlin.Array<User> = // kotlin.Array<User> | List of user object
try {
apiInstance.createUsersWithArrayInput(body) webService.createUsersWithArrayInput(body)
} catch (e: ClientException) {
println("4xx response calling UserApi#createUsersWithArrayInput")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#createUsersWithArrayInput")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -104,29 +88,21 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: Not defined - **Accept**: Not defined
<a name="createUsersWithListInput"></a>
# **createUsersWithListInput**
> createUsersWithListInput(body)
Creates list of users with given input array Creates list of users with given input array
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val body : kotlin.Array<User> = // kotlin.Array<User> | List of user object val body : kotlin.Array<User> = // kotlin.Array<User> | List of user object
try {
apiInstance.createUsersWithListInput(body) webService.createUsersWithListInput(body)
} catch (e: ClientException) {
println("4xx response calling UserApi#createUsersWithListInput")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#createUsersWithListInput")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -148,9 +124,6 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: Not defined - **Accept**: Not defined
<a name="deleteUser"></a>
# **deleteUser**
> deleteUser(username)
Delete user Delete user
@@ -159,20 +132,15 @@ This can only be done by the logged in user.
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val username : kotlin.String = username_example // kotlin.String | The name that needs to be deleted val username : kotlin.String = username_example // kotlin.String | The name that needs to be deleted
try {
apiInstance.deleteUser(username) webService.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 ### Parameters
@@ -194,30 +162,21 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: Not defined - **Accept**: Not defined
<a name="getUserByName"></a>
# **getUserByName**
> User getUserByName(username)
Get user by user name Get user by user name
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing. 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) val result : User = webService.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 ### Parameters
@@ -239,31 +198,22 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="loginUser"></a>
# **loginUser**
> kotlin.String loginUser(username, password)
Logs user into the system Logs user into the system
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val username : kotlin.String = username_example // kotlin.String | The user name for login 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 val password : kotlin.String = password_example // kotlin.String | The password for login in clear text
try {
val result : kotlin.String = apiInstance.loginUser(username, password) val result : kotlin.String = webService.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 ### Parameters
@@ -286,28 +236,20 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="logoutUser"></a>
# **logoutUser**
> logoutUser()
Logs out current logged in user session Logs out current logged in user session
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
try { val webService = apiClient.createWebservice(UserApi::class.java)
apiInstance.logoutUser()
} catch (e: ClientException) { webService.logoutUser()
println("4xx response calling UserApi#logoutUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#logoutUser")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -326,9 +268,6 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: Not defined - **Accept**: Not defined
<a name="updateUser"></a>
# **updateUser**
> updateUser(username, body)
Updated user Updated user
@@ -337,21 +276,16 @@ This can only be done by the logged in user.
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val username : kotlin.String = username_example // kotlin.String | name that need to be deleted val username : kotlin.String = username_example // kotlin.String | name that need to be deleted
val body : User = // User | Updated user object val body : User = // User | Updated user object
try {
apiInstance.updateUser(username, body) webService.updateUser(username, body)
} catch (e: ClientException) {
println("4xx response calling UserApi#updateUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#updateUser")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters

View File

@@ -4,38 +4,119 @@ import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import retrofit2.Call import retrofit2.Call
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import org.openapitools.client.models.ApiResponse import org.openapitools.client.models.ApiResponse
import org.openapitools.client.models.Pet import org.openapitools.client.models.Pet
interface PetApi { interface PetApi {
@POST("/pet") /**
* Add a new pet to the store
*
* Responses:
* - 405: Invalid input
*
* @param body Pet object that needs to be added to the store
* @return [Call]<[Unit]>
*/
@POST("pet")
fun addPet(@Body body: Pet): Call<Unit> fun addPet(@Body body: Pet): Call<Unit>
@DELETE("/pet/{petId}") /**
* Deletes a pet
*
* Responses:
* - 400: Invalid pet value
*
* @param petId Pet id to delete
* @param apiKey (optional)
* @return [Call]<[Unit]>
*/
@DELETE("pet/{petId}")
fun deletePet(@Path("petId") petId: kotlin.Long, @Header("api_key") apiKey: kotlin.String): Call<Unit> fun deletePet(@Path("petId") petId: kotlin.Long, @Header("api_key") apiKey: kotlin.String): Call<Unit>
@GET("/pet/findByStatus") /**
* Finds Pets by status
* Multiple status values can be provided with comma separated strings
* Responses:
* - 200: successful operation
* - 400: Invalid status value
*
* @param status Status values that need to be considered for filter
* @return [Call]<[kotlin.Array<Pet>]>
*/
@GET("pet/findByStatus")
fun findPetsByStatus(@Query("status") status: CSVParams): Call<kotlin.Array<Pet>> fun findPetsByStatus(@Query("status") status: CSVParams): Call<kotlin.Array<Pet>>
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* Responses:
* - 200: successful operation
* - 400: Invalid tag value
*
* @param tags Tags to filter by
* @return [Call]<[kotlin.Array<Pet>]>
*/
@Deprecated("This api was deprecated") @Deprecated("This api was deprecated")
@GET("/pet/findByTags") @GET("pet/findByTags")
fun findPetsByTags(@Query("tags") tags: CSVParams): Call<kotlin.Array<Pet>> fun findPetsByTags(@Query("tags") tags: CSVParams): Call<kotlin.Array<Pet>>
@GET("/pet/{petId}") /**
* Find pet by ID
* Returns a single pet
* Responses:
* - 200: successful operation
* - 400: Invalid ID supplied
* - 404: Pet not found
*
* @param petId ID of pet to return
* @return [Call]<[Pet]>
*/
@GET("pet/{petId}")
fun getPetById(@Path("petId") petId: kotlin.Long): Call<Pet> fun getPetById(@Path("petId") petId: kotlin.Long): Call<Pet>
@PUT("/pet") /**
* Update an existing pet
*
* Responses:
* - 400: Invalid ID supplied
* - 404: Pet not found
* - 405: Validation exception
*
* @param body Pet object that needs to be added to the store
* @return [Call]<[Unit]>
*/
@PUT("pet")
fun updatePet(@Body body: Pet): Call<Unit> fun updatePet(@Body body: Pet): Call<Unit>
/**
* Updates a pet in the store with form data
*
* Responses:
* - 405: Invalid input
*
* @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 [Call]<[Unit]>
*/
@FormUrlEncoded @FormUrlEncoded
@POST("/pet/{petId}") @POST("pet/{petId}")
fun updatePetWithForm(@Path("petId") petId: kotlin.Long, @Field("name") name: kotlin.String, @Field("status") status: kotlin.String): Call<Unit> fun updatePetWithForm(@Path("petId") petId: kotlin.Long, @Field("name") name: kotlin.String, @Field("status") status: kotlin.String): Call<Unit>
/**
* uploads an image
*
* Responses:
* - 200: successful operation
*
* @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server (optional)
* @param file file to upload (optional)
* @return [Call]<[ApiResponse]>
*/
@Multipart @Multipart
@POST("/pet/{petId}/uploadImage") @POST("pet/{petId}/uploadImage")
fun uploadFile(@Path("petId") petId: kotlin.Long, @Part("additionalMetadata") additionalMetadata: kotlin.String, @Part file: MultipartBody.Part): Call<ApiResponse> fun uploadFile(@Path("petId") petId: kotlin.Long, @Part("additionalMetadata") additionalMetadata: kotlin.String, @Part file: MultipartBody.Part): Call<ApiResponse>
} }

View File

@@ -4,22 +4,59 @@ import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import retrofit2.Call import retrofit2.Call
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import org.openapitools.client.models.Order import org.openapitools.client.models.Order
interface StoreApi { interface StoreApi {
@DELETE("/store/order/{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
* Responses:
* - 400: Invalid ID supplied
* - 404: Order not found
*
* @param orderId ID of the order that needs to be deleted
* @return [Call]<[Unit]>
*/
@DELETE("store/order/{orderId}")
fun deleteOrder(@Path("orderId") orderId: kotlin.String): Call<Unit> fun deleteOrder(@Path("orderId") orderId: kotlin.String): Call<Unit>
@GET("/store/inventory") /**
* Returns pet inventories by status
* Returns a map of status codes to quantities
* Responses:
* - 200: successful operation
*
* @return [Call]<[kotlin.collections.Map<kotlin.String, kotlin.Int>]>
*/
@GET("store/inventory")
fun getInventory(): Call<kotlin.collections.Map<kotlin.String, kotlin.Int>> fun getInventory(): Call<kotlin.collections.Map<kotlin.String, kotlin.Int>>
@GET("/store/order/{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
* Responses:
* - 200: successful operation
* - 400: Invalid ID supplied
* - 404: Order not found
*
* @param orderId ID of pet that needs to be fetched
* @return [Call]<[Order]>
*/
@GET("store/order/{orderId}")
fun getOrderById(@Path("orderId") orderId: kotlin.Long): Call<Order> fun getOrderById(@Path("orderId") orderId: kotlin.Long): Call<Order>
@POST("/store/order") /**
* Place an order for a pet
*
* Responses:
* - 200: successful operation
* - 400: Invalid Order
*
* @param body order placed for purchasing the pet
* @return [Call]<[Order]>
*/
@POST("store/order")
fun placeOrder(@Body body: Order): Call<Order> fun placeOrder(@Body body: Order): Call<Order>
} }

View File

@@ -4,34 +4,110 @@ import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import retrofit2.Call import retrofit2.Call
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import org.openapitools.client.models.User import org.openapitools.client.models.User
interface UserApi { interface UserApi {
@POST("/user") /**
* Create user
* This can only be done by the logged in user.
* Responses:
* - 0: successful operation
*
* @param body Created user object
* @return [Call]<[Unit]>
*/
@POST("user")
fun createUser(@Body body: User): Call<Unit> fun createUser(@Body body: User): Call<Unit>
@POST("/user/createWithArray") /**
* Creates list of users with given input array
*
* Responses:
* - 0: successful operation
*
* @param body List of user object
* @return [Call]<[Unit]>
*/
@POST("user/createWithArray")
fun createUsersWithArrayInput(@Body body: kotlin.Array<User>): Call<Unit> fun createUsersWithArrayInput(@Body body: kotlin.Array<User>): Call<Unit>
@POST("/user/createWithList") /**
* Creates list of users with given input array
*
* Responses:
* - 0: successful operation
*
* @param body List of user object
* @return [Call]<[Unit]>
*/
@POST("user/createWithList")
fun createUsersWithListInput(@Body body: kotlin.Array<User>): Call<Unit> fun createUsersWithListInput(@Body body: kotlin.Array<User>): Call<Unit>
@DELETE("/user/{username}") /**
* Delete user
* This can only be done by the logged in user.
* Responses:
* - 400: Invalid username supplied
* - 404: User not found
*
* @param username The name that needs to be deleted
* @return [Call]<[Unit]>
*/
@DELETE("user/{username}")
fun deleteUser(@Path("username") username: kotlin.String): Call<Unit> fun deleteUser(@Path("username") username: kotlin.String): Call<Unit>
@GET("/user/{username}") /**
* Get user by user name
*
* Responses:
* - 200: successful operation
* - 400: Invalid username supplied
* - 404: User not found
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @return [Call]<[User]>
*/
@GET("user/{username}")
fun getUserByName(@Path("username") username: kotlin.String): Call<User> fun getUserByName(@Path("username") username: kotlin.String): Call<User>
@GET("/user/login") /**
* Logs user into the system
*
* Responses:
* - 200: successful operation
* - 400: Invalid username/password supplied
*
* @param username The user name for login
* @param password The password for login in clear text
* @return [Call]<[kotlin.String]>
*/
@GET("user/login")
fun loginUser(@Query("username") username: kotlin.String, @Query("password") password: kotlin.String): Call<kotlin.String> fun loginUser(@Query("username") username: kotlin.String, @Query("password") password: kotlin.String): Call<kotlin.String>
@GET("/user/logout") /**
* Logs out current logged in user session
*
* Responses:
* - 0: successful operation
*
* @return [Call]<[Unit]>
*/
@GET("user/logout")
fun logoutUser(): Call<Unit> fun logoutUser(): Call<Unit>
@PUT("/user/{username}") /**
* Updated user
* This can only be done by the logged in user.
* Responses:
* - 400: Invalid user supplied
* - 404: User not found
*
* @param username name that need to be deleted
* @param body Updated user object
* @return [Call]<[Unit]>
*/
@PUT("user/{username}")
fun updateUser(@Path("username") username: kotlin.String, @Body body: User): Call<Unit> fun updateUser(@Path("username") username: kotlin.String, @Body body: User): Call<Unit>
} }

View File

@@ -0,0 +1,50 @@
package org.openapitools.client.auth
import java.io.IOException
import java.net.URI
import java.net.URISyntaxException
import okhttp3.Interceptor
import okhttp3.Response
class ApiKeyAuth(
private val location: String = "",
private val paramName: String = "",
private var apiKey: String = ""
) : Interceptor {
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {
var request = chain.request()
if ("query" == location) {
var newQuery = request.url.toUri().query
val paramValue = "$paramName=$apiKey"
if (newQuery == null) {
newQuery = paramValue
} else {
newQuery += "&$paramValue"
}
val newUri: URI
try {
val oldUri = request.url.toUri()
newUri = URI(oldUri.scheme, oldUri.authority,
oldUri.path, newQuery, oldUri.fragment)
} catch (e: URISyntaxException) {
throw IOException(e)
}
request = request.newBuilder().url(newUri.toURL()).build()
} else if ("header" == location) {
request = request.newBuilder()
.addHeader(paramName, apiKey)
.build()
} else if ("cookie" == location) {
request = request.newBuilder()
.addHeader("Cookie", "$paramName=$apiKey")
.build()
}
return chain.proceed(request)
}
}

View File

@@ -0,0 +1,151 @@
package org.openapitools.client.auth
import java.net.HttpURLConnection.HTTP_UNAUTHORIZED
import java.net.HttpURLConnection.HTTP_FORBIDDEN
import java.io.IOException
import org.apache.oltu.oauth2.client.OAuthClient
import org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest
import org.apache.oltu.oauth2.client.request.OAuthClientRequest
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder
import org.apache.oltu.oauth2.common.exception.OAuthProblemException
import org.apache.oltu.oauth2.common.exception.OAuthSystemException
import org.apache.oltu.oauth2.common.message.types.GrantType
import org.apache.oltu.oauth2.common.token.BasicOAuthToken
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.Response
class OAuth(
client: OkHttpClient,
var tokenRequestBuilder: TokenRequestBuilder
) : Interceptor {
interface AccessTokenListener {
fun notify(token: BasicOAuthToken)
}
private var oauthClient: OAuthClient = OAuthClient(OAuthOkHttpClient(client))
@Volatile
private var accessToken: String? = null
var authenticationRequestBuilder: AuthenticationRequestBuilder? = null
private var accessTokenListener: AccessTokenListener? = null
constructor(
requestBuilder: TokenRequestBuilder
) : this(
OkHttpClient(),
requestBuilder
)
constructor(
flow: OAuthFlow,
authorizationUrl: String,
tokenUrl: String,
scopes: String
) : this(
OAuthClientRequest.tokenLocation(tokenUrl).setScope(scopes)
) {
setFlow(flow);
authenticationRequestBuilder = OAuthClientRequest.authorizationLocation(authorizationUrl);
}
fun setFlow(flow: OAuthFlow) {
when (flow) {
OAuthFlow.accessCode, OAuthFlow.implicit ->
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE)
OAuthFlow.password ->
tokenRequestBuilder.setGrantType(GrantType.PASSWORD)
OAuthFlow.application ->
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS)
}
}
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {
return retryingIntercept(chain, true)
}
@Throws(IOException::class)
private fun retryingIntercept(chain: Interceptor.Chain, updateTokenAndRetryOnAuthorizationFailure: Boolean): Response {
var request = chain.request()
// If the request already have an authorization (eg. Basic auth), do nothing
if (request.header("Authorization") != null) {
return chain.proceed(request)
}
// If first time, get the token
val oAuthRequest: OAuthClientRequest
if (accessToken == null) {
updateAccessToken(null)
}
if (accessToken != null) {
// Build the request
val rb = request.newBuilder()
val requestAccessToken = accessToken
try {
oAuthRequest = OAuthBearerClientRequest(request.url.toString())
.setAccessToken(requestAccessToken)
.buildHeaderMessage()
} catch (e: OAuthSystemException) {
throw IOException(e)
}
oAuthRequest.headers.entries.forEach { header ->
rb.addHeader(header.key, header.value)
}
rb.url(oAuthRequest.locationUri)
//Execute the request
val response = chain.proceed(rb.build())
// 401/403 most likely indicates that access token has expired. Unless it happens two times in a row.
if ((response.code == HTTP_UNAUTHORIZED || response.code == HTTP_FORBIDDEN) && updateTokenAndRetryOnAuthorizationFailure) {
try {
if (updateAccessToken(requestAccessToken)) {
response.body?.close()
return retryingIntercept(chain, false)
}
} catch (e: Exception) {
response.body?.close()
throw e
}
}
return response
} else {
return chain.proceed(chain.request())
}
}
/**
* Returns true if the access token has been updated
*/
@Throws(IOException::class)
@Synchronized
fun updateAccessToken(requestAccessToken: String?): Boolean {
if (accessToken == null || accessToken.equals(requestAccessToken)) {
return try {
val accessTokenResponse = oauthClient.accessToken(this.tokenRequestBuilder.buildBodyMessage())
if (accessTokenResponse != null && accessTokenResponse.accessToken != null) {
accessToken = accessTokenResponse.accessToken
accessTokenListener?.notify(accessTokenResponse.oAuthToken as BasicOAuthToken)
!accessToken.equals(requestAccessToken)
} else {
false
}
} catch (e: OAuthSystemException) {
throw IOException(e)
} catch (e: OAuthProblemException) {
throw IOException(e)
}
}
return true;
}
}

View File

@@ -0,0 +1,5 @@
package org.openapitools.client.auth
enum class OAuthFlow {
accessCode, implicit, password, application
}

View File

@@ -0,0 +1,61 @@
package org.openapitools.client.auth
import java.io.IOException
import org.apache.oltu.oauth2.client.HttpClient
import org.apache.oltu.oauth2.client.request.OAuthClientRequest
import org.apache.oltu.oauth2.client.response.OAuthClientResponse
import org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory
import org.apache.oltu.oauth2.common.exception.OAuthProblemException
import org.apache.oltu.oauth2.common.exception.OAuthSystemException
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
class OAuthOkHttpClient(
private var client: OkHttpClient
) : HttpClient {
constructor() : this(OkHttpClient())
@Throws(OAuthSystemException::class, OAuthProblemException::class)
override fun <T : OAuthClientResponse?> execute(
request: OAuthClientRequest,
headers: Map<String, String>?,
requestMethod: String,
responseClass: Class<T>?): T {
var mediaType = "application/json".toMediaTypeOrNull()
val requestBuilder = Request.Builder().url(request.locationUri)
headers?.forEach { entry ->
if (entry.key.equals("Content-Type", true)) {
mediaType = entry.value.toMediaTypeOrNull()
} else {
requestBuilder.addHeader(entry.key, entry.value)
}
}
val body: RequestBody? = if (request.body != null) RequestBody.create(mediaType, request.body) else null
requestBuilder.method(requestMethod, body)
try {
val response = client.newCall(requestBuilder.build()).execute()
return OAuthClientResponseFactory.createCustomResponse(
response.body?.string(),
response.body?.contentType()?.toString(),
response.code,
responseClass)
} catch (e: IOException) {
throw OAuthSystemException(e)
}
}
override fun shutdown() {
// Nothing to do here
}
}

View File

@@ -1,35 +1,177 @@
package org.openapitools.client.infrastructure package org.openapitools.client.infrastructure
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder
import org.openapitools.client.auth.ApiKeyAuth
import org.openapitools.client.auth.OAuth
import org.openapitools.client.auth.OAuth.AccessTokenListener
import org.openapitools.client.auth.OAuthFlow
import okhttp3.Interceptor
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import retrofit2.Retrofit import retrofit2.Retrofit
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.converter.scalars.ScalarsConverterFactory import retrofit2.converter.scalars.ScalarsConverterFactory
import com.squareup.moshi.Moshi
import retrofit2.converter.moshi.MoshiConverterFactory import retrofit2.converter.moshi.MoshiConverterFactory
class ApiClient( class ApiClient(
private var baseUrl: String = defaultBasePath, private var baseUrl: String = defaultBasePath,
private var okHttpClient: OkHttpClient private val okHttpClientBuilder: OkHttpClient.Builder? = null,
private val serializerBuilder: Moshi.Builder = Serializer.moshiBuilder
) { ) {
companion object { private val apiAuthorizations = mutableMapOf<String, Interceptor>()
@JvmStatic var logger: ((String) -> Unit)? = null
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2") private val retrofitBuilder: Retrofit.Builder by lazy {
} Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(MoshiConverterFactory.create(serializerBuilder.build()))
}
private val clientBuilder: OkHttpClient.Builder by lazy {
okHttpClientBuilder ?: defaultClientBuilder
}
private val defaultClientBuilder: OkHttpClient.Builder by lazy {
OkHttpClient()
.newBuilder()
.addInterceptor(HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger {
override fun log(message: String) {
logger?.invoke(message)
}
}).apply {
level = HttpLoggingInterceptor.Level.BODY
})
} }
init { init {
normalizeBaseUrl() normalizeBaseUrl()
} }
val retrofitBuilder: Retrofit.Builder by lazy { constructor(
baseUrl: String = defaultBasePath,
okHttpClientBuilder: OkHttpClient.Builder? = null,
serializerBuilder: Moshi.Builder = Serializer.moshiBuilder,
authNames: Array<String>
) : this(baseUrl, okHttpClientBuilder, serializerBuilder) {
authNames.forEach { authName ->
val auth = when (authName) {
"api_key" -> ApiKeyAuth("header", "api_key")"petstore_auth" -> OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets")
else -> throw RuntimeException("auth name $authName not found in available auth names")
}
addAuthorization(authName, auth);
}
}
Retrofit.Builder() constructor(
.baseUrl(baseUrl) baseUrl: String = defaultBasePath,
.addConverterFactory(ScalarsConverterFactory.create()) okHttpClientBuilder: OkHttpClient.Builder? = null,
.addConverterFactory(MoshiConverterFactory.create(Serializer.moshi)) serializerBuilder: Moshi.Builder = Serializer.moshiBuilder,
authName: String,
clientId: String,
secret: String,
username: String,
password: String
) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) {
getTokenEndPoint()
?.setClientId(clientId)
?.setClientSecret(secret)
?.setUsername(username)
?.setPassword(password)
}
/**
* Helper method to configure the token endpoint of the first oauth found in the apiAuthorizations (there should be only one)
* @return Token request builder
*/
fun getTokenEndPoint(): TokenRequestBuilder? {
var result: TokenRequestBuilder? = null
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
result = tokenRequestBuilder
}
return result
}
/**
* Helper method to configure authorization endpoint of the first oauth found in the apiAuthorizations (there should be only one)
* @return Authentication request builder
*/
fun getAuthorizationEndPoint(): AuthenticationRequestBuilder? {
var result: AuthenticationRequestBuilder? = null
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
result = authenticationRequestBuilder
}
return result
}
/**
* Helper method to pre-set the oauth access token of the first oauth found in the apiAuthorizations (there should be only one)
* @param accessToken Access token
* @return ApiClient
*/
fun setAccessToken(accessToken: String): ApiClient {
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
setAccessToken(accessToken)
}
return this
}
/**
* Helper method to configure the oauth accessCode/implicit flow parameters
* @param clientId Client ID
* @param clientSecret Client secret
* @param redirectURI Redirect URI
* @return ApiClient
*/
fun configureAuthorizationFlow(clientId: String, clientSecret: String, redirectURI: String): ApiClient {
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
tokenRequestBuilder
.setClientId(clientId)
.setClientSecret(clientSecret)
.setRedirectURI(redirectURI)
authenticationRequestBuilder
?.setClientId(clientId)
?.setRedirectURI(redirectURI)
}
return this;
}
/**
* Configures a listener which is notified when a new access token is received.
* @param accessTokenListener Access token listener
* @return ApiClient
*/
fun registerAccessTokenListener(accessTokenListener: AccessTokenListener): ApiClient {
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
registerAccessTokenListener(accessTokenListener)
}
return this;
}
/**
* Adds an authorization to be used by the client
* @param authName Authentication name
* @param authorization Authorization interceptor
* @return ApiClient
*/
fun addAuthorization(authName: String, authorization: Interceptor): ApiClient {
if (apiAuthorizations.containsKey(authName)) {
throw RuntimeException("auth name $authName already in api authorizations")
}
apiAuthorizations[authName] = authorization
clientBuilder.addInterceptor(authorization)
return this
}
fun setLogger(logger: (String) -> Unit): ApiClient {
this.logger = logger
return this
} }
fun <S> createService(serviceClass: Class<S>): S { fun <S> createService(serviceClass: Class<S>): S {
return retrofitBuilder.client(okHttpClient).build().create(serviceClass) return retrofitBuilder.client(clientBuilder.build()).build().create(serviceClass)
} }
private fun normalizeBaseUrl() { private fun normalizeBaseUrl() {
@@ -37,4 +179,20 @@ class ApiClient(
baseUrl += "/" baseUrl += "/"
} }
} }
private inline fun <T, reified U> Iterable<T>.runOnFirst(callback: U.() -> Unit) {
for (element in this) {
if (element is U) {
callback.invoke(element)
break
}
}
}
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
}
}
} }

View File

@@ -0,0 +1,16 @@
package org.openapitools.client.infrastructure
import com.squareup.moshi.JsonDataException
import com.squareup.moshi.Moshi
import retrofit2.Response
@Throws(JsonDataException::class)
inline fun <reified T> Response<*>.getErrorResponse(serializerBuilder: Moshi.Builder = Serializer.moshiBuilder): T? {
val serializer = serializerBuilder.build()
val parser = serializer.adapter(T::class.java)
val response = errorBody()?.string()
if(response != null) {
return parser.fromJson(response)
}
return null
}

View File

@@ -2,7 +2,7 @@
## Requires ## Requires
* Kotlin 1.3.41 * Kotlin 1.3.61
* Gradle 4.9 * Gradle 4.9
## Build ## Build

View File

@@ -29,9 +29,11 @@ test {
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.9.2" compile "com.squareup.moshi:moshi-kotlin:1.9.2"
compile "com.squareup.moshi:moshi-adapters:1.9.2" compile "com.squareup.moshi:moshi-adapters:1.9.2"
compile "com.squareup.okhttp3:okhttp:4.2.2" compile "com.squareup.okhttp3:okhttp:4.2.2"
compile "com.squareup.okhttp3:logging-interceptor:4.4.0"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0"
} }

View File

@@ -2,7 +2,7 @@
## Requires ## Requires
* Kotlin 1.3.41 * Kotlin 1.3.61
* Gradle 4.9 * Gradle 4.9
## Build ## Build

View File

@@ -29,10 +29,12 @@ test {
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.9.2" compile "com.squareup.moshi:moshi-kotlin:1.9.2"
compile "com.squareup.moshi:moshi-adapters:1.9.2" compile "com.squareup.moshi:moshi-adapters:1.9.2"
compile "com.squareup.okhttp3:okhttp:4.2.2" compile "com.squareup.okhttp3:okhttp:4.2.2"
compile "com.squareup.okhttp3:logging-interceptor:4.4.0"
compile "org.threeten:threetenbp:1.4.0" compile "org.threeten:threetenbp:1.4.0"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0"
} }

View File

@@ -2,7 +2,7 @@
## Requires ## Requires
* Kotlin 1.3.41 * Kotlin 1.3.61
* Gradle 4.9 * Gradle 4.9
## Build ## Build

View File

@@ -29,9 +29,11 @@ test {
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.9.2" compile "com.squareup.moshi:moshi-kotlin:1.9.2"
compile "com.squareup.moshi:moshi-adapters:1.9.2" compile "com.squareup.moshi:moshi-adapters:1.9.2"
compile "com.squareup.okhttp3:okhttp:4.2.2" compile "com.squareup.okhttp3:okhttp:4.2.2"
compile "com.squareup.okhttp3:logging-interceptor:4.4.0"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0" testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0"
} }

View File

@@ -64,6 +64,72 @@ src/main/kotlin/org/openapitools/client/apis/FakeClassnameTags123Api.kt
src/main/kotlin/org/openapitools/client/apis/PetApi.kt 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/StoreApi.kt
src/main/kotlin/org/openapitools/client/apis/UserApi.kt src/main/kotlin/org/openapitools/client/apis/UserApi.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt
src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt
@@ -71,6 +137,7 @@ src/main/kotlin/org/openapitools/client/infrastructure/DateAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.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/LocalDateTimeAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/ResponseExt.kt
src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
src/main/kotlin/org/openapitools/client/models/AdditionalPropertiesClass.kt src/main/kotlin/org/openapitools/client/models/AdditionalPropertiesClass.kt
src/main/kotlin/org/openapitools/client/models/Animal.kt src/main/kotlin/org/openapitools/client/models/Animal.kt

View File

@@ -2,7 +2,7 @@
## Requires ## Requires
* Kotlin 1.3.41 * Kotlin 1.3.61
* Gradle 4.9 * Gradle 4.9
## Build ## Build
@@ -35,45 +35,45 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Class | Method | HTTP request | Description Class | Method | HTTP request | Description
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
*AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags *AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **PATCH** another-fake/dummy | To test special tags
*DefaultApi* | [**fooGet**](docs/DefaultApi.md#fooget) | **GET** /foo | *DefaultApi* | [**fooGet**](docs/DefaultApi.md#fooget) | **GET** foo |
*FakeApi* | [**fakeHealthGet**](docs/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint *FakeApi* | [**fakeHealthGet**](docs/FakeApi.md#fakehealthget) | **GET** fake/health | Health check endpoint
*FakeApi* | [**fakeHttpSignatureTest**](docs/FakeApi.md#fakehttpsignaturetest) | **GET** /fake/http-signature-test | test http signature authentication *FakeApi* | [**fakeHttpSignatureTest**](docs/FakeApi.md#fakehttpsignaturetest) | **GET** fake/http-signature-test | test http signature authentication
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | *FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** fake/outer/boolean |
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | *FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** fake/outer/composite |
*FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | *FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** fake/outer/number |
*FakeApi* | [**fakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | *FakeApi* | [**fakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **POST** fake/outer/string |
*FakeApi* | [**testBodyWithFileSchema**](docs/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**testBodyWithFileSchema**](docs/FakeApi.md#testbodywithfileschema) | **PUT** fake/body-with-file-schema |
*FakeApi* | [**testBodyWithQueryParams**](docs/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | *FakeApi* | [**testBodyWithQueryParams**](docs/FakeApi.md#testbodywithqueryparams) | **PUT** fake/body-with-query-params |
*FakeApi* | [**testClientModel**](docs/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model *FakeApi* | [**testClientModel**](docs/FakeApi.md#testclientmodel) | **PATCH** fake | To test \"client\" model
*FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **POST** fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters *FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testenumparameters) | **GET** fake | To test enum parameters
*FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testgroupparameters) | **DELETE** fake | Fake endpoint to test group parameters (optional)
*FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testinlineadditionalproperties) | **POST** fake/inline-additionalProperties | test inline additionalProperties
*FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testjsonformdata) | **GET** fake/jsonFormData | test json serialization of form data
*FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-paramters | *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testqueryparametercollectionformat) | **PUT** fake/test-query-paramters |
*FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testclassname) | **PATCH** fake_classname_test | To test class name in snake case
*PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store *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* | [**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* | [**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* | [**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* | [**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* | [**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* | [**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 *PetApi* | [**uploadFile**](docs/PetApi.md#uploadfile) | **POST** pet/{petId}/uploadImage | uploads an image
*PetApi* | [**uploadFileWithRequiredFile**](docs/PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) *PetApi* | [**uploadFileWithRequiredFile**](docs/PetApi.md#uploadfilewithrequiredfile) | **POST** fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID *StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** store/order/{order_id} | Delete purchase order by ID
*StoreApi* | [**getInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**getInventory**](docs/StoreApi.md#getinventory) | **GET** store/inventory | Returns pet inventories by status
*StoreApi* | [**getOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID *StoreApi* | [**getOrderById**](docs/StoreApi.md#getorderbyid) | **GET** store/order/{order_id} | Find purchase order by ID
*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet *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* | [**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* | [**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* | [**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* | [**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* | [**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* | [**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* | [**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 *UserApi* | [**updateUser**](docs/UserApi.md#updateuser) | **PUT** user/{username} | Updated user
<a name="documentation-for-models"></a> <a name="documentation-for-models"></a>

View File

@@ -30,6 +30,7 @@ test {
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0"
compile "com.google.code.gson:gson:2.8.6" compile "com.google.code.gson:gson:2.8.6"
compile "com.squareup.retrofit2:retrofit:$retrofitVersion" compile "com.squareup.retrofit2:retrofit:$retrofitVersion"
compile "com.squareup.retrofit2:converter-gson:$retrofitVersion" compile "com.squareup.retrofit2:converter-gson:$retrofitVersion"

View File

@@ -4,12 +4,9 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**call123testSpecialTags**](AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags [**call123testSpecialTags**](AnotherFakeApi.md#call123testSpecialTags) | **PATCH** another-fake/dummy | To test special tags
<a name="call123testSpecialTags"></a>
# **call123testSpecialTags**
> Client call123testSpecialTags(client)
To test special tags To test special tags
@@ -18,20 +15,16 @@ To test special tags and operation ID starting with number
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = AnotherFakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(AnotherFakeApi::class.java)
val client : Client = // Client | client model val client : Client = // Client | client model
try {
val result : Client = apiInstance.call123testSpecialTags(client) launch(Dispatchers.IO) {
println(result) val result : Client = webService.call123testSpecialTags(client)
} catch (e: ClientException) {
println("4xx response calling AnotherFakeApi#call123testSpecialTags")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling AnotherFakeApi#call123testSpecialTags")
e.printStackTrace()
} }
``` ```

View File

@@ -4,31 +4,24 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**fooGet**](DefaultApi.md#fooGet) | **GET** /foo | [**fooGet**](DefaultApi.md#fooGet) | **GET** foo |
<a name="fooGet"></a>
# **fooGet**
> InlineResponseDefault fooGet()
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = DefaultApi() val apiClient = ApiClient()
try { val webService = apiClient.createWebservice(DefaultApi::class.java)
val result : InlineResponseDefault = apiInstance.fooGet()
println(result) launch(Dispatchers.IO) {
} catch (e: ClientException) { val result : InlineResponseDefault = webService.fooGet()
println("4xx response calling DefaultApi#fooGet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling DefaultApi#fooGet")
e.printStackTrace()
} }
``` ```

View File

@@ -4,45 +4,38 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**fakeHealthGet**](FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint [**fakeHealthGet**](FakeApi.md#fakeHealthGet) | **GET** fake/health | Health check endpoint
[**fakeHttpSignatureTest**](FakeApi.md#fakeHttpSignatureTest) | **GET** /fake/http-signature-test | test http signature authentication [**fakeHttpSignatureTest**](FakeApi.md#fakeHttpSignatureTest) | **GET** fake/http-signature-test | test http signature authentication
[**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | [**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** fake/outer/boolean |
[**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | [**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** fake/outer/composite |
[**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | [**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** fake/outer/number |
[**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | [**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** fake/outer/string |
[**testBodyWithFileSchema**](FakeApi.md#testBodyWithFileSchema) | **PUT** /fake/body-with-file-schema | [**testBodyWithFileSchema**](FakeApi.md#testBodyWithFileSchema) | **PUT** fake/body-with-file-schema |
[**testBodyWithQueryParams**](FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params | [**testBodyWithQueryParams**](FakeApi.md#testBodyWithQueryParams) | **PUT** fake/body-with-query-params |
[**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \&quot;client\&quot; model [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** fake | To test \&quot;client\&quot; model
[**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
[**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** fake | To test enum parameters
[**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** fake | Fake endpoint to test group parameters (optional)
[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** fake/inline-additionalProperties | test inline additionalProperties
[**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** fake/jsonFormData | test json serialization of form data
[**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-paramters | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** fake/test-query-paramters |
<a name="fakeHealthGet"></a>
# **fakeHealthGet**
> HealthCheckResult fakeHealthGet()
Health check endpoint Health check endpoint
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
try { val webService = apiClient.createWebservice(FakeApi::class.java)
val result : HealthCheckResult = apiInstance.fakeHealthGet()
println(result) launch(Dispatchers.IO) {
} catch (e: ClientException) { val result : HealthCheckResult = webService.fakeHealthGet()
println("4xx response calling FakeApi#fakeHealthGet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#fakeHealthGet")
e.printStackTrace()
} }
``` ```
@@ -62,30 +55,24 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/json - **Accept**: application/json
<a name="fakeHttpSignatureTest"></a>
# **fakeHttpSignatureTest**
> fakeHttpSignatureTest(pet, query1, header1)
test http signature authentication test http signature authentication
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val pet : Pet = // Pet | Pet object that needs to be added to the store val pet : Pet = // Pet | Pet object that needs to be added to the store
val query1 : kotlin.String = query1_example // kotlin.String | query parameter val query1 : kotlin.String = query1_example // kotlin.String | query parameter
val header1 : kotlin.String = header1_example // kotlin.String | header parameter val header1 : kotlin.String = header1_example // kotlin.String | header parameter
try {
apiInstance.fakeHttpSignatureTest(pet, query1, header1) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.fakeHttpSignatureTest(pet, query1, header1)
println("4xx response calling FakeApi#fakeHttpSignatureTest")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#fakeHttpSignatureTest")
e.printStackTrace()
} }
``` ```
@@ -110,9 +97,6 @@ null (empty response body)
- **Content-Type**: application/json, application/xml - **Content-Type**: application/json, application/xml
- **Accept**: Not defined - **Accept**: Not defined
<a name="fakeOuterBooleanSerialize"></a>
# **fakeOuterBooleanSerialize**
> kotlin.Boolean fakeOuterBooleanSerialize(body)
@@ -121,20 +105,16 @@ Test serialization of outer boolean types
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val body : kotlin.Boolean = true // kotlin.Boolean | Input boolean as post body val body : kotlin.Boolean = true // kotlin.Boolean | Input boolean as post body
try {
val result : kotlin.Boolean = apiInstance.fakeOuterBooleanSerialize(body) launch(Dispatchers.IO) {
println(result) val result : kotlin.Boolean = webService.fakeOuterBooleanSerialize(body)
} catch (e: ClientException) {
println("4xx response calling FakeApi#fakeOuterBooleanSerialize")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#fakeOuterBooleanSerialize")
e.printStackTrace()
} }
``` ```
@@ -157,9 +137,6 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: */* - **Accept**: */*
<a name="fakeOuterCompositeSerialize"></a>
# **fakeOuterCompositeSerialize**
> OuterComposite fakeOuterCompositeSerialize(outerComposite)
@@ -168,20 +145,16 @@ Test serialization of object with outer number type
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val outerComposite : OuterComposite = // OuterComposite | Input composite as post body val outerComposite : OuterComposite = // OuterComposite | Input composite as post body
try {
val result : OuterComposite = apiInstance.fakeOuterCompositeSerialize(outerComposite) launch(Dispatchers.IO) {
println(result) val result : OuterComposite = webService.fakeOuterCompositeSerialize(outerComposite)
} catch (e: ClientException) {
println("4xx response calling FakeApi#fakeOuterCompositeSerialize")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#fakeOuterCompositeSerialize")
e.printStackTrace()
} }
``` ```
@@ -204,9 +177,6 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: */* - **Accept**: */*
<a name="fakeOuterNumberSerialize"></a>
# **fakeOuterNumberSerialize**
> java.math.BigDecimal fakeOuterNumberSerialize(body)
@@ -215,20 +185,16 @@ Test serialization of outer number types
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val body : java.math.BigDecimal = 8.14 // java.math.BigDecimal | Input number as post body val body : java.math.BigDecimal = 8.14 // java.math.BigDecimal | Input number as post body
try {
val result : java.math.BigDecimal = apiInstance.fakeOuterNumberSerialize(body) launch(Dispatchers.IO) {
println(result) val result : java.math.BigDecimal = webService.fakeOuterNumberSerialize(body)
} catch (e: ClientException) {
println("4xx response calling FakeApi#fakeOuterNumberSerialize")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#fakeOuterNumberSerialize")
e.printStackTrace()
} }
``` ```
@@ -251,9 +217,6 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: */* - **Accept**: */*
<a name="fakeOuterStringSerialize"></a>
# **fakeOuterStringSerialize**
> kotlin.String fakeOuterStringSerialize(body)
@@ -262,20 +225,16 @@ Test serialization of outer string types
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val body : kotlin.String = body_example // kotlin.String | Input string as post body val body : kotlin.String = body_example // kotlin.String | Input string as post body
try {
val result : kotlin.String = apiInstance.fakeOuterStringSerialize(body) launch(Dispatchers.IO) {
println(result) val result : kotlin.String = webService.fakeOuterStringSerialize(body)
} catch (e: ClientException) {
println("4xx response calling FakeApi#fakeOuterStringSerialize")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#fakeOuterStringSerialize")
e.printStackTrace()
} }
``` ```
@@ -298,9 +257,6 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: */* - **Accept**: */*
<a name="testBodyWithFileSchema"></a>
# **testBodyWithFileSchema**
> testBodyWithFileSchema(fileSchemaTestClass)
@@ -309,19 +265,16 @@ For this test, the body for this request much reference a schema named &#x60;Fil
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val fileSchemaTestClass : FileSchemaTestClass = // FileSchemaTestClass | val fileSchemaTestClass : FileSchemaTestClass = // FileSchemaTestClass |
try {
apiInstance.testBodyWithFileSchema(fileSchemaTestClass) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.testBodyWithFileSchema(fileSchemaTestClass)
println("4xx response calling FakeApi#testBodyWithFileSchema")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testBodyWithFileSchema")
e.printStackTrace()
} }
``` ```
@@ -344,29 +297,23 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: Not defined - **Accept**: Not defined
<a name="testBodyWithQueryParams"></a>
# **testBodyWithQueryParams**
> testBodyWithQueryParams(query, user)
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val query : kotlin.String = query_example // kotlin.String | val query : kotlin.String = query_example // kotlin.String |
val user : User = // User | val user : User = // User |
try {
apiInstance.testBodyWithQueryParams(query, user) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.testBodyWithQueryParams(query, user)
println("4xx response calling FakeApi#testBodyWithQueryParams")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testBodyWithQueryParams")
e.printStackTrace()
} }
``` ```
@@ -390,9 +337,6 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: Not defined - **Accept**: Not defined
<a name="testClientModel"></a>
# **testClientModel**
> Client testClientModel(client)
To test \&quot;client\&quot; model To test \&quot;client\&quot; model
@@ -401,20 +345,16 @@ To test \&quot;client\&quot; model
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val client : Client = // Client | client model val client : Client = // Client | client model
try {
val result : Client = apiInstance.testClientModel(client) launch(Dispatchers.IO) {
println(result) val result : Client = webService.testClientModel(client)
} catch (e: ClientException) {
println("4xx response calling FakeApi#testClientModel")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testClientModel")
e.printStackTrace()
} }
``` ```
@@ -437,9 +377,6 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: application/json - **Accept**: application/json
<a name="testEndpointParameters"></a>
# **testEndpointParameters**
> testEndpointParameters(number, double, patternWithoutDelimiter, byte, integer, int32, int64, float, string, binary, date, dateTime, password, paramCallback)
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@@ -448,10 +385,13 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
apiClient.setCredentials("USERNAME", "PASSWORD")
val webService = apiClient.createWebservice(FakeApi::class.java)
val number : java.math.BigDecimal = 8.14 // java.math.BigDecimal | None val number : java.math.BigDecimal = 8.14 // java.math.BigDecimal | None
val double : kotlin.Double = 1.2 // kotlin.Double | None val double : kotlin.Double = 1.2 // kotlin.Double | None
val patternWithoutDelimiter : kotlin.String = patternWithoutDelimiter_example // kotlin.String | None val patternWithoutDelimiter : kotlin.String = patternWithoutDelimiter_example // kotlin.String | None
@@ -466,14 +406,9 @@ val date : java.time.LocalDate = 2013-10-20 // java.time.LocalDate | None
val dateTime : java.time.OffsetDateTime = 2013-10-20T19:20:30+01:00 // java.time.OffsetDateTime | None val dateTime : java.time.OffsetDateTime = 2013-10-20T19:20:30+01:00 // java.time.OffsetDateTime | None
val password : kotlin.String = password_example // kotlin.String | None val password : kotlin.String = password_example // kotlin.String | None
val paramCallback : kotlin.String = paramCallback_example // kotlin.String | None val paramCallback : kotlin.String = paramCallback_example // kotlin.String | None
try {
apiInstance.testEndpointParameters(number, double, patternWithoutDelimiter, byte, integer, int32, int64, float, string, binary, date, dateTime, password, paramCallback) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.testEndpointParameters(number, double, patternWithoutDelimiter, byte, integer, int32, int64, float, string, binary, date, dateTime, password, paramCallback)
println("4xx response calling FakeApi#testEndpointParameters")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testEndpointParameters")
e.printStackTrace()
} }
``` ```
@@ -504,17 +439,13 @@ null (empty response body)
Configure http_basic_test: Configure http_basic_test:
ApiClient.username = "" ApiClient().setCredentials("USERNAME", "PASSWORD")
ApiClient.password = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: application/x-www-form-urlencoded - **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined - **Accept**: Not defined
<a name="testEnumParameters"></a>
# **testEnumParameters**
> testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString)
To test enum parameters To test enum parameters
@@ -523,10 +454,12 @@ To test enum parameters
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val enumHeaderStringArray : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Header parameter enum test (string array) val enumHeaderStringArray : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Header parameter enum test (string array)
val enumHeaderString : kotlin.String = enumHeaderString_example // kotlin.String | Header parameter enum test (string) val enumHeaderString : kotlin.String = enumHeaderString_example // kotlin.String | Header parameter enum test (string)
val enumQueryStringArray : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Query parameter enum test (string array) val enumQueryStringArray : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Query parameter enum test (string array)
@@ -535,14 +468,9 @@ val enumQueryInteger : kotlin.Int = 56 // kotlin.Int | Query parameter enum test
val enumQueryDouble : kotlin.Double = 1.2 // kotlin.Double | Query parameter enum test (double) val enumQueryDouble : kotlin.Double = 1.2 // kotlin.Double | Query parameter enum test (double)
val enumFormStringArray : kotlin.Array<kotlin.String> = enumFormStringArray_example // kotlin.Array<kotlin.String> | Form parameter enum test (string array) val enumFormStringArray : kotlin.Array<kotlin.String> = enumFormStringArray_example // kotlin.Array<kotlin.String> | Form parameter enum test (string array)
val enumFormString : kotlin.String = enumFormString_example // kotlin.String | Form parameter enum test (string) val enumFormString : kotlin.String = enumFormString_example // kotlin.String | Form parameter enum test (string)
try {
apiInstance.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString)
println("4xx response calling FakeApi#testEnumParameters")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testEnumParameters")
e.printStackTrace()
} }
``` ```
@@ -572,9 +500,6 @@ No authorization required
- **Content-Type**: application/x-www-form-urlencoded - **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined - **Accept**: Not defined
<a name="testGroupParameters"></a>
# **testGroupParameters**
> testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group)
Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional)
@@ -583,24 +508,22 @@ Fake endpoint to test group parameters (optional)
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
apiClient.setBearerToken("TOKEN")
val webService = apiClient.createWebservice(FakeApi::class.java)
val requiredStringGroup : kotlin.Int = 56 // kotlin.Int | Required String in group parameters val requiredStringGroup : kotlin.Int = 56 // kotlin.Int | Required String in group parameters
val requiredBooleanGroup : kotlin.Boolean = true // kotlin.Boolean | Required Boolean in group parameters val requiredBooleanGroup : kotlin.Boolean = true // kotlin.Boolean | Required Boolean in group parameters
val requiredInt64Group : kotlin.Long = 789 // kotlin.Long | Required Integer in group parameters val requiredInt64Group : kotlin.Long = 789 // kotlin.Long | Required Integer in group parameters
val stringGroup : kotlin.Int = 56 // kotlin.Int | String in group parameters val stringGroup : kotlin.Int = 56 // kotlin.Int | String in group parameters
val booleanGroup : kotlin.Boolean = true // kotlin.Boolean | Boolean in group parameters val booleanGroup : kotlin.Boolean = true // kotlin.Boolean | Boolean in group parameters
val int64Group : kotlin.Long = 789 // kotlin.Long | Integer in group parameters val int64Group : kotlin.Long = 789 // kotlin.Long | Integer in group parameters
try {
apiInstance.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group)
println("4xx response calling FakeApi#testGroupParameters")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testGroupParameters")
e.printStackTrace()
} }
``` ```
@@ -623,35 +546,29 @@ null (empty response body)
Configure bearer_test: Configure bearer_test:
ApiClient.accessToken = "" ApiClient().setBearerToken("TOKEN")
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: Not defined - **Accept**: Not defined
<a name="testInlineAdditionalProperties"></a>
# **testInlineAdditionalProperties**
> testInlineAdditionalProperties(requestBody)
test inline additionalProperties test inline additionalProperties
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val requestBody : kotlin.collections.Map<kotlin.String, kotlin.String> = // kotlin.collections.Map<kotlin.String, kotlin.String> | request body val requestBody : kotlin.collections.Map<kotlin.String, kotlin.String> = // kotlin.collections.Map<kotlin.String, kotlin.String> | request body
try {
apiInstance.testInlineAdditionalProperties(requestBody) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.testInlineAdditionalProperties(requestBody)
println("4xx response calling FakeApi#testInlineAdditionalProperties")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testInlineAdditionalProperties")
e.printStackTrace()
} }
``` ```
@@ -674,29 +591,23 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: Not defined - **Accept**: Not defined
<a name="testJsonFormData"></a>
# **testJsonFormData**
> testJsonFormData(param, param2)
test json serialization of form data test json serialization of form data
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val param : kotlin.String = param_example // kotlin.String | field1 val param : kotlin.String = param_example // kotlin.String | field1
val param2 : kotlin.String = param2_example // kotlin.String | field2 val param2 : kotlin.String = param2_example // kotlin.String | field2
try {
apiInstance.testJsonFormData(param, param2) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.testJsonFormData(param, param2)
println("4xx response calling FakeApi#testJsonFormData")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testJsonFormData")
e.printStackTrace()
} }
``` ```
@@ -720,9 +631,6 @@ No authorization required
- **Content-Type**: application/x-www-form-urlencoded - **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined - **Accept**: Not defined
<a name="testQueryParameterCollectionFormat"></a>
# **testQueryParameterCollectionFormat**
> testQueryParameterCollectionFormat(pipe, ioutil, http, url, context)
@@ -731,23 +639,20 @@ To test the collection format in query parameters
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val pipe : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | val pipe : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> |
val ioutil : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | val ioutil : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> |
val http : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | val http : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> |
val url : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | val url : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> |
val context : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | val context : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> |
try {
apiInstance.testQueryParameterCollectionFormat(pipe, ioutil, http, url, context) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.testQueryParameterCollectionFormat(pipe, ioutil, http, url, context)
println("4xx response calling FakeApi#testQueryParameterCollectionFormat")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testQueryParameterCollectionFormat")
e.printStackTrace()
} }
``` ```

View File

@@ -4,12 +4,9 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case [**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** fake_classname_test | To test class name in snake case
<a name="testClassname"></a>
# **testClassname**
> Client testClassname(client)
To test class name in snake case To test class name in snake case
@@ -18,20 +15,16 @@ To test class name in snake case
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeClassnameTags123Api() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeClassnameTags123Api::class.java)
val client : Client = // Client | client model val client : Client = // Client | client model
try {
val result : Client = apiInstance.testClassname(client) launch(Dispatchers.IO) {
println(result) val result : Client = webService.testClassname(client)
} catch (e: ClientException) {
println("4xx response calling FakeClassnameTags123Api#testClassname")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeClassnameTags123Api#testClassname")
e.printStackTrace()
} }
``` ```
@@ -48,9 +41,6 @@ Name | Type | Description | Notes
### Authorization ### Authorization
Configure api_key_query:
ApiClient.apiKey["api_key_query"] = ""
ApiClient.apiKeyPrefix["api_key_query"] = ""
### HTTP request headers ### HTTP request headers

View File

@@ -4,39 +4,33 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store [**addPet**](PetApi.md#addPet) | **POST** pet | Add a new pet to the store
[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet [**deletePet**](PetApi.md#deletePet) | **DELETE** pet/{petId} | Deletes a pet
[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status [**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** pet/findByStatus | Finds Pets by status
[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags [**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** pet/findByTags | Finds Pets by tags
[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID [**getPetById**](PetApi.md#getPetById) | **GET** pet/{petId} | Find pet by ID
[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**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 [**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 [**uploadFile**](PetApi.md#uploadFile) | **POST** pet/{petId}/uploadImage | uploads an image
[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) [**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
<a name="addPet"></a>
# **addPet**
> addPet(pet)
Add a new pet to the store Add a new pet to the store
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val pet : Pet = // Pet | Pet object that needs to be added to the store val pet : Pet = // Pet | Pet object that needs to be added to the store
try {
apiInstance.addPet(pet) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.addPet(pet)
println("4xx response calling PetApi#addPet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#addPet")
e.printStackTrace()
} }
``` ```
@@ -53,37 +47,29 @@ null (empty response body)
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: application/json, application/xml - **Content-Type**: application/json, application/xml
- **Accept**: Not defined - **Accept**: Not defined
<a name="deletePet"></a>
# **deletePet**
> deletePet(petId, apiKey)
Deletes a pet Deletes a pet
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val petId : kotlin.Long = 789 // kotlin.Long | Pet id to delete val petId : kotlin.Long = 789 // kotlin.Long | Pet id to delete
val apiKey : kotlin.String = apiKey_example // kotlin.String | val apiKey : kotlin.String = apiKey_example // kotlin.String |
try {
apiInstance.deletePet(petId, apiKey) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.deletePet(petId, apiKey)
println("4xx response calling PetApi#deletePet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#deletePet")
e.printStackTrace()
} }
``` ```
@@ -101,17 +87,12 @@ null (empty response body)
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: Not defined - **Accept**: Not defined
<a name="findPetsByStatus"></a>
# **findPetsByStatus**
> kotlin.Array&lt;Pet&gt; findPetsByStatus(status)
Finds Pets by status Finds Pets by status
@@ -120,20 +101,16 @@ Multiple status values can be provided with comma separated strings
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val status : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Status values that need to be considered for filter val status : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Status values that need to be considered for filter
try {
val result : kotlin.Array<Pet> = apiInstance.findPetsByStatus(status) launch(Dispatchers.IO) {
println(result) val result : kotlin.Array<Pet> = webService.findPetsByStatus(status)
} catch (e: ClientException) {
println("4xx response calling PetApi#findPetsByStatus")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#findPetsByStatus")
e.printStackTrace()
} }
``` ```
@@ -150,17 +127,12 @@ Name | Type | Description | Notes
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="findPetsByTags"></a>
# **findPetsByTags**
> kotlin.Array&lt;Pet&gt; findPetsByTags(tags)
Finds Pets by tags Finds Pets by tags
@@ -169,20 +141,16 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val tags : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Tags to filter by val tags : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Tags to filter by
try {
val result : kotlin.Array<Pet> = apiInstance.findPetsByTags(tags) launch(Dispatchers.IO) {
println(result) val result : kotlin.Array<Pet> = webService.findPetsByTags(tags)
} catch (e: ClientException) {
println("4xx response calling PetApi#findPetsByTags")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#findPetsByTags")
e.printStackTrace()
} }
``` ```
@@ -199,17 +167,12 @@ Name | Type | Description | Notes
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="getPetById"></a>
# **getPetById**
> Pet getPetById(petId)
Find pet by ID Find pet by ID
@@ -218,20 +181,16 @@ Returns a single pet
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to return val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to return
try {
val result : Pet = apiInstance.getPetById(petId) launch(Dispatchers.IO) {
println(result) val result : Pet = webService.getPetById(petId)
} catch (e: ClientException) {
println("4xx response calling PetApi#getPetById")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#getPetById")
e.printStackTrace()
} }
``` ```
@@ -248,37 +207,28 @@ Name | Type | Description | Notes
### Authorization ### Authorization
Configure api_key:
ApiClient.apiKey["api_key"] = ""
ApiClient.apiKeyPrefix["api_key"] = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="updatePet"></a>
# **updatePet**
> updatePet(pet)
Update an existing pet Update an existing pet
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val pet : Pet = // Pet | Pet object that needs to be added to the store val pet : Pet = // Pet | Pet object that needs to be added to the store
try {
apiInstance.updatePet(pet) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.updatePet(pet)
println("4xx response calling PetApi#updatePet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#updatePet")
e.printStackTrace()
} }
``` ```
@@ -295,38 +245,30 @@ null (empty response body)
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: application/json, application/xml - **Content-Type**: application/json, application/xml
- **Accept**: Not defined - **Accept**: Not defined
<a name="updatePetWithForm"></a>
# **updatePetWithForm**
> updatePetWithForm(petId, name, status)
Updates a pet in the store with form data Updates a pet in the store with form data
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be updated 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 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 val status : kotlin.String = status_example // kotlin.String | Updated status of the pet
try {
apiInstance.updatePetWithForm(petId, name, status) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.updatePetWithForm(petId, name, status)
println("4xx response calling PetApi#updatePetWithForm")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#updatePetWithForm")
e.printStackTrace()
} }
``` ```
@@ -345,39 +287,30 @@ null (empty response body)
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: application/x-www-form-urlencoded - **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined - **Accept**: Not defined
<a name="uploadFile"></a>
# **uploadFile**
> ApiResponse uploadFile(petId, additionalMetadata, file)
uploads an image uploads an image
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to update 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 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 val file : java.io.File = BINARY_DATA_HERE // java.io.File | file to upload
try {
val result : ApiResponse = apiInstance.uploadFile(petId, additionalMetadata, file) launch(Dispatchers.IO) {
println(result) val result : ApiResponse = webService.uploadFile(petId, additionalMetadata, file)
} catch (e: ClientException) {
println("4xx response calling PetApi#uploadFile")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#uploadFile")
e.printStackTrace()
} }
``` ```
@@ -396,39 +329,30 @@ Name | Type | Description | Notes
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: multipart/form-data - **Content-Type**: multipart/form-data
- **Accept**: application/json - **Accept**: application/json
<a name="uploadFileWithRequiredFile"></a>
# **uploadFileWithRequiredFile**
> ApiResponse uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata)
uploads an image (required) uploads an image (required)
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to update val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to update
val requiredFile : java.io.File = BINARY_DATA_HERE // java.io.File | file to upload val requiredFile : java.io.File = BINARY_DATA_HERE // java.io.File | file to upload
val additionalMetadata : kotlin.String = additionalMetadata_example // kotlin.String | Additional data to pass to server val additionalMetadata : kotlin.String = additionalMetadata_example // kotlin.String | Additional data to pass to server
try {
val result : ApiResponse = apiInstance.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata) launch(Dispatchers.IO) {
println(result) val result : ApiResponse = webService.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata)
} catch (e: ClientException) {
println("4xx response calling PetApi#uploadFileWithRequiredFile")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#uploadFileWithRequiredFile")
e.printStackTrace()
} }
``` ```
@@ -447,8 +371,6 @@ Name | Type | Description | Notes
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers

View File

@@ -4,15 +4,12 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID [**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** store/order/{order_id} | Delete purchase order by ID
[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status [**getInventory**](StoreApi.md#getInventory) | **GET** store/inventory | Returns pet inventories by status
[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID [**getOrderById**](StoreApi.md#getOrderById) | **GET** store/order/{order_id} | Find purchase order by ID
[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet [**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 Delete purchase order by ID
@@ -21,19 +18,16 @@ For valid response try integer IDs with value &lt; 1000. Anything above 1000 or
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = StoreApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(StoreApi::class.java)
val orderId : kotlin.String = orderId_example // kotlin.String | ID of the order that needs to be deleted val orderId : kotlin.String = orderId_example // kotlin.String | ID of the order that needs to be deleted
try {
apiInstance.deleteOrder(orderId) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.deleteOrder(orderId)
println("4xx response calling StoreApi#deleteOrder")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling StoreApi#deleteOrder")
e.printStackTrace()
} }
``` ```
@@ -56,9 +50,6 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: 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 pet inventories by status
@@ -67,19 +58,15 @@ Returns a map of status codes to quantities
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = StoreApi() val apiClient = ApiClient()
try { val webService = apiClient.createWebservice(StoreApi::class.java)
val result : kotlin.collections.Map<kotlin.String, kotlin.Int> = apiInstance.getInventory()
println(result) launch(Dispatchers.IO) {
} catch (e: ClientException) { val result : kotlin.collections.Map<kotlin.String, kotlin.Int> = webService.getInventory()
println("4xx response calling StoreApi#getInventory")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling StoreApi#getInventory")
e.printStackTrace()
} }
``` ```
@@ -93,18 +80,12 @@ This endpoint does not need any parameter.
### Authorization ### Authorization
Configure api_key:
ApiClient.apiKey["api_key"] = ""
ApiClient.apiKeyPrefix["api_key"] = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/json - **Accept**: application/json
<a name="getOrderById"></a>
# **getOrderById**
> Order getOrderById(orderId)
Find purchase order by ID Find purchase order by ID
@@ -113,20 +94,16 @@ For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other val
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = StoreApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(StoreApi::class.java)
val orderId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be fetched val orderId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be fetched
try {
val result : Order = apiInstance.getOrderById(orderId) launch(Dispatchers.IO) {
println(result) val result : Order = webService.getOrderById(orderId)
} catch (e: ClientException) {
println("4xx response calling StoreApi#getOrderById")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling StoreApi#getOrderById")
e.printStackTrace()
} }
``` ```
@@ -149,29 +126,22 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="placeOrder"></a>
# **placeOrder**
> Order placeOrder(order)
Place an order for a pet Place an order for a pet
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = StoreApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(StoreApi::class.java)
val order : Order = // Order | order placed for purchasing the pet val order : Order = // Order | order placed for purchasing the pet
try {
val result : Order = apiInstance.placeOrder(order) launch(Dispatchers.IO) {
println(result) val result : Order = webService.placeOrder(order)
} catch (e: ClientException) {
println("4xx response calling StoreApi#placeOrder")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling StoreApi#placeOrder")
e.printStackTrace()
} }
``` ```

View File

@@ -4,19 +4,16 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**createUser**](UserApi.md#createUser) | **POST** /user | Create user [**createUser**](UserApi.md#createUser) | **POST** user | Create user
[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array [**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 [**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** user/createWithList | Creates list of users with given input array
[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user [**deleteUser**](UserApi.md#deleteUser) | **DELETE** user/{username} | Delete user
[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name [**getUserByName**](UserApi.md#getUserByName) | **GET** user/{username} | Get user by user name
[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system [**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 [**logoutUser**](UserApi.md#logoutUser) | **GET** user/logout | Logs out current logged in user session
[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user [**updateUser**](UserApi.md#updateUser) | **PUT** user/{username} | Updated user
<a name="createUser"></a>
# **createUser**
> createUser(user)
Create user Create user
@@ -25,19 +22,16 @@ This can only be done by the logged in user.
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val user : User = // User | Created user object val user : User = // User | Created user object
try {
apiInstance.createUser(user) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.createUser(user)
println("4xx response calling UserApi#createUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#createUser")
e.printStackTrace()
} }
``` ```
@@ -60,28 +54,22 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: Not defined - **Accept**: Not defined
<a name="createUsersWithArrayInput"></a>
# **createUsersWithArrayInput**
> createUsersWithArrayInput(user)
Creates list of users with given input array Creates list of users with given input array
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val user : kotlin.Array<User> = // kotlin.Array<User> | List of user object val user : kotlin.Array<User> = // kotlin.Array<User> | List of user object
try {
apiInstance.createUsersWithArrayInput(user) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.createUsersWithArrayInput(user)
println("4xx response calling UserApi#createUsersWithArrayInput")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#createUsersWithArrayInput")
e.printStackTrace()
} }
``` ```
@@ -104,28 +92,22 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: Not defined - **Accept**: Not defined
<a name="createUsersWithListInput"></a>
# **createUsersWithListInput**
> createUsersWithListInput(user)
Creates list of users with given input array Creates list of users with given input array
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val user : kotlin.Array<User> = // kotlin.Array<User> | List of user object val user : kotlin.Array<User> = // kotlin.Array<User> | List of user object
try {
apiInstance.createUsersWithListInput(user) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.createUsersWithListInput(user)
println("4xx response calling UserApi#createUsersWithListInput")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#createUsersWithListInput")
e.printStackTrace()
} }
``` ```
@@ -148,9 +130,6 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: Not defined - **Accept**: Not defined
<a name="deleteUser"></a>
# **deleteUser**
> deleteUser(username)
Delete user Delete user
@@ -159,19 +138,16 @@ This can only be done by the logged in user.
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val username : kotlin.String = username_example // kotlin.String | The name that needs to be deleted val username : kotlin.String = username_example // kotlin.String | The name that needs to be deleted
try {
apiInstance.deleteUser(username) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.deleteUser(username)
println("4xx response calling UserApi#deleteUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#deleteUser")
e.printStackTrace()
} }
``` ```
@@ -194,29 +170,22 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: Not defined - **Accept**: Not defined
<a name="getUserByName"></a>
# **getUserByName**
> User getUserByName(username)
Get user by user name Get user by user name
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing. 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) launch(Dispatchers.IO) {
println(result) val result : User = webService.getUserByName(username)
} catch (e: ClientException) {
println("4xx response calling UserApi#getUserByName")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#getUserByName")
e.printStackTrace()
} }
``` ```
@@ -239,30 +208,23 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="loginUser"></a>
# **loginUser**
> kotlin.String loginUser(username, password)
Logs user into the system Logs user into the system
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val username : kotlin.String = username_example // kotlin.String | The user name for login 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 val password : kotlin.String = password_example // kotlin.String | The password for login in clear text
try {
val result : kotlin.String = apiInstance.loginUser(username, password) launch(Dispatchers.IO) {
println(result) val result : kotlin.String = webService.loginUser(username, password)
} catch (e: ClientException) {
println("4xx response calling UserApi#loginUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#loginUser")
e.printStackTrace()
} }
``` ```
@@ -286,27 +248,21 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="logoutUser"></a>
# **logoutUser**
> logoutUser()
Logs out current logged in user session Logs out current logged in user session
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
try { val webService = apiClient.createWebservice(UserApi::class.java)
apiInstance.logoutUser()
} catch (e: ClientException) { launch(Dispatchers.IO) {
println("4xx response calling UserApi#logoutUser") webService.logoutUser()
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#logoutUser")
e.printStackTrace()
} }
``` ```
@@ -326,9 +282,6 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: Not defined - **Accept**: Not defined
<a name="updateUser"></a>
# **updateUser**
> updateUser(username, user)
Updated user Updated user
@@ -337,20 +290,17 @@ This can only be done by the logged in user.
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val username : kotlin.String = username_example // kotlin.String | name that need to be deleted val username : kotlin.String = username_example // kotlin.String | name that need to be deleted
val user : User = // User | Updated user object val user : User = // User | Updated user object
try {
apiInstance.updateUser(username, user) launch(Dispatchers.IO) {
} catch (e: ClientException) { webService.updateUser(username, user)
println("4xx response calling UserApi#updateUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#updateUser")
e.printStackTrace()
} }
``` ```

View File

@@ -2,14 +2,22 @@ package org.openapitools.client.apis
import org.openapitools.client.infrastructure.CollectionFormats.* import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import retrofit2.Response
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import org.openapitools.client.models.Client import org.openapitools.client.models.Client
interface AnotherFakeApi { interface AnotherFakeApi {
@PATCH("/another-fake/dummy") /**
suspend fun call123testSpecialTags(@Body client: Client): Client * To test special tags
* To test special tags and operation ID starting with number
* Responses:
* - 200: successful operation
*
* @param client client model
* @return [Client]
*/
@PATCH("another-fake/dummy")
suspend fun call123testSpecialTags(@Body client: Client): Response<Client>
} }

View File

@@ -2,14 +2,21 @@ package org.openapitools.client.apis
import org.openapitools.client.infrastructure.CollectionFormats.* import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import retrofit2.Response
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import org.openapitools.client.models.InlineResponseDefault import org.openapitools.client.models.InlineResponseDefault
interface DefaultApi { interface DefaultApi {
@GET("/foo") /**
suspend fun fooGet(): InlineResponseDefault *
*
* Responses:
* - 0: response
*
* @return [InlineResponseDefault]
*/
@GET("foo")
suspend fun fooGet(): Response<InlineResponseDefault>
} }

View File

@@ -2,9 +2,8 @@ package org.openapitools.client.apis
import org.openapitools.client.infrastructure.CollectionFormats.* import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import retrofit2.Response
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import org.openapitools.client.models.Client import org.openapitools.client.models.Client
import org.openapitools.client.models.FileSchemaTestClass import org.openapitools.client.models.FileSchemaTestClass
@@ -14,52 +13,221 @@ import org.openapitools.client.models.Pet
import org.openapitools.client.models.User import org.openapitools.client.models.User
interface FakeApi { interface FakeApi {
@GET("/fake/health") /**
suspend fun fakeHealthGet(): HealthCheckResult * Health check endpoint
*
* Responses:
* - 200: The instance started successfully
*
* @return [HealthCheckResult]
*/
@GET("fake/health")
suspend fun fakeHealthGet(): Response<HealthCheckResult>
@GET("/fake/http-signature-test") /**
suspend fun fakeHttpSignatureTest(@Body pet: Pet, @Query("query_1") query1: kotlin.String, @Header("header_1") header1: kotlin.String): Unit * test http signature authentication
*
* Responses:
* - 200: The instance started successfully
*
* @param pet Pet object that needs to be added to the store
* @param query1 query parameter (optional)
* @param header1 header parameter (optional)
* @return [Unit]
*/
@GET("fake/http-signature-test")
suspend fun fakeHttpSignatureTest(@Body pet: Pet, @Query("query_1") query1: kotlin.String, @Header("header_1") header1: kotlin.String): Response<Unit>
@POST("/fake/outer/boolean") /**
suspend fun fakeOuterBooleanSerialize(@Body body: kotlin.Boolean): kotlin.Boolean *
* Test serialization of outer boolean types
* Responses:
* - 200: Output boolean
*
* @param body Input boolean as post body (optional)
* @return [kotlin.Boolean]
*/
@POST("fake/outer/boolean")
suspend fun fakeOuterBooleanSerialize(@Body body: kotlin.Boolean? = null): Response<kotlin.Boolean>
@POST("/fake/outer/composite") /**
suspend fun fakeOuterCompositeSerialize(@Body outerComposite: OuterComposite): OuterComposite *
* Test serialization of object with outer number type
* Responses:
* - 200: Output composite
*
* @param outerComposite Input composite as post body (optional)
* @return [OuterComposite]
*/
@POST("fake/outer/composite")
suspend fun fakeOuterCompositeSerialize(@Body outerComposite: OuterComposite? = null): Response<OuterComposite>
@POST("/fake/outer/number") /**
suspend fun fakeOuterNumberSerialize(@Body body: java.math.BigDecimal): java.math.BigDecimal *
* Test serialization of outer number types
* Responses:
* - 200: Output number
*
* @param body Input number as post body (optional)
* @return [java.math.BigDecimal]
*/
@POST("fake/outer/number")
suspend fun fakeOuterNumberSerialize(@Body body: java.math.BigDecimal? = null): Response<java.math.BigDecimal>
@POST("/fake/outer/string") /**
suspend fun fakeOuterStringSerialize(@Body body: kotlin.String): kotlin.String *
* Test serialization of outer string types
* Responses:
* - 200: Output string
*
* @param body Input string as post body (optional)
* @return [kotlin.String]
*/
@POST("fake/outer/string")
suspend fun fakeOuterStringSerialize(@Body body: kotlin.String? = null): Response<kotlin.String>
@PUT("/fake/body-with-file-schema") /**
suspend fun testBodyWithFileSchema(@Body fileSchemaTestClass: FileSchemaTestClass): Unit *
* For this test, the body for this request much reference a schema named &#x60;File&#x60;.
* Responses:
* - 200: Success
*
* @param fileSchemaTestClass
* @return [Unit]
*/
@PUT("fake/body-with-file-schema")
suspend fun testBodyWithFileSchema(@Body fileSchemaTestClass: FileSchemaTestClass): Response<Unit>
@PUT("/fake/body-with-query-params") /**
suspend fun testBodyWithQueryParams(@Query("query") query: kotlin.String, @Body user: User): Unit *
*
* Responses:
* - 200: Success
*
* @param query
* @param user
* @return [Unit]
*/
@PUT("fake/body-with-query-params")
suspend fun testBodyWithQueryParams(@Query("query") query: kotlin.String, @Body user: User): Response<Unit>
@PATCH("/fake") /**
suspend fun testClientModel(@Body client: Client): Client * To test \&quot;client\&quot; model
* To test \&quot;client\&quot; model
* Responses:
* - 200: successful operation
*
* @param client client model
* @return [Client]
*/
@PATCH("fake")
suspend fun testClientModel(@Body client: Client): Response<Client>
/**
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
* Responses:
* - 400: Invalid username supplied
* - 404: User not found
*
* @param number None
* @param double None
* @param patternWithoutDelimiter None
* @param byte None
* @param integer None (optional)
* @param int32 None (optional)
* @param int64 None (optional)
* @param float None (optional)
* @param string None (optional)
* @param binary None (optional)
* @param date None (optional)
* @param dateTime None (optional)
* @param password None (optional)
* @param paramCallback None (optional)
* @return [Unit]
*/
@FormUrlEncoded @FormUrlEncoded
@POST("/fake") @POST("fake")
suspend fun testEndpointParameters(@Field("number") number: java.math.BigDecimal, @Field("double") double: kotlin.Double, @Field("pattern_without_delimiter") patternWithoutDelimiter: kotlin.String, @Field("byte") byte: kotlin.ByteArray, @Field("integer") integer: kotlin.Int, @Field("int32") int32: kotlin.Int, @Field("int64") int64: kotlin.Long, @Field("float") float: kotlin.Float, @Field("string") string: kotlin.String, @Field("binary") binary: MultipartBody.Part, @Field("date") date: java.time.LocalDate, @Field("dateTime") dateTime: java.time.OffsetDateTime, @Field("password") password: kotlin.String, @Field("callback") paramCallback: kotlin.String): Unit suspend fun testEndpointParameters(@Field("number") number: java.math.BigDecimal, @Field("double") double: kotlin.Double, @Field("pattern_without_delimiter") patternWithoutDelimiter: kotlin.String, @Field("byte") byte: kotlin.ByteArray, @Field("integer") integer: kotlin.Int, @Field("int32") int32: kotlin.Int, @Field("int64") int64: kotlin.Long, @Field("float") float: kotlin.Float, @Field("string") string: kotlin.String, @Field("binary") binary: MultipartBody.Part, @Field("date") date: java.time.LocalDate, @Field("dateTime") dateTime: java.time.OffsetDateTime, @Field("password") password: kotlin.String, @Field("callback") paramCallback: kotlin.String): Response<Unit>
/**
* To test enum parameters
* To test enum parameters
* Responses:
* - 400: Invalid request
* - 404: Not found
*
* @param enumHeaderStringArray Header parameter enum test (string array) (optional)
* @param enumHeaderString Header parameter enum test (string) (optional, default to "-efg")
* @param enumQueryStringArray Query parameter enum test (string array) (optional)
* @param enumQueryString Query parameter enum test (string) (optional, default to "-efg")
* @param enumQueryInteger Query parameter enum test (double) (optional)
* @param enumQueryDouble Query parameter enum test (double) (optional)
* @param enumFormStringArray Form parameter enum test (string array) (optional, default to "$")
* @param enumFormString Form parameter enum test (string) (optional, default to "-efg")
* @return [Unit]
*/
@FormUrlEncoded @FormUrlEncoded
@GET("/fake") @GET("fake")
suspend fun testEnumParameters(@Header("enum_header_string_array") enumHeaderStringArray: kotlin.Array<kotlin.String>, @Header("enum_header_string") enumHeaderString: kotlin.String, @Query("enum_query_string_array") enumQueryStringArray: kotlin.Array<kotlin.String>, @Query("enum_query_string") enumQueryString: kotlin.String, @Query("enum_query_integer") enumQueryInteger: kotlin.Int, @Query("enum_query_double") enumQueryDouble: kotlin.Double, @Field("enum_form_string_array") enumFormStringArray: kotlin.Array<kotlin.String>, @Field("enum_form_string") enumFormString: kotlin.String): Unit suspend fun testEnumParameters(@Header("enum_header_string_array") enumHeaderStringArray: kotlin.Array<kotlin.String>, @Header("enum_header_string") enumHeaderString: kotlin.String, @Query("enum_query_string_array") enumQueryStringArray: kotlin.Array<kotlin.String>, @Query("enum_query_string") enumQueryString: kotlin.String, @Query("enum_query_integer") enumQueryInteger: kotlin.Int, @Query("enum_query_double") enumQueryDouble: kotlin.Double, @Field("enum_form_string_array") enumFormStringArray: kotlin.Array<kotlin.String>, @Field("enum_form_string") enumFormString: kotlin.String): Response<Unit>
@DELETE("/fake") /**
suspend fun testGroupParameters(@Query("required_string_group") requiredStringGroup: kotlin.Int, @Header("required_boolean_group") requiredBooleanGroup: kotlin.Boolean, @Query("required_int64_group") requiredInt64Group: kotlin.Long, @Query("string_group") stringGroup: kotlin.Int, @Header("boolean_group") booleanGroup: kotlin.Boolean, @Query("int64_group") int64Group: kotlin.Long): Unit * Fake endpoint to test group parameters (optional)
* Fake endpoint to test group parameters (optional)
* Responses:
* - 400: Someting wrong
*
* @param requiredStringGroup Required String in group parameters
* @param requiredBooleanGroup Required Boolean in group parameters
* @param requiredInt64Group Required Integer in group parameters
* @param stringGroup String in group parameters (optional)
* @param booleanGroup Boolean in group parameters (optional)
* @param int64Group Integer in group parameters (optional)
* @return [Unit]
*/
@DELETE("fake")
suspend fun testGroupParameters(@Query("required_string_group") requiredStringGroup: kotlin.Int, @Header("required_boolean_group") requiredBooleanGroup: kotlin.Boolean, @Query("required_int64_group") requiredInt64Group: kotlin.Long, @Query("string_group") stringGroup: kotlin.Int, @Header("boolean_group") booleanGroup: kotlin.Boolean, @Query("int64_group") int64Group: kotlin.Long): Response<Unit>
@POST("/fake/inline-additionalProperties") /**
suspend fun testInlineAdditionalProperties(@Body requestBody: kotlin.collections.Map<kotlin.String, kotlin.String>): Unit * test inline additionalProperties
*
* Responses:
* - 200: successful operation
*
* @param requestBody request body
* @return [Unit]
*/
@POST("fake/inline-additionalProperties")
suspend fun testInlineAdditionalProperties(@Body requestBody: kotlin.collections.Map<kotlin.String, kotlin.String>): Response<Unit>
/**
* test json serialization of form data
*
* Responses:
* - 200: successful operation
*
* @param param field1
* @param param2 field2
* @return [Unit]
*/
@FormUrlEncoded @FormUrlEncoded
@GET("/fake/jsonFormData") @GET("fake/jsonFormData")
suspend fun testJsonFormData(@Field("param") param: kotlin.String, @Field("param2") param2: kotlin.String): Unit suspend fun testJsonFormData(@Field("param") param: kotlin.String, @Field("param2") param2: kotlin.String): Response<Unit>
@PUT("/fake/test-query-paramters") /**
suspend fun testQueryParameterCollectionFormat(@Query("pipe") pipe: kotlin.Array<kotlin.String>, @Query("ioutil") ioutil: CSVParams, @Query("http") http: SPACEParams, @Query("url") url: CSVParams, @Query("context") context: kotlin.Array<kotlin.String>): Unit *
* To test the collection format in query parameters
* Responses:
* - 200: Success
*
* @param pipe
* @param ioutil
* @param http
* @param url
* @param context
* @return [Unit]
*/
@PUT("fake/test-query-paramters")
suspend fun testQueryParameterCollectionFormat(@Query("pipe") pipe: kotlin.Array<kotlin.String>, @Query("ioutil") ioutil: CSVParams, @Query("http") http: SSVParams, @Query("url") url: CSVParams, @Query("context") context: kotlin.Array<kotlin.String>): Response<Unit>
} }

View File

@@ -2,14 +2,22 @@ package org.openapitools.client.apis
import org.openapitools.client.infrastructure.CollectionFormats.* import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import retrofit2.Response
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import org.openapitools.client.models.Client import org.openapitools.client.models.Client
interface FakeClassnameTags123Api { interface FakeClassnameTags123Api {
@PATCH("/fake_classname_test") /**
suspend fun testClassname(@Body client: Client): Client * To test class name in snake case
* To test class name in snake case
* Responses:
* - 200: successful operation
*
* @param client client model
* @return [Client]
*/
@PATCH("fake_classname_test")
suspend fun testClassname(@Body client: Client): Response<Client>
} }

View File

@@ -2,43 +2,136 @@ package org.openapitools.client.apis
import org.openapitools.client.infrastructure.CollectionFormats.* import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import retrofit2.Response
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import org.openapitools.client.models.ApiResponse import org.openapitools.client.models.ApiResponse
import org.openapitools.client.models.Pet import org.openapitools.client.models.Pet
interface PetApi { interface PetApi {
@POST("/pet") /**
suspend fun addPet(@Body pet: Pet): Unit * Add a new pet to the store
*
* Responses:
* - 405: Invalid input
*
* @param pet Pet object that needs to be added to the store
* @return [Unit]
*/
@POST("pet")
suspend fun addPet(@Body pet: Pet): Response<Unit>
@DELETE("/pet/{petId}") /**
suspend fun deletePet(@Path("petId") petId: kotlin.Long, @Header("api_key") apiKey: kotlin.String): Unit * Deletes a pet
*
* Responses:
* - 400: Invalid pet value
*
* @param petId Pet id to delete
* @param apiKey (optional)
* @return [Unit]
*/
@DELETE("pet/{petId}")
suspend fun deletePet(@Path("petId") petId: kotlin.Long, @Header("api_key") apiKey: kotlin.String): Response<Unit>
@GET("/pet/findByStatus") /**
suspend fun findPetsByStatus(@Query("status") status: CSVParams): kotlin.Array<Pet> * Finds Pets by status
* Multiple status values can be provided with comma separated strings
* Responses:
* - 200: successful operation
* - 400: Invalid status value
*
* @param status Status values that need to be considered for filter
* @return [kotlin.Array<Pet>]
*/
@GET("pet/findByStatus")
suspend fun findPetsByStatus(@Query("status") status: CSVParams): Response<kotlin.Array<Pet>>
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* Responses:
* - 200: successful operation
* - 400: Invalid tag value
*
* @param tags Tags to filter by
* @return [kotlin.Array<Pet>]
*/
@Deprecated("This api was deprecated") @Deprecated("This api was deprecated")
@GET("/pet/findByTags") @GET("pet/findByTags")
suspend fun findPetsByTags(@Query("tags") tags: CSVParams): kotlin.Array<Pet> suspend fun findPetsByTags(@Query("tags") tags: CSVParams): Response<kotlin.Array<Pet>>
@GET("/pet/{petId}") /**
suspend fun getPetById(@Path("petId") petId: kotlin.Long): Pet * Find pet by ID
* Returns a single pet
* Responses:
* - 200: successful operation
* - 400: Invalid ID supplied
* - 404: Pet not found
*
* @param petId ID of pet to return
* @return [Pet]
*/
@GET("pet/{petId}")
suspend fun getPetById(@Path("petId") petId: kotlin.Long): Response<Pet>
@PUT("/pet") /**
suspend fun updatePet(@Body pet: Pet): Unit * Update an existing pet
*
* Responses:
* - 400: Invalid ID supplied
* - 404: Pet not found
* - 405: Validation exception
*
* @param pet Pet object that needs to be added to the store
* @return [Unit]
*/
@PUT("pet")
suspend fun updatePet(@Body pet: Pet): Response<Unit>
/**
* Updates a pet in the store with form data
*
* Responses:
* - 405: Invalid input
*
* @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 [Unit]
*/
@FormUrlEncoded @FormUrlEncoded
@POST("/pet/{petId}") @POST("pet/{petId}")
suspend fun updatePetWithForm(@Path("petId") petId: kotlin.Long, @Field("name") name: kotlin.String, @Field("status") status: kotlin.String): Unit suspend fun updatePetWithForm(@Path("petId") petId: kotlin.Long, @Field("name") name: kotlin.String, @Field("status") status: kotlin.String): Response<Unit>
/**
* uploads an image
*
* Responses:
* - 200: successful operation
*
* @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server (optional)
* @param file file to upload (optional)
* @return [ApiResponse]
*/
@Multipart @Multipart
@POST("/pet/{petId}/uploadImage") @POST("pet/{petId}/uploadImage")
suspend fun uploadFile(@Path("petId") petId: kotlin.Long, @Part("additionalMetadata") additionalMetadata: kotlin.String, @Part file: MultipartBody.Part): ApiResponse suspend fun uploadFile(@Path("petId") petId: kotlin.Long, @Part("additionalMetadata") additionalMetadata: kotlin.String, @Part file: MultipartBody.Part): Response<ApiResponse>
/**
* uploads an image (required)
*
* Responses:
* - 200: successful operation
*
* @param petId ID of pet to update
* @param requiredFile file to upload
* @param additionalMetadata Additional data to pass to server (optional)
* @return [ApiResponse]
*/
@Multipart @Multipart
@POST("/fake/{petId}/uploadImageWithRequiredFile") @POST("fake/{petId}/uploadImageWithRequiredFile")
suspend fun uploadFileWithRequiredFile(@Path("petId") petId: kotlin.Long, @Part requiredFile: MultipartBody.Part, @Part("additionalMetadata") additionalMetadata: kotlin.String): ApiResponse suspend fun uploadFileWithRequiredFile(@Path("petId") petId: kotlin.Long, @Part requiredFile: MultipartBody.Part, @Part("additionalMetadata") additionalMetadata: kotlin.String): Response<ApiResponse>
} }

View File

@@ -2,23 +2,61 @@ package org.openapitools.client.apis
import org.openapitools.client.infrastructure.CollectionFormats.* import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import retrofit2.Response
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import org.openapitools.client.models.Order import org.openapitools.client.models.Order
interface StoreApi { interface StoreApi {
@DELETE("/store/order/{order_id}") /**
suspend fun deleteOrder(@Path("order_id") orderId: kotlin.String): Unit * Delete purchase order by ID
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
* Responses:
* - 400: Invalid ID supplied
* - 404: Order not found
*
* @param orderId ID of the order that needs to be deleted
* @return [Unit]
*/
@DELETE("store/order/{order_id}")
suspend fun deleteOrder(@Path("order_id") orderId: kotlin.String): Response<Unit>
@GET("/store/inventory") /**
suspend fun getInventory(): kotlin.collections.Map<kotlin.String, kotlin.Int> * Returns pet inventories by status
* Returns a map of status codes to quantities
* Responses:
* - 200: successful operation
*
* @return [kotlin.collections.Map<kotlin.String, kotlin.Int>]
*/
@GET("store/inventory")
suspend fun getInventory(): Response<kotlin.collections.Map<kotlin.String, kotlin.Int>>
@GET("/store/order/{order_id}") /**
suspend fun getOrderById(@Path("order_id") orderId: kotlin.Long): Order * Find purchase order by ID
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* Responses:
* - 200: successful operation
* - 400: Invalid ID supplied
* - 404: Order not found
*
* @param orderId ID of pet that needs to be fetched
* @return [Order]
*/
@GET("store/order/{order_id}")
suspend fun getOrderById(@Path("order_id") orderId: kotlin.Long): Response<Order>
@POST("/store/order") /**
suspend fun placeOrder(@Body order: Order): Order * Place an order for a pet
*
* Responses:
* - 200: successful operation
* - 400: Invalid Order
*
* @param order order placed for purchasing the pet
* @return [Order]
*/
@POST("store/order")
suspend fun placeOrder(@Body order: Order): Response<Order>
} }

View File

@@ -2,35 +2,112 @@ package org.openapitools.client.apis
import org.openapitools.client.infrastructure.CollectionFormats.* import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import retrofit2.Response
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import org.openapitools.client.models.User import org.openapitools.client.models.User
interface UserApi { interface UserApi {
@POST("/user") /**
suspend fun createUser(@Body user: User): Unit * Create user
* This can only be done by the logged in user.
* Responses:
* - 0: successful operation
*
* @param user Created user object
* @return [Unit]
*/
@POST("user")
suspend fun createUser(@Body user: User): Response<Unit>
@POST("/user/createWithArray") /**
suspend fun createUsersWithArrayInput(@Body user: kotlin.Array<User>): Unit * Creates list of users with given input array
*
* Responses:
* - 0: successful operation
*
* @param user List of user object
* @return [Unit]
*/
@POST("user/createWithArray")
suspend fun createUsersWithArrayInput(@Body user: kotlin.Array<User>): Response<Unit>
@POST("/user/createWithList") /**
suspend fun createUsersWithListInput(@Body user: kotlin.Array<User>): Unit * Creates list of users with given input array
*
* Responses:
* - 0: successful operation
*
* @param user List of user object
* @return [Unit]
*/
@POST("user/createWithList")
suspend fun createUsersWithListInput(@Body user: kotlin.Array<User>): Response<Unit>
@DELETE("/user/{username}") /**
suspend fun deleteUser(@Path("username") username: kotlin.String): Unit * Delete user
* This can only be done by the logged in user.
* Responses:
* - 400: Invalid username supplied
* - 404: User not found
*
* @param username The name that needs to be deleted
* @return [Unit]
*/
@DELETE("user/{username}")
suspend fun deleteUser(@Path("username") username: kotlin.String): Response<Unit>
@GET("/user/{username}") /**
suspend fun getUserByName(@Path("username") username: kotlin.String): User * Get user by user name
*
* Responses:
* - 200: successful operation
* - 400: Invalid username supplied
* - 404: User not found
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @return [User]
*/
@GET("user/{username}")
suspend fun getUserByName(@Path("username") username: kotlin.String): Response<User>
@GET("/user/login") /**
suspend fun loginUser(@Query("username") username: kotlin.String, @Query("password") password: kotlin.String): kotlin.String * Logs user into the system
*
* Responses:
* - 200: successful operation
* - 400: Invalid username/password supplied
*
* @param username The user name for login
* @param password The password for login in clear text
* @return [kotlin.String]
*/
@GET("user/login")
suspend fun loginUser(@Query("username") username: kotlin.String, @Query("password") password: kotlin.String): Response<kotlin.String>
@GET("/user/logout") /**
suspend fun logoutUser(): Unit * Logs out current logged in user session
*
* Responses:
* - 0: successful operation
*
* @return [Unit]
*/
@GET("user/logout")
suspend fun logoutUser(): Response<Unit>
@PUT("/user/{username}") /**
suspend fun updateUser(@Path("username") username: kotlin.String, @Body user: User): Unit * Updated user
* This can only be done by the logged in user.
* Responses:
* - 400: Invalid user supplied
* - 404: User not found
*
* @param username name that need to be deleted
* @param user Updated user object
* @return [Unit]
*/
@PUT("user/{username}")
suspend fun updateUser(@Path("username") username: kotlin.String, @Body user: User): Response<Unit>
} }

View File

@@ -0,0 +1,50 @@
package org.openapitools.client.auth
import java.io.IOException
import java.net.URI
import java.net.URISyntaxException
import okhttp3.Interceptor
import okhttp3.Response
class ApiKeyAuth(
private val location: String = "",
private val paramName: String = "",
private var apiKey: String = ""
) : Interceptor {
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {
var request = chain.request()
if ("query" == location) {
var newQuery = request.url.toUri().query
val paramValue = "$paramName=$apiKey"
if (newQuery == null) {
newQuery = paramValue
} else {
newQuery += "&$paramValue"
}
val newUri: URI
try {
val oldUri = request.url.toUri()
newUri = URI(oldUri.scheme, oldUri.authority,
oldUri.path, newQuery, oldUri.fragment)
} catch (e: URISyntaxException) {
throw IOException(e)
}
request = request.newBuilder().url(newUri.toURL()).build()
} else if ("header" == location) {
request = request.newBuilder()
.addHeader(paramName, apiKey)
.build()
} else if ("cookie" == location) {
request = request.newBuilder()
.addHeader("Cookie", "$paramName=$apiKey")
.build()
}
return chain.proceed(request)
}
}

View File

@@ -0,0 +1,33 @@
package org.openapitools.client.auth
import java.io.IOException
import kotlin.jvm.Throws
import okhttp3.Interceptor
import okhttp3.Interceptor.Chain
import okhttp3.Response
import okhttp3.Credentials
class HttpBasicAuth(
private var username: String = "",
private var password: String = ""
) : Interceptor {
fun setCredentials(username: String, password: String) {
this.username = username
this.password = password
}
@Throws(IOException::class)
override fun intercept(chain: Chain): Response {
var request = chain.request()
// If the request already have an authorization (eg. Basic auth), do nothing
if (request.header("Authorization") == null && username.isNotBlank() && password.isNotBlank()) {
request = request.newBuilder()
.addHeader("Authorization", Credentials.basic(username, password))
.build()
}
return chain.proceed(request)
}
}

View File

@@ -0,0 +1,39 @@
package org.openapitools.client.auth
import java.io.IOException
import okhttp3.Interceptor
import okhttp3.Interceptor.Chain
import okhttp3.Response
class HttpBearerAuth(
private var schema: String = "",
var bearerToken: String = ""
) : Interceptor {
@Throws(IOException::class)
override fun intercept(chain: Chain): Response {
var request = chain.request()
// If the request already have an authorization (eg. Basic auth), do nothing
if (request.header("Authorization") == null && bearerToken.isNotBlank()) {
request = request.newBuilder()
.addHeader("Authorization", headerValue())
.build()
}
return chain.proceed(request)
}
private fun headerValue(): String {
return if (schema.isNotBlank()) {
"${upperCaseBearer()} $bearerToken"
} else {
bearerToken
}
}
private fun upperCaseBearer(): String {
return if (schema.toLowerCase().equals("bearer")) "Bearer" else schema
}
}

View File

@@ -0,0 +1,151 @@
package org.openapitools.client.auth
import java.net.HttpURLConnection.HTTP_UNAUTHORIZED
import java.net.HttpURLConnection.HTTP_FORBIDDEN
import java.io.IOException
import org.apache.oltu.oauth2.client.OAuthClient
import org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest
import org.apache.oltu.oauth2.client.request.OAuthClientRequest
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder
import org.apache.oltu.oauth2.common.exception.OAuthProblemException
import org.apache.oltu.oauth2.common.exception.OAuthSystemException
import org.apache.oltu.oauth2.common.message.types.GrantType
import org.apache.oltu.oauth2.common.token.BasicOAuthToken
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.Response
class OAuth(
client: OkHttpClient,
var tokenRequestBuilder: TokenRequestBuilder
) : Interceptor {
interface AccessTokenListener {
fun notify(token: BasicOAuthToken)
}
private var oauthClient: OAuthClient = OAuthClient(OAuthOkHttpClient(client))
@Volatile
private var accessToken: String? = null
var authenticationRequestBuilder: AuthenticationRequestBuilder? = null
private var accessTokenListener: AccessTokenListener? = null
constructor(
requestBuilder: TokenRequestBuilder
) : this(
OkHttpClient(),
requestBuilder
)
constructor(
flow: OAuthFlow,
authorizationUrl: String,
tokenUrl: String,
scopes: String
) : this(
OAuthClientRequest.tokenLocation(tokenUrl).setScope(scopes)
) {
setFlow(flow);
authenticationRequestBuilder = OAuthClientRequest.authorizationLocation(authorizationUrl);
}
fun setFlow(flow: OAuthFlow) {
when (flow) {
OAuthFlow.accessCode, OAuthFlow.implicit ->
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE)
OAuthFlow.password ->
tokenRequestBuilder.setGrantType(GrantType.PASSWORD)
OAuthFlow.application ->
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS)
}
}
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {
return retryingIntercept(chain, true)
}
@Throws(IOException::class)
private fun retryingIntercept(chain: Interceptor.Chain, updateTokenAndRetryOnAuthorizationFailure: Boolean): Response {
var request = chain.request()
// If the request already have an authorization (eg. Basic auth), do nothing
if (request.header("Authorization") != null) {
return chain.proceed(request)
}
// If first time, get the token
val oAuthRequest: OAuthClientRequest
if (accessToken == null) {
updateAccessToken(null)
}
if (accessToken != null) {
// Build the request
val rb = request.newBuilder()
val requestAccessToken = accessToken
try {
oAuthRequest = OAuthBearerClientRequest(request.url.toString())
.setAccessToken(requestAccessToken)
.buildHeaderMessage()
} catch (e: OAuthSystemException) {
throw IOException(e)
}
oAuthRequest.headers.entries.forEach { header ->
rb.addHeader(header.key, header.value)
}
rb.url(oAuthRequest.locationUri)
//Execute the request
val response = chain.proceed(rb.build())
// 401/403 most likely indicates that access token has expired. Unless it happens two times in a row.
if ((response.code == HTTP_UNAUTHORIZED || response.code == HTTP_FORBIDDEN) && updateTokenAndRetryOnAuthorizationFailure) {
try {
if (updateAccessToken(requestAccessToken)) {
response.body?.close()
return retryingIntercept(chain, false)
}
} catch (e: Exception) {
response.body?.close()
throw e
}
}
return response
} else {
return chain.proceed(chain.request())
}
}
/**
* Returns true if the access token has been updated
*/
@Throws(IOException::class)
@Synchronized
fun updateAccessToken(requestAccessToken: String?): Boolean {
if (accessToken == null || accessToken.equals(requestAccessToken)) {
return try {
val accessTokenResponse = oauthClient.accessToken(this.tokenRequestBuilder.buildBodyMessage())
if (accessTokenResponse != null && accessTokenResponse.accessToken != null) {
accessToken = accessTokenResponse.accessToken
accessTokenListener?.notify(accessTokenResponse.oAuthToken as BasicOAuthToken)
!accessToken.equals(requestAccessToken)
} else {
false
}
} catch (e: OAuthSystemException) {
throw IOException(e)
} catch (e: OAuthProblemException) {
throw IOException(e)
}
}
return true;
}
}

View File

@@ -0,0 +1,5 @@
package org.openapitools.client.auth
enum class OAuthFlow {
accessCode, implicit, password, application
}

View File

@@ -0,0 +1,61 @@
package org.openapitools.client.auth
import java.io.IOException
import org.apache.oltu.oauth2.client.HttpClient
import org.apache.oltu.oauth2.client.request.OAuthClientRequest
import org.apache.oltu.oauth2.client.response.OAuthClientResponse
import org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory
import org.apache.oltu.oauth2.common.exception.OAuthProblemException
import org.apache.oltu.oauth2.common.exception.OAuthSystemException
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
class OAuthOkHttpClient(
private var client: OkHttpClient
) : HttpClient {
constructor() : this(OkHttpClient())
@Throws(OAuthSystemException::class, OAuthProblemException::class)
override fun <T : OAuthClientResponse?> execute(
request: OAuthClientRequest,
headers: Map<String, String>?,
requestMethod: String,
responseClass: Class<T>?): T {
var mediaType = "application/json".toMediaTypeOrNull()
val requestBuilder = Request.Builder().url(request.locationUri)
headers?.forEach { entry ->
if (entry.key.equals("Content-Type", true)) {
mediaType = entry.value.toMediaTypeOrNull()
} else {
requestBuilder.addHeader(entry.key, entry.value)
}
}
val body: RequestBody? = if (request.body != null) RequestBody.create(mediaType, request.body) else null
requestBuilder.method(requestMethod, body)
try {
val response = client.newCall(requestBuilder.build()).execute()
return OAuthClientResponseFactory.createCustomResponse(
response.body?.string(),
response.body?.contentType()?.toString(),
response.code,
responseClass)
} catch (e: IOException) {
throw OAuthSystemException(e)
}
}
override fun shutdown() {
// Nothing to do here
}
}

View File

@@ -1,35 +1,230 @@
package org.openapitools.client.infrastructure package org.openapitools.client.infrastructure
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder
import org.openapitools.client.auth.ApiKeyAuth
import org.openapitools.client.auth.OAuth
import org.openapitools.client.auth.OAuth.AccessTokenListener
import org.openapitools.client.auth.OAuthFlow
import org.openapitools.client.auth.HttpBearerAuth
import org.openapitools.client.auth.HttpBasicAuth
import okhttp3.Interceptor
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import retrofit2.Retrofit import retrofit2.Retrofit
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.converter.scalars.ScalarsConverterFactory import retrofit2.converter.scalars.ScalarsConverterFactory
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import retrofit2.converter.gson.GsonConverterFactory import retrofit2.converter.gson.GsonConverterFactory
class ApiClient( class ApiClient(
private var baseUrl: String = defaultBasePath, private var baseUrl: String = defaultBasePath,
private var okHttpClient: OkHttpClient private val okHttpClientBuilder: OkHttpClient.Builder? = null,
private val serializerBuilder: GsonBuilder = Serializer.gsonBuilder
) { ) {
companion object { private val apiAuthorizations = mutableMapOf<String, Interceptor>()
@JvmStatic var logger: ((String) -> Unit)? = null
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io:80/v2") private val retrofitBuilder: Retrofit.Builder by lazy {
} Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create(serializerBuilder.create()))
}
private val clientBuilder: OkHttpClient.Builder by lazy {
okHttpClientBuilder ?: defaultClientBuilder
}
private val defaultClientBuilder: OkHttpClient.Builder by lazy {
OkHttpClient()
.newBuilder()
.addInterceptor(HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger {
override fun log(message: String) {
logger?.invoke(message)
}
}).apply {
level = HttpLoggingInterceptor.Level.BODY
})
} }
init { init {
normalizeBaseUrl() normalizeBaseUrl()
} }
val retrofitBuilder: Retrofit.Builder by lazy { constructor(
baseUrl: String = defaultBasePath,
okHttpClientBuilder: OkHttpClient.Builder? = null,
serializerBuilder: GsonBuilder = Serializer.gsonBuilder,
authNames: Array<String>
) : this(baseUrl, okHttpClientBuilder, serializerBuilder) {
authNames.forEach { authName ->
val auth = when (authName) {
"api_key" -> ApiKeyAuth("header", "api_key")"api_key_query" -> ApiKeyAuth("query", "api_key_query")"bearer_test" -> HttpBearerAuth("bearer")"http_basic_test" -> HttpBasicAuth()"http_signature_test" -> "petstore_auth" -> OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets")
else -> throw RuntimeException("auth name $authName not found in available auth names")
}
addAuthorization(authName, auth);
}
}
Retrofit.Builder() constructor(
.baseUrl(baseUrl) baseUrl: String = defaultBasePath,
.addConverterFactory(ScalarsConverterFactory.create()) okHttpClientBuilder: OkHttpClient.Builder? = null,
.addConverterFactory(GsonConverterFactory.create(Serializer.gson)) serializerBuilder: GsonBuilder = Serializer.gsonBuilder,
authName: String,
bearerToken: String
) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) {
setBearerToken(bearerToken)
}
constructor(
baseUrl: String = defaultBasePath,
okHttpClientBuilder: OkHttpClient.Builder? = null,
serializerBuilder: GsonBuilder = Serializer.gsonBuilder,
authName: String,
username: String,
password: String
) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) {
setCredentials(username, password)
}
constructor(
baseUrl: String = defaultBasePath,
okHttpClientBuilder: OkHttpClient.Builder? = null,
serializerBuilder: GsonBuilder = Serializer.gsonBuilder,
authName: String,
clientId: String,
secret: String,
username: String,
password: String
) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) {
getTokenEndPoint()
?.setClientId(clientId)
?.setClientSecret(secret)
?.setUsername(username)
?.setPassword(password)
}
fun setCredentials(username: String, password: String): ApiClient {
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
tokenRequestBuilder.setUsername(username).setPassword(password)
}
return this
}
fun setBearerToken(bearerToken: String): ApiClient {
apiAuthorizations.values.runOnFirst<Interceptor, HttpBearerAuth> {
this.bearerToken = bearerToken
}
return this
}
fun setCredentials(username: String, password: String): ApiClient {
apiAuthorizations.values.runOnFirst<Interceptor, HttpBasicAuth> {
setCredentials(username, password);
}
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
tokenRequestBuilder.setUsername(username).setPassword(password)
}
return this
}
fun setCredentials(username: String, password: String): ApiClient {
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
tokenRequestBuilder.setUsername(username).setPassword(password)
}
return this
}
/**
* Helper method to configure the token endpoint of the first oauth found in the apiAuthorizations (there should be only one)
* @return Token request builder
*/
fun getTokenEndPoint(): TokenRequestBuilder? {
var result: TokenRequestBuilder? = null
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
result = tokenRequestBuilder
}
return result
}
/**
* Helper method to configure authorization endpoint of the first oauth found in the apiAuthorizations (there should be only one)
* @return Authentication request builder
*/
fun getAuthorizationEndPoint(): AuthenticationRequestBuilder? {
var result: AuthenticationRequestBuilder? = null
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
result = authenticationRequestBuilder
}
return result
}
/**
* Helper method to pre-set the oauth access token of the first oauth found in the apiAuthorizations (there should be only one)
* @param accessToken Access token
* @return ApiClient
*/
fun setAccessToken(accessToken: String): ApiClient {
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
setAccessToken(accessToken)
}
return this
}
/**
* Helper method to configure the oauth accessCode/implicit flow parameters
* @param clientId Client ID
* @param clientSecret Client secret
* @param redirectURI Redirect URI
* @return ApiClient
*/
fun configureAuthorizationFlow(clientId: String, clientSecret: String, redirectURI: String): ApiClient {
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
tokenRequestBuilder
.setClientId(clientId)
.setClientSecret(clientSecret)
.setRedirectURI(redirectURI)
authenticationRequestBuilder
?.setClientId(clientId)
?.setRedirectURI(redirectURI)
}
return this;
}
/**
* Configures a listener which is notified when a new access token is received.
* @param accessTokenListener Access token listener
* @return ApiClient
*/
fun registerAccessTokenListener(accessTokenListener: AccessTokenListener): ApiClient {
apiAuthorizations.values.runOnFirst<Interceptor, OAuth> {
registerAccessTokenListener(accessTokenListener)
}
return this;
}
/**
* Adds an authorization to be used by the client
* @param authName Authentication name
* @param authorization Authorization interceptor
* @return ApiClient
*/
fun addAuthorization(authName: String, authorization: Interceptor): ApiClient {
if (apiAuthorizations.containsKey(authName)) {
throw RuntimeException("auth name $authName already in api authorizations")
}
apiAuthorizations[authName] = authorization
clientBuilder.addInterceptor(authorization)
return this
}
fun setLogger(logger: (String) -> Unit): ApiClient {
this.logger = logger
return this
} }
fun <S> createService(serviceClass: Class<S>): S { fun <S> createService(serviceClass: Class<S>): S {
return retrofitBuilder.client(okHttpClient).build().create(serviceClass) return retrofitBuilder.client(clientBuilder.build()).build().create(serviceClass)
} }
private fun normalizeBaseUrl() { private fun normalizeBaseUrl() {
@@ -37,4 +232,20 @@ class ApiClient(
baseUrl += "/" baseUrl += "/"
} }
} }
private inline fun <T, reified U> Iterable<T>.runOnFirst(callback: U.() -> Unit) {
for (element in this) {
if (element is U) {
callback.invoke(element)
break
}
}
}
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io:80/v2")
}
}
} }

View File

@@ -0,0 +1,15 @@
package org.openapitools.client.infrastructure
import com.google.gson.GsonBuilder
import com.google.gson.JsonParseException
import retrofit2.Response
@Throws(JsonParseException::class)
inline fun <reified T> Response<*>.getErrorResponse(serializerBuilder: GsonBuilder = Serializer.gsonBuilder): T? {
val serializer = serializerBuilder.create()
val reader = errorBody()?.charStream()
if(reader != null) {
return serializer.fromJson(reader, T::class.java)
}
return null
}

View File

@@ -64,6 +64,72 @@ src/main/kotlin/org/openapitools/client/apis/FakeClassnameTags123Api.kt
src/main/kotlin/org/openapitools/client/apis/PetApi.kt 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/StoreApi.kt
src/main/kotlin/org/openapitools/client/apis/UserApi.kt src/main/kotlin/org/openapitools/client/apis/UserApi.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt
src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt
@@ -71,6 +137,7 @@ src/main/kotlin/org/openapitools/client/infrastructure/DateAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.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/LocalDateTimeAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/ResponseExt.kt
src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
src/main/kotlin/org/openapitools/client/models/AdditionalPropertiesClass.kt src/main/kotlin/org/openapitools/client/models/AdditionalPropertiesClass.kt
src/main/kotlin/org/openapitools/client/models/Animal.kt src/main/kotlin/org/openapitools/client/models/Animal.kt

View File

@@ -2,7 +2,7 @@
## Requires ## Requires
* Kotlin 1.3.41 * Kotlin 1.3.61
* Gradle 4.9 * Gradle 4.9
## Build ## Build
@@ -35,45 +35,45 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Class | Method | HTTP request | Description Class | Method | HTTP request | Description
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
*AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags *AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **PATCH** another-fake/dummy | To test special tags
*DefaultApi* | [**fooGet**](docs/DefaultApi.md#fooget) | **GET** /foo | *DefaultApi* | [**fooGet**](docs/DefaultApi.md#fooget) | **GET** foo |
*FakeApi* | [**fakeHealthGet**](docs/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint *FakeApi* | [**fakeHealthGet**](docs/FakeApi.md#fakehealthget) | **GET** fake/health | Health check endpoint
*FakeApi* | [**fakeHttpSignatureTest**](docs/FakeApi.md#fakehttpsignaturetest) | **GET** /fake/http-signature-test | test http signature authentication *FakeApi* | [**fakeHttpSignatureTest**](docs/FakeApi.md#fakehttpsignaturetest) | **GET** fake/http-signature-test | test http signature authentication
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | *FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** fake/outer/boolean |
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | *FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** fake/outer/composite |
*FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | *FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** fake/outer/number |
*FakeApi* | [**fakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | *FakeApi* | [**fakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **POST** fake/outer/string |
*FakeApi* | [**testBodyWithFileSchema**](docs/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**testBodyWithFileSchema**](docs/FakeApi.md#testbodywithfileschema) | **PUT** fake/body-with-file-schema |
*FakeApi* | [**testBodyWithQueryParams**](docs/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | *FakeApi* | [**testBodyWithQueryParams**](docs/FakeApi.md#testbodywithqueryparams) | **PUT** fake/body-with-query-params |
*FakeApi* | [**testClientModel**](docs/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model *FakeApi* | [**testClientModel**](docs/FakeApi.md#testclientmodel) | **PATCH** fake | To test \"client\" model
*FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **POST** fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters *FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testenumparameters) | **GET** fake | To test enum parameters
*FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testgroupparameters) | **DELETE** fake | Fake endpoint to test group parameters (optional)
*FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testinlineadditionalproperties) | **POST** fake/inline-additionalProperties | test inline additionalProperties
*FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testjsonformdata) | **GET** fake/jsonFormData | test json serialization of form data
*FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-paramters | *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testqueryparametercollectionformat) | **PUT** fake/test-query-paramters |
*FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testclassname) | **PATCH** fake_classname_test | To test class name in snake case
*PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store *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* | [**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* | [**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* | [**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* | [**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* | [**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* | [**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 *PetApi* | [**uploadFile**](docs/PetApi.md#uploadfile) | **POST** pet/{petId}/uploadImage | uploads an image
*PetApi* | [**uploadFileWithRequiredFile**](docs/PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) *PetApi* | [**uploadFileWithRequiredFile**](docs/PetApi.md#uploadfilewithrequiredfile) | **POST** fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID *StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** store/order/{order_id} | Delete purchase order by ID
*StoreApi* | [**getInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**getInventory**](docs/StoreApi.md#getinventory) | **GET** store/inventory | Returns pet inventories by status
*StoreApi* | [**getOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID *StoreApi* | [**getOrderById**](docs/StoreApi.md#getorderbyid) | **GET** store/order/{order_id} | Find purchase order by ID
*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet *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* | [**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* | [**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* | [**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* | [**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* | [**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* | [**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* | [**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 *UserApi* | [**updateUser**](docs/UserApi.md#updateuser) | **PUT** user/{username} | Updated user
<a name="documentation-for-models"></a> <a name="documentation-for-models"></a>

View File

@@ -31,6 +31,7 @@ test {
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0"
compile "com.google.code.gson:gson:2.8.6" compile "com.google.code.gson:gson:2.8.6"
compile "io.reactivex:rxjava:$rxJavaVersion" compile "io.reactivex:rxjava:$rxJavaVersion"
compile "com.squareup.retrofit2:adapter-rxjava:$retrofitVersion" compile "com.squareup.retrofit2:adapter-rxjava:$retrofitVersion"

View File

@@ -4,12 +4,9 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**call123testSpecialTags**](AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags [**call123testSpecialTags**](AnotherFakeApi.md#call123testSpecialTags) | **PATCH** another-fake/dummy | To test special tags
<a name="call123testSpecialTags"></a>
# **call123testSpecialTags**
> Client call123testSpecialTags(client)
To test special tags To test special tags
@@ -18,21 +15,15 @@ To test special tags and operation ID starting with number
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = AnotherFakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(AnotherFakeApi::class.java)
val client : Client = // Client | client model val client : Client = // Client | client model
try {
val result : Client = apiInstance.call123testSpecialTags(client) val result : Client = webService.call123testSpecialTags(client)
println(result)
} catch (e: ClientException) {
println("4xx response calling AnotherFakeApi#call123testSpecialTags")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling AnotherFakeApi#call123testSpecialTags")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters

View File

@@ -4,32 +4,23 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**fooGet**](DefaultApi.md#fooGet) | **GET** /foo | [**fooGet**](DefaultApi.md#fooGet) | **GET** foo |
<a name="fooGet"></a>
# **fooGet**
> InlineResponseDefault fooGet()
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = DefaultApi() val apiClient = ApiClient()
try { val webService = apiClient.createWebservice(DefaultApi::class.java)
val result : InlineResponseDefault = apiInstance.fooGet()
println(result) val result : InlineResponseDefault = webService.fooGet()
} catch (e: ClientException) {
println("4xx response calling DefaultApi#fooGet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling DefaultApi#fooGet")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters

View File

@@ -4,46 +4,37 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**fakeHealthGet**](FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint [**fakeHealthGet**](FakeApi.md#fakeHealthGet) | **GET** fake/health | Health check endpoint
[**fakeHttpSignatureTest**](FakeApi.md#fakeHttpSignatureTest) | **GET** /fake/http-signature-test | test http signature authentication [**fakeHttpSignatureTest**](FakeApi.md#fakeHttpSignatureTest) | **GET** fake/http-signature-test | test http signature authentication
[**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | [**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** fake/outer/boolean |
[**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | [**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** fake/outer/composite |
[**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | [**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** fake/outer/number |
[**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | [**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** fake/outer/string |
[**testBodyWithFileSchema**](FakeApi.md#testBodyWithFileSchema) | **PUT** /fake/body-with-file-schema | [**testBodyWithFileSchema**](FakeApi.md#testBodyWithFileSchema) | **PUT** fake/body-with-file-schema |
[**testBodyWithQueryParams**](FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params | [**testBodyWithQueryParams**](FakeApi.md#testBodyWithQueryParams) | **PUT** fake/body-with-query-params |
[**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \&quot;client\&quot; model [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** fake | To test \&quot;client\&quot; model
[**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
[**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** fake | To test enum parameters
[**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** fake | Fake endpoint to test group parameters (optional)
[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** fake/inline-additionalProperties | test inline additionalProperties
[**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** fake/jsonFormData | test json serialization of form data
[**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-paramters | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** fake/test-query-paramters |
<a name="fakeHealthGet"></a>
# **fakeHealthGet**
> HealthCheckResult fakeHealthGet()
Health check endpoint Health check endpoint
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
try { val webService = apiClient.createWebservice(FakeApi::class.java)
val result : HealthCheckResult = apiInstance.fakeHealthGet()
println(result) val result : HealthCheckResult = webService.fakeHealthGet()
} catch (e: ClientException) {
println("4xx response calling FakeApi#fakeHealthGet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#fakeHealthGet")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -62,31 +53,23 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/json - **Accept**: application/json
<a name="fakeHttpSignatureTest"></a>
# **fakeHttpSignatureTest**
> fakeHttpSignatureTest(pet, query1, header1)
test http signature authentication test http signature authentication
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val pet : Pet = // Pet | Pet object that needs to be added to the store val pet : Pet = // Pet | Pet object that needs to be added to the store
val query1 : kotlin.String = query1_example // kotlin.String | query parameter val query1 : kotlin.String = query1_example // kotlin.String | query parameter
val header1 : kotlin.String = header1_example // kotlin.String | header parameter val header1 : kotlin.String = header1_example // kotlin.String | header parameter
try {
apiInstance.fakeHttpSignatureTest(pet, query1, header1) webService.fakeHttpSignatureTest(pet, query1, header1)
} catch (e: ClientException) {
println("4xx response calling FakeApi#fakeHttpSignatureTest")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#fakeHttpSignatureTest")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -110,9 +93,6 @@ null (empty response body)
- **Content-Type**: application/json, application/xml - **Content-Type**: application/json, application/xml
- **Accept**: Not defined - **Accept**: Not defined
<a name="fakeOuterBooleanSerialize"></a>
# **fakeOuterBooleanSerialize**
> kotlin.Boolean fakeOuterBooleanSerialize(body)
@@ -121,21 +101,15 @@ Test serialization of outer boolean types
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val body : kotlin.Boolean = true // kotlin.Boolean | Input boolean as post body val body : kotlin.Boolean = true // kotlin.Boolean | Input boolean as post body
try {
val result : kotlin.Boolean = apiInstance.fakeOuterBooleanSerialize(body) val result : kotlin.Boolean = webService.fakeOuterBooleanSerialize(body)
println(result)
} catch (e: ClientException) {
println("4xx response calling FakeApi#fakeOuterBooleanSerialize")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#fakeOuterBooleanSerialize")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -157,9 +131,6 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: */* - **Accept**: */*
<a name="fakeOuterCompositeSerialize"></a>
# **fakeOuterCompositeSerialize**
> OuterComposite fakeOuterCompositeSerialize(outerComposite)
@@ -168,21 +139,15 @@ Test serialization of object with outer number type
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val outerComposite : OuterComposite = // OuterComposite | Input composite as post body val outerComposite : OuterComposite = // OuterComposite | Input composite as post body
try {
val result : OuterComposite = apiInstance.fakeOuterCompositeSerialize(outerComposite) val result : OuterComposite = webService.fakeOuterCompositeSerialize(outerComposite)
println(result)
} catch (e: ClientException) {
println("4xx response calling FakeApi#fakeOuterCompositeSerialize")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#fakeOuterCompositeSerialize")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -204,9 +169,6 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: */* - **Accept**: */*
<a name="fakeOuterNumberSerialize"></a>
# **fakeOuterNumberSerialize**
> java.math.BigDecimal fakeOuterNumberSerialize(body)
@@ -215,21 +177,15 @@ Test serialization of outer number types
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val body : java.math.BigDecimal = 8.14 // java.math.BigDecimal | Input number as post body val body : java.math.BigDecimal = 8.14 // java.math.BigDecimal | Input number as post body
try {
val result : java.math.BigDecimal = apiInstance.fakeOuterNumberSerialize(body) val result : java.math.BigDecimal = webService.fakeOuterNumberSerialize(body)
println(result)
} catch (e: ClientException) {
println("4xx response calling FakeApi#fakeOuterNumberSerialize")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#fakeOuterNumberSerialize")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -251,9 +207,6 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: */* - **Accept**: */*
<a name="fakeOuterStringSerialize"></a>
# **fakeOuterStringSerialize**
> kotlin.String fakeOuterStringSerialize(body)
@@ -262,21 +215,15 @@ Test serialization of outer string types
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val body : kotlin.String = body_example // kotlin.String | Input string as post body val body : kotlin.String = body_example // kotlin.String | Input string as post body
try {
val result : kotlin.String = apiInstance.fakeOuterStringSerialize(body) val result : kotlin.String = webService.fakeOuterStringSerialize(body)
println(result)
} catch (e: ClientException) {
println("4xx response calling FakeApi#fakeOuterStringSerialize")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#fakeOuterStringSerialize")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -298,9 +245,6 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: */* - **Accept**: */*
<a name="testBodyWithFileSchema"></a>
# **testBodyWithFileSchema**
> testBodyWithFileSchema(fileSchemaTestClass)
@@ -309,20 +253,15 @@ For this test, the body for this request much reference a schema named &#x60;Fil
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val fileSchemaTestClass : FileSchemaTestClass = // FileSchemaTestClass | val fileSchemaTestClass : FileSchemaTestClass = // FileSchemaTestClass |
try {
apiInstance.testBodyWithFileSchema(fileSchemaTestClass) webService.testBodyWithFileSchema(fileSchemaTestClass)
} catch (e: ClientException) {
println("4xx response calling FakeApi#testBodyWithFileSchema")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testBodyWithFileSchema")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -344,30 +283,22 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: Not defined - **Accept**: Not defined
<a name="testBodyWithQueryParams"></a>
# **testBodyWithQueryParams**
> testBodyWithQueryParams(query, user)
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val query : kotlin.String = query_example // kotlin.String | val query : kotlin.String = query_example // kotlin.String |
val user : User = // User | val user : User = // User |
try {
apiInstance.testBodyWithQueryParams(query, user) webService.testBodyWithQueryParams(query, user)
} catch (e: ClientException) {
println("4xx response calling FakeApi#testBodyWithQueryParams")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testBodyWithQueryParams")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -390,9 +321,6 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: Not defined - **Accept**: Not defined
<a name="testClientModel"></a>
# **testClientModel**
> Client testClientModel(client)
To test \&quot;client\&quot; model To test \&quot;client\&quot; model
@@ -401,21 +329,15 @@ To test \&quot;client\&quot; model
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val client : Client = // Client | client model val client : Client = // Client | client model
try {
val result : Client = apiInstance.testClientModel(client) val result : Client = webService.testClientModel(client)
println(result)
} catch (e: ClientException) {
println("4xx response calling FakeApi#testClientModel")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testClientModel")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -437,9 +359,6 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: application/json - **Accept**: application/json
<a name="testEndpointParameters"></a>
# **testEndpointParameters**
> testEndpointParameters(number, double, patternWithoutDelimiter, byte, integer, int32, int64, float, string, binary, date, dateTime, password, paramCallback)
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@@ -448,10 +367,13 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
apiClient.setCredentials("USERNAME", "PASSWORD")
val webService = apiClient.createWebservice(FakeApi::class.java)
val number : java.math.BigDecimal = 8.14 // java.math.BigDecimal | None val number : java.math.BigDecimal = 8.14 // java.math.BigDecimal | None
val double : kotlin.Double = 1.2 // kotlin.Double | None val double : kotlin.Double = 1.2 // kotlin.Double | None
val patternWithoutDelimiter : kotlin.String = patternWithoutDelimiter_example // kotlin.String | None val patternWithoutDelimiter : kotlin.String = patternWithoutDelimiter_example // kotlin.String | None
@@ -466,15 +388,8 @@ val date : java.time.LocalDate = 2013-10-20 // java.time.LocalDate | None
val dateTime : java.time.OffsetDateTime = 2013-10-20T19:20:30+01:00 // java.time.OffsetDateTime | None val dateTime : java.time.OffsetDateTime = 2013-10-20T19:20:30+01:00 // java.time.OffsetDateTime | None
val password : kotlin.String = password_example // kotlin.String | None val password : kotlin.String = password_example // kotlin.String | None
val paramCallback : kotlin.String = paramCallback_example // kotlin.String | None val paramCallback : kotlin.String = paramCallback_example // kotlin.String | None
try {
apiInstance.testEndpointParameters(number, double, patternWithoutDelimiter, byte, integer, int32, int64, float, string, binary, date, dateTime, password, paramCallback) webService.testEndpointParameters(number, double, patternWithoutDelimiter, byte, integer, int32, int64, float, string, binary, date, dateTime, password, paramCallback)
} catch (e: ClientException) {
println("4xx response calling FakeApi#testEndpointParameters")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testEndpointParameters")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -504,17 +419,13 @@ null (empty response body)
Configure http_basic_test: Configure http_basic_test:
ApiClient.username = "" ApiClient().setCredentials("USERNAME", "PASSWORD")
ApiClient.password = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: application/x-www-form-urlencoded - **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined - **Accept**: Not defined
<a name="testEnumParameters"></a>
# **testEnumParameters**
> testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString)
To test enum parameters To test enum parameters
@@ -523,10 +434,12 @@ To test enum parameters
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val enumHeaderStringArray : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Header parameter enum test (string array) val enumHeaderStringArray : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Header parameter enum test (string array)
val enumHeaderString : kotlin.String = enumHeaderString_example // kotlin.String | Header parameter enum test (string) val enumHeaderString : kotlin.String = enumHeaderString_example // kotlin.String | Header parameter enum test (string)
val enumQueryStringArray : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Query parameter enum test (string array) val enumQueryStringArray : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Query parameter enum test (string array)
@@ -535,15 +448,8 @@ val enumQueryInteger : kotlin.Int = 56 // kotlin.Int | Query parameter enum test
val enumQueryDouble : kotlin.Double = 1.2 // kotlin.Double | Query parameter enum test (double) val enumQueryDouble : kotlin.Double = 1.2 // kotlin.Double | Query parameter enum test (double)
val enumFormStringArray : kotlin.Array<kotlin.String> = enumFormStringArray_example // kotlin.Array<kotlin.String> | Form parameter enum test (string array) val enumFormStringArray : kotlin.Array<kotlin.String> = enumFormStringArray_example // kotlin.Array<kotlin.String> | Form parameter enum test (string array)
val enumFormString : kotlin.String = enumFormString_example // kotlin.String | Form parameter enum test (string) val enumFormString : kotlin.String = enumFormString_example // kotlin.String | Form parameter enum test (string)
try {
apiInstance.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString) webService.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString)
} catch (e: ClientException) {
println("4xx response calling FakeApi#testEnumParameters")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testEnumParameters")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -572,9 +478,6 @@ No authorization required
- **Content-Type**: application/x-www-form-urlencoded - **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined - **Accept**: Not defined
<a name="testGroupParameters"></a>
# **testGroupParameters**
> testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group)
Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional)
@@ -583,25 +486,21 @@ Fake endpoint to test group parameters (optional)
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
apiClient.setBearerToken("TOKEN")
val webService = apiClient.createWebservice(FakeApi::class.java)
val requiredStringGroup : kotlin.Int = 56 // kotlin.Int | Required String in group parameters val requiredStringGroup : kotlin.Int = 56 // kotlin.Int | Required String in group parameters
val requiredBooleanGroup : kotlin.Boolean = true // kotlin.Boolean | Required Boolean in group parameters val requiredBooleanGroup : kotlin.Boolean = true // kotlin.Boolean | Required Boolean in group parameters
val requiredInt64Group : kotlin.Long = 789 // kotlin.Long | Required Integer in group parameters val requiredInt64Group : kotlin.Long = 789 // kotlin.Long | Required Integer in group parameters
val stringGroup : kotlin.Int = 56 // kotlin.Int | String in group parameters val stringGroup : kotlin.Int = 56 // kotlin.Int | String in group parameters
val booleanGroup : kotlin.Boolean = true // kotlin.Boolean | Boolean in group parameters val booleanGroup : kotlin.Boolean = true // kotlin.Boolean | Boolean in group parameters
val int64Group : kotlin.Long = 789 // kotlin.Long | Integer in group parameters val int64Group : kotlin.Long = 789 // kotlin.Long | Integer in group parameters
try {
apiInstance.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group) webService.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group)
} catch (e: ClientException) {
println("4xx response calling FakeApi#testGroupParameters")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testGroupParameters")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -623,36 +522,28 @@ null (empty response body)
Configure bearer_test: Configure bearer_test:
ApiClient.accessToken = "" ApiClient().setBearerToken("TOKEN")
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: Not defined - **Accept**: Not defined
<a name="testInlineAdditionalProperties"></a>
# **testInlineAdditionalProperties**
> testInlineAdditionalProperties(requestBody)
test inline additionalProperties test inline additionalProperties
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val requestBody : kotlin.collections.Map<kotlin.String, kotlin.String> = // kotlin.collections.Map<kotlin.String, kotlin.String> | request body val requestBody : kotlin.collections.Map<kotlin.String, kotlin.String> = // kotlin.collections.Map<kotlin.String, kotlin.String> | request body
try {
apiInstance.testInlineAdditionalProperties(requestBody) webService.testInlineAdditionalProperties(requestBody)
} catch (e: ClientException) {
println("4xx response calling FakeApi#testInlineAdditionalProperties")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testInlineAdditionalProperties")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -674,30 +565,22 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: Not defined - **Accept**: Not defined
<a name="testJsonFormData"></a>
# **testJsonFormData**
> testJsonFormData(param, param2)
test json serialization of form data test json serialization of form data
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val param : kotlin.String = param_example // kotlin.String | field1 val param : kotlin.String = param_example // kotlin.String | field1
val param2 : kotlin.String = param2_example // kotlin.String | field2 val param2 : kotlin.String = param2_example // kotlin.String | field2
try {
apiInstance.testJsonFormData(param, param2) webService.testJsonFormData(param, param2)
} catch (e: ClientException) {
println("4xx response calling FakeApi#testJsonFormData")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testJsonFormData")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -720,9 +603,6 @@ No authorization required
- **Content-Type**: application/x-www-form-urlencoded - **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined - **Accept**: Not defined
<a name="testQueryParameterCollectionFormat"></a>
# **testQueryParameterCollectionFormat**
> testQueryParameterCollectionFormat(pipe, ioutil, http, url, context)
@@ -731,24 +611,19 @@ To test the collection format in query parameters
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeApi::class.java)
val pipe : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | val pipe : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> |
val ioutil : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | val ioutil : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> |
val http : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | val http : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> |
val url : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | val url : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> |
val context : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | val context : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> |
try {
apiInstance.testQueryParameterCollectionFormat(pipe, ioutil, http, url, context) webService.testQueryParameterCollectionFormat(pipe, ioutil, http, url, context)
} catch (e: ClientException) {
println("4xx response calling FakeApi#testQueryParameterCollectionFormat")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#testQueryParameterCollectionFormat")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters

View File

@@ -4,12 +4,9 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case [**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** fake_classname_test | To test class name in snake case
<a name="testClassname"></a>
# **testClassname**
> Client testClassname(client)
To test class name in snake case To test class name in snake case
@@ -18,21 +15,15 @@ To test class name in snake case
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = FakeClassnameTags123Api() val apiClient = ApiClient()
val webService = apiClient.createWebservice(FakeClassnameTags123Api::class.java)
val client : Client = // Client | client model val client : Client = // Client | client model
try {
val result : Client = apiInstance.testClassname(client) val result : Client = webService.testClassname(client)
println(result)
} catch (e: ClientException) {
println("4xx response calling FakeClassnameTags123Api#testClassname")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeClassnameTags123Api#testClassname")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -48,9 +39,6 @@ Name | Type | Description | Notes
### Authorization ### Authorization
Configure api_key_query:
ApiClient.apiKey["api_key_query"] = ""
ApiClient.apiKeyPrefix["api_key_query"] = ""
### HTTP request headers ### HTTP request headers

View File

@@ -4,40 +4,32 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store [**addPet**](PetApi.md#addPet) | **POST** pet | Add a new pet to the store
[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet [**deletePet**](PetApi.md#deletePet) | **DELETE** pet/{petId} | Deletes a pet
[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status [**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** pet/findByStatus | Finds Pets by status
[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags [**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** pet/findByTags | Finds Pets by tags
[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID [**getPetById**](PetApi.md#getPetById) | **GET** pet/{petId} | Find pet by ID
[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**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 [**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 [**uploadFile**](PetApi.md#uploadFile) | **POST** pet/{petId}/uploadImage | uploads an image
[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) [**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
<a name="addPet"></a>
# **addPet**
> addPet(pet)
Add a new pet to the store Add a new pet to the store
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val pet : Pet = // Pet | Pet object that needs to be added to the store val pet : Pet = // Pet | Pet object that needs to be added to the store
try {
apiInstance.addPet(pet) webService.addPet(pet)
} catch (e: ClientException) {
println("4xx response calling PetApi#addPet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#addPet")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -53,38 +45,28 @@ null (empty response body)
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: application/json, application/xml - **Content-Type**: application/json, application/xml
- **Accept**: Not defined - **Accept**: Not defined
<a name="deletePet"></a>
# **deletePet**
> deletePet(petId, apiKey)
Deletes a pet Deletes a pet
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val petId : kotlin.Long = 789 // kotlin.Long | Pet id to delete val petId : kotlin.Long = 789 // kotlin.Long | Pet id to delete
val apiKey : kotlin.String = apiKey_example // kotlin.String | val apiKey : kotlin.String = apiKey_example // kotlin.String |
try {
apiInstance.deletePet(petId, apiKey) webService.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 ### Parameters
@@ -101,17 +83,12 @@ null (empty response body)
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: Not defined - **Accept**: Not defined
<a name="findPetsByStatus"></a>
# **findPetsByStatus**
> kotlin.Array&lt;Pet&gt; findPetsByStatus(status)
Finds Pets by status Finds Pets by status
@@ -120,21 +97,15 @@ Multiple status values can be provided with comma separated strings
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val status : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Status values that need to be considered for filter val status : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Status values that need to be considered for filter
try {
val result : kotlin.Array<Pet> = apiInstance.findPetsByStatus(status) val result : kotlin.Array<Pet> = webService.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 ### Parameters
@@ -150,17 +121,12 @@ Name | Type | Description | Notes
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="findPetsByTags"></a>
# **findPetsByTags**
> kotlin.Array&lt;Pet&gt; findPetsByTags(tags)
Finds Pets by tags Finds Pets by tags
@@ -169,21 +135,15 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val tags : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Tags to filter by val tags : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Tags to filter by
try {
val result : kotlin.Array<Pet> = apiInstance.findPetsByTags(tags) val result : kotlin.Array<Pet> = webService.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 ### Parameters
@@ -199,17 +159,12 @@ Name | Type | Description | Notes
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="getPetById"></a>
# **getPetById**
> Pet getPetById(petId)
Find pet by ID Find pet by ID
@@ -218,21 +173,15 @@ Returns a single pet
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to return val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to return
try {
val result : Pet = apiInstance.getPetById(petId) val result : Pet = webService.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 ### Parameters
@@ -248,38 +197,27 @@ Name | Type | Description | Notes
### Authorization ### Authorization
Configure api_key:
ApiClient.apiKey["api_key"] = ""
ApiClient.apiKeyPrefix["api_key"] = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="updatePet"></a>
# **updatePet**
> updatePet(pet)
Update an existing pet Update an existing pet
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val pet : Pet = // Pet | Pet object that needs to be added to the store val pet : Pet = // Pet | Pet object that needs to be added to the store
try {
apiInstance.updatePet(pet) webService.updatePet(pet)
} catch (e: ClientException) {
println("4xx response calling PetApi#updatePet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#updatePet")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -295,39 +233,29 @@ null (empty response body)
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: application/json, application/xml - **Content-Type**: application/json, application/xml
- **Accept**: Not defined - **Accept**: Not defined
<a name="updatePetWithForm"></a>
# **updatePetWithForm**
> updatePetWithForm(petId, name, status)
Updates a pet in the store with form data Updates a pet in the store with form data
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be updated 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 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 val status : kotlin.String = status_example // kotlin.String | Updated status of the pet
try {
apiInstance.updatePetWithForm(petId, name, status) webService.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 ### Parameters
@@ -345,40 +273,29 @@ null (empty response body)
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: application/x-www-form-urlencoded - **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined - **Accept**: Not defined
<a name="uploadFile"></a>
# **uploadFile**
> ApiResponse uploadFile(petId, additionalMetadata, file)
uploads an image uploads an image
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to update 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 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 val file : java.io.File = BINARY_DATA_HERE // java.io.File | file to upload
try {
val result : ApiResponse = apiInstance.uploadFile(petId, additionalMetadata, file) val result : ApiResponse = webService.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 ### Parameters
@@ -396,40 +313,29 @@ Name | Type | Description | Notes
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: multipart/form-data - **Content-Type**: multipart/form-data
- **Accept**: application/json - **Accept**: application/json
<a name="uploadFileWithRequiredFile"></a>
# **uploadFileWithRequiredFile**
> ApiResponse uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata)
uploads an image (required) uploads an image (required)
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = PetApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(PetApi::class.java)
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to update val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to update
val requiredFile : java.io.File = BINARY_DATA_HERE // java.io.File | file to upload val requiredFile : java.io.File = BINARY_DATA_HERE // java.io.File | file to upload
val additionalMetadata : kotlin.String = additionalMetadata_example // kotlin.String | Additional data to pass to server val additionalMetadata : kotlin.String = additionalMetadata_example // kotlin.String | Additional data to pass to server
try {
val result : ApiResponse = apiInstance.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata) val result : ApiResponse = webService.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata)
println(result)
} catch (e: ClientException) {
println("4xx response calling PetApi#uploadFileWithRequiredFile")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#uploadFileWithRequiredFile")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -447,8 +353,6 @@ Name | Type | Description | Notes
### Authorization ### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers ### HTTP request headers

View File

@@ -4,15 +4,12 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID [**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** store/order/{order_id} | Delete purchase order by ID
[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status [**getInventory**](StoreApi.md#getInventory) | **GET** store/inventory | Returns pet inventories by status
[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID [**getOrderById**](StoreApi.md#getOrderById) | **GET** store/order/{order_id} | Find purchase order by ID
[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet [**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 Delete purchase order by ID
@@ -21,20 +18,15 @@ For valid response try integer IDs with value &lt; 1000. Anything above 1000 or
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = StoreApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(StoreApi::class.java)
val orderId : kotlin.String = orderId_example // kotlin.String | ID of the order that needs to be deleted val orderId : kotlin.String = orderId_example // kotlin.String | ID of the order that needs to be deleted
try {
apiInstance.deleteOrder(orderId) webService.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 ### Parameters
@@ -56,9 +48,6 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: 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 pet inventories by status
@@ -67,20 +56,14 @@ Returns a map of status codes to quantities
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = StoreApi() val apiClient = ApiClient()
try { val webService = apiClient.createWebservice(StoreApi::class.java)
val result : kotlin.collections.Map<kotlin.String, kotlin.Int> = apiInstance.getInventory()
println(result) val result : kotlin.collections.Map<kotlin.String, kotlin.Int> = webService.getInventory()
} catch (e: ClientException) {
println("4xx response calling StoreApi#getInventory")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling StoreApi#getInventory")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -93,18 +76,12 @@ This endpoint does not need any parameter.
### Authorization ### Authorization
Configure api_key:
ApiClient.apiKey["api_key"] = ""
ApiClient.apiKeyPrefix["api_key"] = ""
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/json - **Accept**: application/json
<a name="getOrderById"></a>
# **getOrderById**
> Order getOrderById(orderId)
Find purchase order by ID Find purchase order by ID
@@ -113,21 +90,15 @@ For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other val
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = StoreApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(StoreApi::class.java)
val orderId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be fetched val orderId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be fetched
try {
val result : Order = apiInstance.getOrderById(orderId) val result : Order = webService.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 ### Parameters
@@ -149,30 +120,21 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="placeOrder"></a>
# **placeOrder**
> Order placeOrder(order)
Place an order for a pet Place an order for a pet
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = StoreApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(StoreApi::class.java)
val order : Order = // Order | order placed for purchasing the pet val order : Order = // Order | order placed for purchasing the pet
try {
val result : Order = apiInstance.placeOrder(order) val result : Order = webService.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 ### Parameters

View File

@@ -4,19 +4,16 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**createUser**](UserApi.md#createUser) | **POST** /user | Create user [**createUser**](UserApi.md#createUser) | **POST** user | Create user
[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array [**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 [**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** user/createWithList | Creates list of users with given input array
[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user [**deleteUser**](UserApi.md#deleteUser) | **DELETE** user/{username} | Delete user
[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name [**getUserByName**](UserApi.md#getUserByName) | **GET** user/{username} | Get user by user name
[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system [**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 [**logoutUser**](UserApi.md#logoutUser) | **GET** user/logout | Logs out current logged in user session
[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user [**updateUser**](UserApi.md#updateUser) | **PUT** user/{username} | Updated user
<a name="createUser"></a>
# **createUser**
> createUser(user)
Create user Create user
@@ -25,20 +22,15 @@ This can only be done by the logged in user.
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val user : User = // User | Created user object val user : User = // User | Created user object
try {
apiInstance.createUser(user) webService.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 ### Parameters
@@ -60,29 +52,21 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: Not defined - **Accept**: Not defined
<a name="createUsersWithArrayInput"></a>
# **createUsersWithArrayInput**
> createUsersWithArrayInput(user)
Creates list of users with given input array Creates list of users with given input array
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val user : kotlin.Array<User> = // kotlin.Array<User> | List of user object val user : kotlin.Array<User> = // kotlin.Array<User> | List of user object
try {
apiInstance.createUsersWithArrayInput(user) webService.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 ### Parameters
@@ -104,29 +88,21 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: Not defined - **Accept**: Not defined
<a name="createUsersWithListInput"></a>
# **createUsersWithListInput**
> createUsersWithListInput(user)
Creates list of users with given input array Creates list of users with given input array
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val user : kotlin.Array<User> = // kotlin.Array<User> | List of user object val user : kotlin.Array<User> = // kotlin.Array<User> | List of user object
try {
apiInstance.createUsersWithListInput(user) webService.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 ### Parameters
@@ -148,9 +124,6 @@ No authorization required
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: Not defined - **Accept**: Not defined
<a name="deleteUser"></a>
# **deleteUser**
> deleteUser(username)
Delete user Delete user
@@ -159,20 +132,15 @@ This can only be done by the logged in user.
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val username : kotlin.String = username_example // kotlin.String | The name that needs to be deleted val username : kotlin.String = username_example // kotlin.String | The name that needs to be deleted
try {
apiInstance.deleteUser(username) webService.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 ### Parameters
@@ -194,30 +162,21 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: Not defined - **Accept**: Not defined
<a name="getUserByName"></a>
# **getUserByName**
> User getUserByName(username)
Get user by user name Get user by user name
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing. 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) val result : User = webService.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 ### Parameters
@@ -239,31 +198,22 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="loginUser"></a>
# **loginUser**
> kotlin.String loginUser(username, password)
Logs user into the system Logs user into the system
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val username : kotlin.String = username_example // kotlin.String | The user name for login 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 val password : kotlin.String = password_example // kotlin.String | The password for login in clear text
try {
val result : kotlin.String = apiInstance.loginUser(username, password) val result : kotlin.String = webService.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 ### Parameters
@@ -286,28 +236,20 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
<a name="logoutUser"></a>
# **logoutUser**
> logoutUser()
Logs out current logged in user session Logs out current logged in user session
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
try { val webService = apiClient.createWebservice(UserApi::class.java)
apiInstance.logoutUser()
} catch (e: ClientException) { webService.logoutUser()
println("4xx response calling UserApi#logoutUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#logoutUser")
e.printStackTrace()
}
``` ```
### Parameters ### Parameters
@@ -326,9 +268,6 @@ No authorization required
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: Not defined - **Accept**: Not defined
<a name="updateUser"></a>
# **updateUser**
> updateUser(username, user)
Updated user Updated user
@@ -337,21 +276,16 @@ This can only be done by the logged in user.
### Example ### Example
```kotlin ```kotlin
// Import classes: // Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.* //import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.* //import org.openapitools.client.models.*
val apiInstance = UserApi() val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val username : kotlin.String = username_example // kotlin.String | name that need to be deleted val username : kotlin.String = username_example // kotlin.String | name that need to be deleted
val user : User = // User | Updated user object val user : User = // User | Updated user object
try {
apiInstance.updateUser(username, user) webService.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 ### Parameters

View File

@@ -3,14 +3,21 @@ package org.openapitools.client.apis
import org.openapitools.client.infrastructure.CollectionFormats.* import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import rx.Observable import rx.Observable
import org.openapitools.client.models.Client import org.openapitools.client.models.Client
interface AnotherFakeApi { interface AnotherFakeApi {
@PATCH("/another-fake/dummy") /**
* To test special tags
* To test special tags and operation ID starting with number
* Responses:
* - 200: successful operation
*
* @param client client model
* @return [Call]<[Client]>
*/
@PATCH("another-fake/dummy")
fun call123testSpecialTags(@Body client: Client): Observable<Client> fun call123testSpecialTags(@Body client: Client): Observable<Client>
} }

View File

@@ -3,14 +3,20 @@ package org.openapitools.client.apis
import org.openapitools.client.infrastructure.CollectionFormats.* import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import rx.Observable import rx.Observable
import org.openapitools.client.models.InlineResponseDefault import org.openapitools.client.models.InlineResponseDefault
interface DefaultApi { interface DefaultApi {
@GET("/foo") /**
*
*
* Responses:
* - 0: response
*
* @return [Call]<[InlineResponseDefault]>
*/
@GET("foo")
fun fooGet(): Observable<InlineResponseDefault> fun fooGet(): Observable<InlineResponseDefault>
} }

View File

@@ -3,8 +3,6 @@ package org.openapitools.client.apis
import org.openapitools.client.infrastructure.CollectionFormats.* import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import rx.Observable import rx.Observable
import org.openapitools.client.models.Client import org.openapitools.client.models.Client
@@ -15,52 +13,221 @@ import org.openapitools.client.models.Pet
import org.openapitools.client.models.User import org.openapitools.client.models.User
interface FakeApi { interface FakeApi {
@GET("/fake/health") /**
* Health check endpoint
*
* Responses:
* - 200: The instance started successfully
*
* @return [Call]<[HealthCheckResult]>
*/
@GET("fake/health")
fun fakeHealthGet(): Observable<HealthCheckResult> fun fakeHealthGet(): Observable<HealthCheckResult>
@GET("/fake/http-signature-test") /**
* test http signature authentication
*
* Responses:
* - 200: The instance started successfully
*
* @param pet Pet object that needs to be added to the store
* @param query1 query parameter (optional)
* @param header1 header parameter (optional)
* @return [Call]<[Unit]>
*/
@GET("fake/http-signature-test")
fun fakeHttpSignatureTest(@Body pet: Pet, @Query("query_1") query1: kotlin.String, @Header("header_1") header1: kotlin.String): Observable<Unit> fun fakeHttpSignatureTest(@Body pet: Pet, @Query("query_1") query1: kotlin.String, @Header("header_1") header1: kotlin.String): Observable<Unit>
@POST("/fake/outer/boolean") /**
fun fakeOuterBooleanSerialize(@Body body: kotlin.Boolean): Observable<kotlin.Boolean> *
* Test serialization of outer boolean types
* Responses:
* - 200: Output boolean
*
* @param body Input boolean as post body (optional)
* @return [Call]<[kotlin.Boolean]>
*/
@POST("fake/outer/boolean")
fun fakeOuterBooleanSerialize(@Body body: kotlin.Boolean? = null): Observable<kotlin.Boolean>
@POST("/fake/outer/composite") /**
fun fakeOuterCompositeSerialize(@Body outerComposite: OuterComposite): Observable<OuterComposite> *
* Test serialization of object with outer number type
* Responses:
* - 200: Output composite
*
* @param outerComposite Input composite as post body (optional)
* @return [Call]<[OuterComposite]>
*/
@POST("fake/outer/composite")
fun fakeOuterCompositeSerialize(@Body outerComposite: OuterComposite? = null): Observable<OuterComposite>
@POST("/fake/outer/number") /**
fun fakeOuterNumberSerialize(@Body body: java.math.BigDecimal): Observable<java.math.BigDecimal> *
* Test serialization of outer number types
* Responses:
* - 200: Output number
*
* @param body Input number as post body (optional)
* @return [Call]<[java.math.BigDecimal]>
*/
@POST("fake/outer/number")
fun fakeOuterNumberSerialize(@Body body: java.math.BigDecimal? = null): Observable<java.math.BigDecimal>
@POST("/fake/outer/string") /**
fun fakeOuterStringSerialize(@Body body: kotlin.String): Observable<kotlin.String> *
* Test serialization of outer string types
* Responses:
* - 200: Output string
*
* @param body Input string as post body (optional)
* @return [Call]<[kotlin.String]>
*/
@POST("fake/outer/string")
fun fakeOuterStringSerialize(@Body body: kotlin.String? = null): Observable<kotlin.String>
@PUT("/fake/body-with-file-schema") /**
*
* For this test, the body for this request much reference a schema named &#x60;File&#x60;.
* Responses:
* - 200: Success
*
* @param fileSchemaTestClass
* @return [Call]<[Unit]>
*/
@PUT("fake/body-with-file-schema")
fun testBodyWithFileSchema(@Body fileSchemaTestClass: FileSchemaTestClass): Observable<Unit> fun testBodyWithFileSchema(@Body fileSchemaTestClass: FileSchemaTestClass): Observable<Unit>
@PUT("/fake/body-with-query-params") /**
*
*
* Responses:
* - 200: Success
*
* @param query
* @param user
* @return [Call]<[Unit]>
*/
@PUT("fake/body-with-query-params")
fun testBodyWithQueryParams(@Query("query") query: kotlin.String, @Body user: User): Observable<Unit> fun testBodyWithQueryParams(@Query("query") query: kotlin.String, @Body user: User): Observable<Unit>
@PATCH("/fake") /**
* To test \&quot;client\&quot; model
* To test \&quot;client\&quot; model
* Responses:
* - 200: successful operation
*
* @param client client model
* @return [Call]<[Client]>
*/
@PATCH("fake")
fun testClientModel(@Body client: Client): Observable<Client> fun testClientModel(@Body client: Client): Observable<Client>
/**
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
* Responses:
* - 400: Invalid username supplied
* - 404: User not found
*
* @param number None
* @param double None
* @param patternWithoutDelimiter None
* @param byte None
* @param integer None (optional)
* @param int32 None (optional)
* @param int64 None (optional)
* @param float None (optional)
* @param string None (optional)
* @param binary None (optional)
* @param date None (optional)
* @param dateTime None (optional)
* @param password None (optional)
* @param paramCallback None (optional)
* @return [Call]<[Unit]>
*/
@FormUrlEncoded @FormUrlEncoded
@POST("/fake") @POST("fake")
fun testEndpointParameters(@Field("number") number: java.math.BigDecimal, @Field("double") double: kotlin.Double, @Field("pattern_without_delimiter") patternWithoutDelimiter: kotlin.String, @Field("byte") byte: kotlin.ByteArray, @Field("integer") integer: kotlin.Int, @Field("int32") int32: kotlin.Int, @Field("int64") int64: kotlin.Long, @Field("float") float: kotlin.Float, @Field("string") string: kotlin.String, @Field("binary") binary: MultipartBody.Part, @Field("date") date: java.time.LocalDate, @Field("dateTime") dateTime: java.time.OffsetDateTime, @Field("password") password: kotlin.String, @Field("callback") paramCallback: kotlin.String): Observable<Unit> fun testEndpointParameters(@Field("number") number: java.math.BigDecimal, @Field("double") double: kotlin.Double, @Field("pattern_without_delimiter") patternWithoutDelimiter: kotlin.String, @Field("byte") byte: kotlin.ByteArray, @Field("integer") integer: kotlin.Int, @Field("int32") int32: kotlin.Int, @Field("int64") int64: kotlin.Long, @Field("float") float: kotlin.Float, @Field("string") string: kotlin.String, @Field("binary") binary: MultipartBody.Part, @Field("date") date: java.time.LocalDate, @Field("dateTime") dateTime: java.time.OffsetDateTime, @Field("password") password: kotlin.String, @Field("callback") paramCallback: kotlin.String): Observable<Unit>
/**
* To test enum parameters
* To test enum parameters
* Responses:
* - 400: Invalid request
* - 404: Not found
*
* @param enumHeaderStringArray Header parameter enum test (string array) (optional)
* @param enumHeaderString Header parameter enum test (string) (optional, default to "-efg")
* @param enumQueryStringArray Query parameter enum test (string array) (optional)
* @param enumQueryString Query parameter enum test (string) (optional, default to "-efg")
* @param enumQueryInteger Query parameter enum test (double) (optional)
* @param enumQueryDouble Query parameter enum test (double) (optional)
* @param enumFormStringArray Form parameter enum test (string array) (optional, default to "$")
* @param enumFormString Form parameter enum test (string) (optional, default to "-efg")
* @return [Call]<[Unit]>
*/
@FormUrlEncoded @FormUrlEncoded
@GET("/fake") @GET("fake")
fun testEnumParameters(@Header("enum_header_string_array") enumHeaderStringArray: kotlin.Array<kotlin.String>, @Header("enum_header_string") enumHeaderString: kotlin.String, @Query("enum_query_string_array") enumQueryStringArray: kotlin.Array<kotlin.String>, @Query("enum_query_string") enumQueryString: kotlin.String, @Query("enum_query_integer") enumQueryInteger: kotlin.Int, @Query("enum_query_double") enumQueryDouble: kotlin.Double, @Field("enum_form_string_array") enumFormStringArray: kotlin.Array<kotlin.String>, @Field("enum_form_string") enumFormString: kotlin.String): Observable<Unit> fun testEnumParameters(@Header("enum_header_string_array") enumHeaderStringArray: kotlin.Array<kotlin.String>, @Header("enum_header_string") enumHeaderString: kotlin.String, @Query("enum_query_string_array") enumQueryStringArray: kotlin.Array<kotlin.String>, @Query("enum_query_string") enumQueryString: kotlin.String, @Query("enum_query_integer") enumQueryInteger: kotlin.Int, @Query("enum_query_double") enumQueryDouble: kotlin.Double, @Field("enum_form_string_array") enumFormStringArray: kotlin.Array<kotlin.String>, @Field("enum_form_string") enumFormString: kotlin.String): Observable<Unit>
@DELETE("/fake") /**
* Fake endpoint to test group parameters (optional)
* Fake endpoint to test group parameters (optional)
* Responses:
* - 400: Someting wrong
*
* @param requiredStringGroup Required String in group parameters
* @param requiredBooleanGroup Required Boolean in group parameters
* @param requiredInt64Group Required Integer in group parameters
* @param stringGroup String in group parameters (optional)
* @param booleanGroup Boolean in group parameters (optional)
* @param int64Group Integer in group parameters (optional)
* @return [Call]<[Unit]>
*/
@DELETE("fake")
fun testGroupParameters(@Query("required_string_group") requiredStringGroup: kotlin.Int, @Header("required_boolean_group") requiredBooleanGroup: kotlin.Boolean, @Query("required_int64_group") requiredInt64Group: kotlin.Long, @Query("string_group") stringGroup: kotlin.Int, @Header("boolean_group") booleanGroup: kotlin.Boolean, @Query("int64_group") int64Group: kotlin.Long): Observable<Unit> fun testGroupParameters(@Query("required_string_group") requiredStringGroup: kotlin.Int, @Header("required_boolean_group") requiredBooleanGroup: kotlin.Boolean, @Query("required_int64_group") requiredInt64Group: kotlin.Long, @Query("string_group") stringGroup: kotlin.Int, @Header("boolean_group") booleanGroup: kotlin.Boolean, @Query("int64_group") int64Group: kotlin.Long): Observable<Unit>
@POST("/fake/inline-additionalProperties") /**
* test inline additionalProperties
*
* Responses:
* - 200: successful operation
*
* @param requestBody request body
* @return [Call]<[Unit]>
*/
@POST("fake/inline-additionalProperties")
fun testInlineAdditionalProperties(@Body requestBody: kotlin.collections.Map<kotlin.String, kotlin.String>): Observable<Unit> fun testInlineAdditionalProperties(@Body requestBody: kotlin.collections.Map<kotlin.String, kotlin.String>): Observable<Unit>
/**
* test json serialization of form data
*
* Responses:
* - 200: successful operation
*
* @param param field1
* @param param2 field2
* @return [Call]<[Unit]>
*/
@FormUrlEncoded @FormUrlEncoded
@GET("/fake/jsonFormData") @GET("fake/jsonFormData")
fun testJsonFormData(@Field("param") param: kotlin.String, @Field("param2") param2: kotlin.String): Observable<Unit> fun testJsonFormData(@Field("param") param: kotlin.String, @Field("param2") param2: kotlin.String): Observable<Unit>
@PUT("/fake/test-query-paramters") /**
fun testQueryParameterCollectionFormat(@Query("pipe") pipe: kotlin.Array<kotlin.String>, @Query("ioutil") ioutil: CSVParams, @Query("http") http: SPACEParams, @Query("url") url: CSVParams, @Query("context") context: kotlin.Array<kotlin.String>): Observable<Unit> *
* To test the collection format in query parameters
* Responses:
* - 200: Success
*
* @param pipe
* @param ioutil
* @param http
* @param url
* @param context
* @return [Call]<[Unit]>
*/
@PUT("fake/test-query-paramters")
fun testQueryParameterCollectionFormat(@Query("pipe") pipe: kotlin.Array<kotlin.String>, @Query("ioutil") ioutil: CSVParams, @Query("http") http: SSVParams, @Query("url") url: CSVParams, @Query("context") context: kotlin.Array<kotlin.String>): Observable<Unit>
} }

View File

@@ -3,14 +3,21 @@ package org.openapitools.client.apis
import org.openapitools.client.infrastructure.CollectionFormats.* import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import rx.Observable import rx.Observable
import org.openapitools.client.models.Client import org.openapitools.client.models.Client
interface FakeClassnameTags123Api { interface FakeClassnameTags123Api {
@PATCH("/fake_classname_test") /**
* To test class name in snake case
* To test class name in snake case
* Responses:
* - 200: successful operation
*
* @param client client model
* @return [Call]<[Client]>
*/
@PATCH("fake_classname_test")
fun testClassname(@Body client: Client): Observable<Client> fun testClassname(@Body client: Client): Observable<Client>
} }

View File

@@ -3,43 +3,135 @@ package org.openapitools.client.apis
import org.openapitools.client.infrastructure.CollectionFormats.* import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import rx.Observable import rx.Observable
import org.openapitools.client.models.ApiResponse import org.openapitools.client.models.ApiResponse
import org.openapitools.client.models.Pet import org.openapitools.client.models.Pet
interface PetApi { interface PetApi {
@POST("/pet") /**
* Add a new pet to the store
*
* Responses:
* - 405: Invalid input
*
* @param pet Pet object that needs to be added to the store
* @return [Call]<[Unit]>
*/
@POST("pet")
fun addPet(@Body pet: Pet): Observable<Unit> fun addPet(@Body pet: Pet): Observable<Unit>
@DELETE("/pet/{petId}") /**
* Deletes a pet
*
* Responses:
* - 400: Invalid pet value
*
* @param petId Pet id to delete
* @param apiKey (optional)
* @return [Call]<[Unit]>
*/
@DELETE("pet/{petId}")
fun deletePet(@Path("petId") petId: kotlin.Long, @Header("api_key") apiKey: kotlin.String): Observable<Unit> fun deletePet(@Path("petId") petId: kotlin.Long, @Header("api_key") apiKey: kotlin.String): Observable<Unit>
@GET("/pet/findByStatus") /**
* Finds Pets by status
* Multiple status values can be provided with comma separated strings
* Responses:
* - 200: successful operation
* - 400: Invalid status value
*
* @param status Status values that need to be considered for filter
* @return [Call]<[kotlin.Array<Pet>]>
*/
@GET("pet/findByStatus")
fun findPetsByStatus(@Query("status") status: CSVParams): Observable<kotlin.Array<Pet>> fun findPetsByStatus(@Query("status") status: CSVParams): Observable<kotlin.Array<Pet>>
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* Responses:
* - 200: successful operation
* - 400: Invalid tag value
*
* @param tags Tags to filter by
* @return [Call]<[kotlin.Array<Pet>]>
*/
@Deprecated("This api was deprecated") @Deprecated("This api was deprecated")
@GET("/pet/findByTags") @GET("pet/findByTags")
fun findPetsByTags(@Query("tags") tags: CSVParams): Observable<kotlin.Array<Pet>> fun findPetsByTags(@Query("tags") tags: CSVParams): Observable<kotlin.Array<Pet>>
@GET("/pet/{petId}") /**
* Find pet by ID
* Returns a single pet
* Responses:
* - 200: successful operation
* - 400: Invalid ID supplied
* - 404: Pet not found
*
* @param petId ID of pet to return
* @return [Call]<[Pet]>
*/
@GET("pet/{petId}")
fun getPetById(@Path("petId") petId: kotlin.Long): Observable<Pet> fun getPetById(@Path("petId") petId: kotlin.Long): Observable<Pet>
@PUT("/pet") /**
* Update an existing pet
*
* Responses:
* - 400: Invalid ID supplied
* - 404: Pet not found
* - 405: Validation exception
*
* @param pet Pet object that needs to be added to the store
* @return [Call]<[Unit]>
*/
@PUT("pet")
fun updatePet(@Body pet: Pet): Observable<Unit> fun updatePet(@Body pet: Pet): Observable<Unit>
/**
* Updates a pet in the store with form data
*
* Responses:
* - 405: Invalid input
*
* @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 [Call]<[Unit]>
*/
@FormUrlEncoded @FormUrlEncoded
@POST("/pet/{petId}") @POST("pet/{petId}")
fun updatePetWithForm(@Path("petId") petId: kotlin.Long, @Field("name") name: kotlin.String, @Field("status") status: kotlin.String): Observable<Unit> fun updatePetWithForm(@Path("petId") petId: kotlin.Long, @Field("name") name: kotlin.String, @Field("status") status: kotlin.String): Observable<Unit>
/**
* uploads an image
*
* Responses:
* - 200: successful operation
*
* @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server (optional)
* @param file file to upload (optional)
* @return [Call]<[ApiResponse]>
*/
@Multipart @Multipart
@POST("/pet/{petId}/uploadImage") @POST("pet/{petId}/uploadImage")
fun uploadFile(@Path("petId") petId: kotlin.Long, @Part("additionalMetadata") additionalMetadata: kotlin.String, @Part file: MultipartBody.Part): Observable<ApiResponse> fun uploadFile(@Path("petId") petId: kotlin.Long, @Part("additionalMetadata") additionalMetadata: kotlin.String, @Part file: MultipartBody.Part): Observable<ApiResponse>
/**
* uploads an image (required)
*
* Responses:
* - 200: successful operation
*
* @param petId ID of pet to update
* @param requiredFile file to upload
* @param additionalMetadata Additional data to pass to server (optional)
* @return [Call]<[ApiResponse]>
*/
@Multipart @Multipart
@POST("/fake/{petId}/uploadImageWithRequiredFile") @POST("fake/{petId}/uploadImageWithRequiredFile")
fun uploadFileWithRequiredFile(@Path("petId") petId: kotlin.Long, @Part requiredFile: MultipartBody.Part, @Part("additionalMetadata") additionalMetadata: kotlin.String): Observable<ApiResponse> fun uploadFileWithRequiredFile(@Path("petId") petId: kotlin.Long, @Part requiredFile: MultipartBody.Part, @Part("additionalMetadata") additionalMetadata: kotlin.String): Observable<ApiResponse>
} }

View File

@@ -3,23 +3,60 @@ package org.openapitools.client.apis
import org.openapitools.client.infrastructure.CollectionFormats.* import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import rx.Observable import rx.Observable
import org.openapitools.client.models.Order import org.openapitools.client.models.Order
interface StoreApi { interface StoreApi {
@DELETE("/store/order/{order_id}") /**
* Delete purchase order by ID
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
* Responses:
* - 400: Invalid ID supplied
* - 404: Order not found
*
* @param orderId ID of the order that needs to be deleted
* @return [Call]<[Unit]>
*/
@DELETE("store/order/{order_id}")
fun deleteOrder(@Path("order_id") orderId: kotlin.String): Observable<Unit> fun deleteOrder(@Path("order_id") orderId: kotlin.String): Observable<Unit>
@GET("/store/inventory") /**
* Returns pet inventories by status
* Returns a map of status codes to quantities
* Responses:
* - 200: successful operation
*
* @return [Call]<[kotlin.collections.Map<kotlin.String, kotlin.Int>]>
*/
@GET("store/inventory")
fun getInventory(): Observable<kotlin.collections.Map<kotlin.String, kotlin.Int>> fun getInventory(): Observable<kotlin.collections.Map<kotlin.String, kotlin.Int>>
@GET("/store/order/{order_id}") /**
* Find purchase order by ID
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* Responses:
* - 200: successful operation
* - 400: Invalid ID supplied
* - 404: Order not found
*
* @param orderId ID of pet that needs to be fetched
* @return [Call]<[Order]>
*/
@GET("store/order/{order_id}")
fun getOrderById(@Path("order_id") orderId: kotlin.Long): Observable<Order> fun getOrderById(@Path("order_id") orderId: kotlin.Long): Observable<Order>
@POST("/store/order") /**
* Place an order for a pet
*
* Responses:
* - 200: successful operation
* - 400: Invalid Order
*
* @param order order placed for purchasing the pet
* @return [Call]<[Order]>
*/
@POST("store/order")
fun placeOrder(@Body order: Order): Observable<Order> fun placeOrder(@Body order: Order): Observable<Order>
} }

View File

@@ -3,35 +3,111 @@ package org.openapitools.client.apis
import org.openapitools.client.infrastructure.CollectionFormats.* import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.* import retrofit2.http.*
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
import rx.Observable import rx.Observable
import org.openapitools.client.models.User import org.openapitools.client.models.User
interface UserApi { interface UserApi {
@POST("/user") /**
* Create user
* This can only be done by the logged in user.
* Responses:
* - 0: successful operation
*
* @param user Created user object
* @return [Call]<[Unit]>
*/
@POST("user")
fun createUser(@Body user: User): Observable<Unit> fun createUser(@Body user: User): Observable<Unit>
@POST("/user/createWithArray") /**
* Creates list of users with given input array
*
* Responses:
* - 0: successful operation
*
* @param user List of user object
* @return [Call]<[Unit]>
*/
@POST("user/createWithArray")
fun createUsersWithArrayInput(@Body user: kotlin.Array<User>): Observable<Unit> fun createUsersWithArrayInput(@Body user: kotlin.Array<User>): Observable<Unit>
@POST("/user/createWithList") /**
* Creates list of users with given input array
*
* Responses:
* - 0: successful operation
*
* @param user List of user object
* @return [Call]<[Unit]>
*/
@POST("user/createWithList")
fun createUsersWithListInput(@Body user: kotlin.Array<User>): Observable<Unit> fun createUsersWithListInput(@Body user: kotlin.Array<User>): Observable<Unit>
@DELETE("/user/{username}") /**
* Delete user
* This can only be done by the logged in user.
* Responses:
* - 400: Invalid username supplied
* - 404: User not found
*
* @param username The name that needs to be deleted
* @return [Call]<[Unit]>
*/
@DELETE("user/{username}")
fun deleteUser(@Path("username") username: kotlin.String): Observable<Unit> fun deleteUser(@Path("username") username: kotlin.String): Observable<Unit>
@GET("/user/{username}") /**
* Get user by user name
*
* Responses:
* - 200: successful operation
* - 400: Invalid username supplied
* - 404: User not found
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @return [Call]<[User]>
*/
@GET("user/{username}")
fun getUserByName(@Path("username") username: kotlin.String): Observable<User> fun getUserByName(@Path("username") username: kotlin.String): Observable<User>
@GET("/user/login") /**
* Logs user into the system
*
* Responses:
* - 200: successful operation
* - 400: Invalid username/password supplied
*
* @param username The user name for login
* @param password The password for login in clear text
* @return [Call]<[kotlin.String]>
*/
@GET("user/login")
fun loginUser(@Query("username") username: kotlin.String, @Query("password") password: kotlin.String): Observable<kotlin.String> fun loginUser(@Query("username") username: kotlin.String, @Query("password") password: kotlin.String): Observable<kotlin.String>
@GET("/user/logout") /**
* Logs out current logged in user session
*
* Responses:
* - 0: successful operation
*
* @return [Call]<[Unit]>
*/
@GET("user/logout")
fun logoutUser(): Observable<Unit> fun logoutUser(): Observable<Unit>
@PUT("/user/{username}") /**
* Updated user
* This can only be done by the logged in user.
* Responses:
* - 400: Invalid user supplied
* - 404: User not found
*
* @param username name that need to be deleted
* @param user Updated user object
* @return [Call]<[Unit]>
*/
@PUT("user/{username}")
fun updateUser(@Path("username") username: kotlin.String, @Body user: User): Observable<Unit> fun updateUser(@Path("username") username: kotlin.String, @Body user: User): Observable<Unit>
} }

View File

@@ -0,0 +1,50 @@
package org.openapitools.client.auth
import java.io.IOException
import java.net.URI
import java.net.URISyntaxException
import okhttp3.Interceptor
import okhttp3.Response
class ApiKeyAuth(
private val location: String = "",
private val paramName: String = "",
private var apiKey: String = ""
) : Interceptor {
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {
var request = chain.request()
if ("query" == location) {
var newQuery = request.url.toUri().query
val paramValue = "$paramName=$apiKey"
if (newQuery == null) {
newQuery = paramValue
} else {
newQuery += "&$paramValue"
}
val newUri: URI
try {
val oldUri = request.url.toUri()
newUri = URI(oldUri.scheme, oldUri.authority,
oldUri.path, newQuery, oldUri.fragment)
} catch (e: URISyntaxException) {
throw IOException(e)
}
request = request.newBuilder().url(newUri.toURL()).build()
} else if ("header" == location) {
request = request.newBuilder()
.addHeader(paramName, apiKey)
.build()
} else if ("cookie" == location) {
request = request.newBuilder()
.addHeader("Cookie", "$paramName=$apiKey")
.build()
}
return chain.proceed(request)
}
}

View File

@@ -0,0 +1,33 @@
package org.openapitools.client.auth
import java.io.IOException
import kotlin.jvm.Throws
import okhttp3.Interceptor
import okhttp3.Interceptor.Chain
import okhttp3.Response
import okhttp3.Credentials
class HttpBasicAuth(
private var username: String = "",
private var password: String = ""
) : Interceptor {
fun setCredentials(username: String, password: String) {
this.username = username
this.password = password
}
@Throws(IOException::class)
override fun intercept(chain: Chain): Response {
var request = chain.request()
// If the request already have an authorization (eg. Basic auth), do nothing
if (request.header("Authorization") == null && username.isNotBlank() && password.isNotBlank()) {
request = request.newBuilder()
.addHeader("Authorization", Credentials.basic(username, password))
.build()
}
return chain.proceed(request)
}
}

View File

@@ -0,0 +1,39 @@
package org.openapitools.client.auth
import java.io.IOException
import okhttp3.Interceptor
import okhttp3.Interceptor.Chain
import okhttp3.Response
class HttpBearerAuth(
private var schema: String = "",
var bearerToken: String = ""
) : Interceptor {
@Throws(IOException::class)
override fun intercept(chain: Chain): Response {
var request = chain.request()
// If the request already have an authorization (eg. Basic auth), do nothing
if (request.header("Authorization") == null && bearerToken.isNotBlank()) {
request = request.newBuilder()
.addHeader("Authorization", headerValue())
.build()
}
return chain.proceed(request)
}
private fun headerValue(): String {
return if (schema.isNotBlank()) {
"${upperCaseBearer()} $bearerToken"
} else {
bearerToken
}
}
private fun upperCaseBearer(): String {
return if (schema.toLowerCase().equals("bearer")) "Bearer" else schema
}
}

View File

@@ -0,0 +1,151 @@
package org.openapitools.client.auth
import java.net.HttpURLConnection.HTTP_UNAUTHORIZED
import java.net.HttpURLConnection.HTTP_FORBIDDEN
import java.io.IOException
import org.apache.oltu.oauth2.client.OAuthClient
import org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest
import org.apache.oltu.oauth2.client.request.OAuthClientRequest
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder
import org.apache.oltu.oauth2.common.exception.OAuthProblemException
import org.apache.oltu.oauth2.common.exception.OAuthSystemException
import org.apache.oltu.oauth2.common.message.types.GrantType
import org.apache.oltu.oauth2.common.token.BasicOAuthToken
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.Response
class OAuth(
client: OkHttpClient,
var tokenRequestBuilder: TokenRequestBuilder
) : Interceptor {
interface AccessTokenListener {
fun notify(token: BasicOAuthToken)
}
private var oauthClient: OAuthClient = OAuthClient(OAuthOkHttpClient(client))
@Volatile
private var accessToken: String? = null
var authenticationRequestBuilder: AuthenticationRequestBuilder? = null
private var accessTokenListener: AccessTokenListener? = null
constructor(
requestBuilder: TokenRequestBuilder
) : this(
OkHttpClient(),
requestBuilder
)
constructor(
flow: OAuthFlow,
authorizationUrl: String,
tokenUrl: String,
scopes: String
) : this(
OAuthClientRequest.tokenLocation(tokenUrl).setScope(scopes)
) {
setFlow(flow);
authenticationRequestBuilder = OAuthClientRequest.authorizationLocation(authorizationUrl);
}
fun setFlow(flow: OAuthFlow) {
when (flow) {
OAuthFlow.accessCode, OAuthFlow.implicit ->
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE)
OAuthFlow.password ->
tokenRequestBuilder.setGrantType(GrantType.PASSWORD)
OAuthFlow.application ->
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS)
}
}
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {
return retryingIntercept(chain, true)
}
@Throws(IOException::class)
private fun retryingIntercept(chain: Interceptor.Chain, updateTokenAndRetryOnAuthorizationFailure: Boolean): Response {
var request = chain.request()
// If the request already have an authorization (eg. Basic auth), do nothing
if (request.header("Authorization") != null) {
return chain.proceed(request)
}
// If first time, get the token
val oAuthRequest: OAuthClientRequest
if (accessToken == null) {
updateAccessToken(null)
}
if (accessToken != null) {
// Build the request
val rb = request.newBuilder()
val requestAccessToken = accessToken
try {
oAuthRequest = OAuthBearerClientRequest(request.url.toString())
.setAccessToken(requestAccessToken)
.buildHeaderMessage()
} catch (e: OAuthSystemException) {
throw IOException(e)
}
oAuthRequest.headers.entries.forEach { header ->
rb.addHeader(header.key, header.value)
}
rb.url(oAuthRequest.locationUri)
//Execute the request
val response = chain.proceed(rb.build())
// 401/403 most likely indicates that access token has expired. Unless it happens two times in a row.
if ((response.code == HTTP_UNAUTHORIZED || response.code == HTTP_FORBIDDEN) && updateTokenAndRetryOnAuthorizationFailure) {
try {
if (updateAccessToken(requestAccessToken)) {
response.body?.close()
return retryingIntercept(chain, false)
}
} catch (e: Exception) {
response.body?.close()
throw e
}
}
return response
} else {
return chain.proceed(chain.request())
}
}
/**
* Returns true if the access token has been updated
*/
@Throws(IOException::class)
@Synchronized
fun updateAccessToken(requestAccessToken: String?): Boolean {
if (accessToken == null || accessToken.equals(requestAccessToken)) {
return try {
val accessTokenResponse = oauthClient.accessToken(this.tokenRequestBuilder.buildBodyMessage())
if (accessTokenResponse != null && accessTokenResponse.accessToken != null) {
accessToken = accessTokenResponse.accessToken
accessTokenListener?.notify(accessTokenResponse.oAuthToken as BasicOAuthToken)
!accessToken.equals(requestAccessToken)
} else {
false
}
} catch (e: OAuthSystemException) {
throw IOException(e)
} catch (e: OAuthProblemException) {
throw IOException(e)
}
}
return true;
}
}

View File

@@ -0,0 +1,5 @@
package org.openapitools.client.auth
enum class OAuthFlow {
accessCode, implicit, password, application
}

View File

@@ -0,0 +1,61 @@
package org.openapitools.client.auth
import java.io.IOException
import org.apache.oltu.oauth2.client.HttpClient
import org.apache.oltu.oauth2.client.request.OAuthClientRequest
import org.apache.oltu.oauth2.client.response.OAuthClientResponse
import org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory
import org.apache.oltu.oauth2.common.exception.OAuthProblemException
import org.apache.oltu.oauth2.common.exception.OAuthSystemException
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
class OAuthOkHttpClient(
private var client: OkHttpClient
) : HttpClient {
constructor() : this(OkHttpClient())
@Throws(OAuthSystemException::class, OAuthProblemException::class)
override fun <T : OAuthClientResponse?> execute(
request: OAuthClientRequest,
headers: Map<String, String>?,
requestMethod: String,
responseClass: Class<T>?): T {
var mediaType = "application/json".toMediaTypeOrNull()
val requestBuilder = Request.Builder().url(request.locationUri)
headers?.forEach { entry ->
if (entry.key.equals("Content-Type", true)) {
mediaType = entry.value.toMediaTypeOrNull()
} else {
requestBuilder.addHeader(entry.key, entry.value)
}
}
val body: RequestBody? = if (request.body != null) RequestBody.create(mediaType, request.body) else null
requestBuilder.method(requestMethod, body)
try {
val response = client.newCall(requestBuilder.build()).execute()
return OAuthClientResponseFactory.createCustomResponse(
response.body?.string(),
response.body?.contentType()?.toString(),
response.code,
responseClass)
} catch (e: IOException) {
throw OAuthSystemException(e)
}
}
override fun shutdown() {
// Nothing to do here
}
}

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