forked from loafle/openapi-generator-original
[kotlin] add option for non public api (#4089)
* [kotlin] add option for non public api * [kotlin] update petstores * [kotlin] add missing script to kotlin-client-all.sh * [kotlin] update pet projects * [kotlin] remove public modifier * [kotlin-client] inline visibility modifier
This commit is contained in:
parent
60a3746bb7
commit
3cd74f4a8d
@ -1,5 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
./bin/kotlin-client-nonpublic.sh
|
||||||
./bin/kotlin-client-okhttp3.sh
|
./bin/kotlin-client-okhttp3.sh
|
||||||
./bin/kotlin-client-petstore-multiplatform.sh
|
./bin/kotlin-client-petstore-multiplatform.sh
|
||||||
./bin/kotlin-client-petstore.sh
|
./bin/kotlin-client-petstore.sh
|
||||||
|
34
bin/kotlin-client-nonpublic.sh
Executable file
34
bin/kotlin-client-nonpublic.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
echo "# START SCRIPT: $SCRIPT"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=$(ls -ld "$SCRIPT")
|
||||||
|
link=$(expr "$ls" : '.*-> \(.*\)$')
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=$(dirname "$SCRIPT")/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=$(dirname "$SCRIPT")/..
|
||||||
|
APP_DIR=$(cd "${APP_DIR}"; pwd)
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn -B clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-petstore-nonpublic --additional-properties nonPublicApi=true -o samples/client/petstore/kotlin-nonpublic $@"
|
||||||
|
|
||||||
|
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
||||||
|
|
||||||
|
cp CI/samples.ci/client/petstore/kotlin-string/pom.xml samples/client/petstore/kotlin-string/pom.xml
|
@ -60,6 +60,8 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
|||||||
protected boolean serializableModel = false;
|
protected boolean serializableModel = false;
|
||||||
protected boolean needsDataClassBody = false;
|
protected boolean needsDataClassBody = false;
|
||||||
|
|
||||||
|
protected boolean nonPublicApi = false;
|
||||||
|
|
||||||
protected CodegenConstants.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.camelCase;
|
protected CodegenConstants.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.camelCase;
|
||||||
protected SERIALIZATION_LIBRARY_TYPE serializationLibrary = SERIALIZATION_LIBRARY_TYPE.moshi;
|
protected SERIALIZATION_LIBRARY_TYPE serializationLibrary = SERIALIZATION_LIBRARY_TYPE.moshi;
|
||||||
|
|
||||||
@ -442,6 +444,12 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
|||||||
additionalProperties.put(CodegenConstants.PARCELIZE_MODELS, parcelizeModels);
|
additionalProperties.put(CodegenConstants.PARCELIZE_MODELS, parcelizeModels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(CodegenConstants.NON_PUBLIC_API)) {
|
||||||
|
this.setNonPublicApi(Boolean.valueOf((String) additionalProperties.get(CodegenConstants.NON_PUBLIC_API)));
|
||||||
|
} else {
|
||||||
|
additionalProperties.put(CodegenConstants.NON_PUBLIC_API, nonPublicApi);
|
||||||
|
}
|
||||||
|
|
||||||
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage());
|
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage());
|
||||||
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage());
|
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage());
|
||||||
|
|
||||||
@ -493,6 +501,14 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
|||||||
this.serializableModel = serializableModel;
|
this.serializableModel = serializableModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean nonPublicApi() {
|
||||||
|
return nonPublicApi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNonPublicApi(boolean nonPublicApi) {
|
||||||
|
this.nonPublicApi = nonPublicApi;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isNeedsDataClassBody() {
|
public boolean isNeedsDataClassBody() {
|
||||||
return needsDataClassBody;
|
return needsDataClassBody;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import {{packageName}}.infrastructure.Success
|
|||||||
import {{packageName}}.infrastructure.toMultiValue
|
import {{packageName}}.infrastructure.toMultiValue
|
||||||
|
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
class {{classname}}(basePath: kotlin.String = "{{{basePath}}}") : ApiClient(basePath) {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}class {{classname}}(basePath: kotlin.String = "{{{basePath}}}") : ApiClient(basePath) {
|
||||||
|
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +28,7 @@ import java.io.Serializable
|
|||||||
@Parcelize
|
@Parcelize
|
||||||
{{/parcelizeModels}}
|
{{/parcelizeModels}}
|
||||||
{{#multiplatform}}@Serializable{{/multiplatform}}
|
{{#multiplatform}}@Serializable{{/multiplatform}}
|
||||||
data class {{classname}} (
|
{{#nonPublicApi}}internal {{/nonPublicApi}}data class {{classname}} (
|
||||||
{{#requiredVars}}
|
{{#requiredVars}}
|
||||||
{{>data_class_req_var}}{{^-last}},
|
{{>data_class_req_var}}{{^-last}},
|
||||||
{{/-last}}{{/requiredVars}}{{#hasRequired}}{{#hasOptional}},
|
{{/-last}}{{/requiredVars}}{{#hasRequired}}{{#hasOptional}},
|
||||||
@ -41,7 +41,7 @@ data class {{classname}} (
|
|||||||
{
|
{
|
||||||
{{/vendorExtensions.x-has-data-class-body}}
|
{{/vendorExtensions.x-has-data-class-body}}
|
||||||
{{#serializableModel}}
|
{{#serializableModel}}
|
||||||
companion object {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
|
||||||
private const val serialVersionUID: Long = 123
|
private const val serialVersionUID: Long = 123
|
||||||
}
|
}
|
||||||
{{/serializableModel}}
|
{{/serializableModel}}
|
||||||
@ -53,7 +53,7 @@ data class {{classname}} (
|
|||||||
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
|
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||||
*/
|
*/
|
||||||
{{#multiplatform}}@Serializable(with = {{nameInCamelCase}}.Serializer::class){{/multiplatform}}
|
{{#multiplatform}}@Serializable(with = {{nameInCamelCase}}.Serializer::class){{/multiplatform}}
|
||||||
enum class {{{nameInCamelCase}}}(val value: {{#isListContainer}}{{{ nestedType }}}{{/isListContainer}}{{^isListContainer}}{{{dataType}}}{{/isListContainer}}){
|
{{#nonPublicApi}}internal {{/nonPublicApi}}enum class {{{nameInCamelCase}}}(val value: {{#isListContainer}}{{{ nestedType }}}{{/isListContainer}}{{^isListContainer}}{{{dataType}}}{{/isListContainer}}){
|
||||||
{{#allowableValues}}
|
{{#allowableValues}}
|
||||||
{{#enumVars}}
|
{{#enumVars}}
|
||||||
{{#jvm}}
|
{{#jvm}}
|
||||||
@ -71,7 +71,7 @@ data class {{classname}} (
|
|||||||
{{/allowableValues}}
|
{{/allowableValues}}
|
||||||
{{#multiplatform}}
|
{{#multiplatform}}
|
||||||
|
|
||||||
object Serializer : CommonEnumSerializer<{{nameInCamelCase}}>("{{nameInCamelCase}}", values(), values().map { it.value }.toTypedArray())
|
{{#nonPublicApi}}internal {{/nonPublicApi}}object Serializer : CommonEnumSerializer<{{nameInCamelCase}}>("{{nameInCamelCase}}", values(), values().map { it.value }.toTypedArray())
|
||||||
{{/multiplatform}}
|
{{/multiplatform}}
|
||||||
}
|
}
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
|
@ -16,7 +16,7 @@ import kotlinx.serialization.internal.CommonEnumSerializer
|
|||||||
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
|
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||||
*/
|
*/
|
||||||
{{#multiplatform}}@Serializable(with = {{classname}}.Serializer::class){{/multiplatform}}
|
{{#multiplatform}}@Serializable(with = {{classname}}.Serializer::class){{/multiplatform}}
|
||||||
enum class {{classname}}(val value: {{{dataType}}}){
|
{{#nonPublicApi}}internal {{/nonPublicApi}}enum class {{classname}}(val value: {{{dataType}}}){
|
||||||
|
|
||||||
{{#allowableValues}}{{#enumVars}}
|
{{#allowableValues}}{{#enumVars}}
|
||||||
{{#jvm}}
|
{{#jvm}}
|
||||||
@ -42,6 +42,6 @@ enum class {{classname}}(val value: {{{dataType}}}){
|
|||||||
{{/enumVars}}{{/allowableValues}}
|
{{/enumVars}}{{/allowableValues}}
|
||||||
|
|
||||||
{{#multiplatform}}
|
{{#multiplatform}}
|
||||||
object Serializer : CommonEnumSerializer<{{classname}}>("{{classname}}", values(), values().map { it.value }.toTypedArray())
|
{{#nonPublicApi}}internal {{/nonPublicApi}}object Serializer : CommonEnumSerializer<{{classname}}>("{{classname}}", values(), values().map { it.value }.toTypedArray())
|
||||||
{{/multiplatform}}
|
{{/multiplatform}}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package {{packageName}}.infrastructure
|
|||||||
|
|
||||||
typealias MultiValueMap = Map<String,List<String>>
|
typealias MultiValueMap = Map<String,List<String>>
|
||||||
|
|
||||||
fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
|
||||||
"csv" -> ","
|
"csv" -> ","
|
||||||
"tsv" -> "\t"
|
"tsv" -> "\t"
|
||||||
"pipes" -> "|"
|
"pipes" -> "|"
|
||||||
@ -10,12 +10,12 @@ fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
|
|||||||
else -> ""
|
else -> ""
|
||||||
}
|
}
|
||||||
|
|
||||||
val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
|
{{#nonPublicApi}}internal {{/nonPublicApi}}val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
|
||||||
|
|
||||||
fun <T : Any?> toMultiValue(items: Array<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter)
|
{{#nonPublicApi}}internal {{/nonPublicApi}}fun <T : Any?> toMultiValue(items: Array<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter)
|
||||||
= toMultiValue(items.asIterable(), collectionFormat, map)
|
= toMultiValue(items.asIterable(), collectionFormat, map)
|
||||||
|
|
||||||
fun <T : Any?> toMultiValue(items: Iterable<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List<String> {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}fun <T : Any?> toMultiValue(items: Iterable<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List<String> {
|
||||||
return when(collectionFormat) {
|
return when(collectionFormat) {
|
||||||
"multi" -> items.map(map)
|
"multi" -> items.map(map)
|
||||||
else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map))
|
else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map))
|
||||||
|
@ -8,7 +8,7 @@ package {{packageName}}.infrastructure
|
|||||||
* NOTE: Headers is a Map<String,String> because rfc2616 defines
|
* NOTE: Headers is a Map<String,String> because rfc2616 defines
|
||||||
* multi-valued headers as csv-only.
|
* multi-valued headers as csv-only.
|
||||||
*/
|
*/
|
||||||
data class RequestConfig(
|
{{#nonPublicApi}}internal {{/nonPublicApi}}data class RequestConfig(
|
||||||
val method: RequestMethod,
|
val method: RequestMethod,
|
||||||
val path: String,
|
val path: String,
|
||||||
val headers: MutableMap<String, String> = mutableMapOf(),
|
val headers: MutableMap<String, String> = mutableMapOf(),
|
||||||
|
@ -3,6 +3,6 @@ package {{packageName}}.infrastructure
|
|||||||
/**
|
/**
|
||||||
* Provides enumerated HTTP verbs
|
* Provides enumerated HTTP verbs
|
||||||
*/
|
*/
|
||||||
enum class RequestMethod {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}enum class RequestMethod {
|
||||||
GET, DELETE, HEAD, OPTIONS, PATCH, POST, PUT
|
GET, DELETE, HEAD, OPTIONS, PATCH, POST, PUT
|
||||||
}
|
}
|
@ -23,8 +23,8 @@ import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
|||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String) {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient(val baseUrl: String) {
|
||||||
companion object {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
protected const val Accept = "Accept"
|
protected const val Accept = "Accept"
|
||||||
protected const val Authorization = "Authorization"
|
protected const val Authorization = "Authorization"
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
package {{packageName}}.infrastructure
|
package {{packageName}}.infrastructure
|
||||||
|
|
||||||
enum class ResponseType {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}enum class ResponseType {
|
||||||
Success, Informational, Redirection, ClientError, ServerError
|
Success, Informational, Redirection, ClientError, ServerError
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ApiInfrastructureResponse<T>(val responseType: ResponseType) {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}abstract class ApiInfrastructureResponse<T>(val responseType: ResponseType) {
|
||||||
abstract val statusCode: Int
|
abstract val statusCode: Int
|
||||||
abstract val headers: Map<String,List<String>>
|
abstract val headers: Map<String,List<String>>
|
||||||
}
|
}
|
||||||
|
|
||||||
class Success<T>(
|
{{#nonPublicApi}}internal {{/nonPublicApi}}class Success<T>(
|
||||||
val data: T,
|
val data: T,
|
||||||
override val statusCode: Int = -1,
|
override val statusCode: Int = -1,
|
||||||
override val headers: Map<String, List<String>> = mapOf()
|
override val headers: Map<String, List<String>> = mapOf()
|
||||||
): ApiInfrastructureResponse<T>(ResponseType.Success)
|
): ApiInfrastructureResponse<T>(ResponseType.Success)
|
||||||
|
|
||||||
class Informational<T>(
|
{{#nonPublicApi}}internal {{/nonPublicApi}}class Informational<T>(
|
||||||
val statusText: String,
|
val statusText: String,
|
||||||
override val statusCode: Int = -1,
|
override val statusCode: Int = -1,
|
||||||
override val headers: Map<String, List<String>> = mapOf()
|
override val headers: Map<String, List<String>> = mapOf()
|
||||||
) : ApiInfrastructureResponse<T>(ResponseType.Informational)
|
) : ApiInfrastructureResponse<T>(ResponseType.Informational)
|
||||||
|
|
||||||
class Redirection<T>(
|
{{#nonPublicApi}}internal {{/nonPublicApi}}class Redirection<T>(
|
||||||
override val statusCode: Int = -1,
|
override val statusCode: Int = -1,
|
||||||
override val headers: Map<String, List<String>> = mapOf()
|
override val headers: Map<String, List<String>> = mapOf()
|
||||||
) : ApiInfrastructureResponse<T>(ResponseType.Redirection)
|
) : ApiInfrastructureResponse<T>(ResponseType.Redirection)
|
||||||
|
|
||||||
class ClientError<T>(
|
{{#nonPublicApi}}internal {{/nonPublicApi}}class ClientError<T>(
|
||||||
val body: Any? = null,
|
val body: Any? = null,
|
||||||
override val statusCode: Int = -1,
|
override val statusCode: Int = -1,
|
||||||
override val headers: Map<String, List<String>> = mapOf()
|
override val headers: Map<String, List<String>> = mapOf()
|
||||||
) : ApiInfrastructureResponse<T>(ResponseType.ClientError)
|
) : ApiInfrastructureResponse<T>(ResponseType.ClientError)
|
||||||
|
|
||||||
class ServerError<T>(
|
{{#nonPublicApi}}internal {{/nonPublicApi}}class ServerError<T>(
|
||||||
val message: String? = null,
|
val message: String? = null,
|
||||||
val body: Any? = null,
|
val body: Any? = null,
|
||||||
override val statusCode: Int = -1,
|
override val statusCode: Int = -1,
|
||||||
|
@ -3,7 +3,7 @@ package {{packageName}}.infrastructure
|
|||||||
import kotlin.properties.ReadWriteProperty
|
import kotlin.properties.ReadWriteProperty
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
object ApplicationDelegates {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}object ApplicationDelegates {
|
||||||
/**
|
/**
|
||||||
* Provides a property delegate, allowing the property to be set once and only once.
|
* Provides a property delegate, allowing the property to be set once and only once.
|
||||||
*
|
*
|
||||||
|
@ -3,7 +3,7 @@ package {{packageName}}.infrastructure
|
|||||||
import com.squareup.moshi.FromJson
|
import com.squareup.moshi.FromJson
|
||||||
import com.squareup.moshi.ToJson
|
import com.squareup.moshi.ToJson
|
||||||
|
|
||||||
class ByteArrayAdapter {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}class ByteArrayAdapter {
|
||||||
@ToJson
|
@ToJson
|
||||||
fun toJson(data: ByteArray): String = String(data)
|
fun toJson(data: ByteArray): String = String(data)
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package {{packageName}}.infrastructure
|
|||||||
|
|
||||||
import java.lang.RuntimeException
|
import java.lang.RuntimeException
|
||||||
|
|
||||||
open class ClientException : RuntimeException {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ClientException : RuntimeException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an [ClientException] with no detail message.
|
* Constructs an [ClientException] with no detail message.
|
||||||
@ -17,12 +17,12 @@ open class ClientException : RuntimeException {
|
|||||||
*/
|
*/
|
||||||
constructor(message: kotlin.String) : super(message)
|
constructor(message: kotlin.String) : super(message)
|
||||||
|
|
||||||
companion object {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
|
||||||
private const val serialVersionUID: Long = 123L
|
private const val serialVersionUID: Long = 123L
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open class ServerException : RuntimeException {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ServerException : RuntimeException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an [ServerException] with no detail message.
|
* Constructs an [ServerException] with no detail message.
|
||||||
@ -36,7 +36,7 @@ open class ServerException : RuntimeException {
|
|||||||
*/
|
*/
|
||||||
constructor(message: kotlin.String) : super(message)
|
constructor(message: kotlin.String) : super(message)
|
||||||
|
|
||||||
companion object {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
|
||||||
private const val serialVersionUID: Long = 456L
|
private const val serialVersionUID: Long = 456L
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,7 +11,7 @@ import org.threeten.bp.LocalDate
|
|||||||
import org.threeten.bp.format.DateTimeFormatter
|
import org.threeten.bp.format.DateTimeFormatter
|
||||||
{{/threetenbp}}
|
{{/threetenbp}}
|
||||||
|
|
||||||
class LocalDateAdapter {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}class LocalDateAdapter {
|
||||||
@ToJson
|
@ToJson
|
||||||
fun toJson(value: LocalDate): String {
|
fun toJson(value: LocalDate): String {
|
||||||
return DateTimeFormatter.ISO_LOCAL_DATE.format(value)
|
return DateTimeFormatter.ISO_LOCAL_DATE.format(value)
|
||||||
|
@ -11,7 +11,7 @@ import org.threeten.bp.LocalDateTime
|
|||||||
import org.threeten.bp.format.DateTimeFormatter
|
import org.threeten.bp.format.DateTimeFormatter
|
||||||
{{/threetenbp}}
|
{{/threetenbp}}
|
||||||
|
|
||||||
class LocalDateTimeAdapter {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}class LocalDateTimeAdapter {
|
||||||
@ToJson
|
@ToJson
|
||||||
fun toJson(value: LocalDateTime): String {
|
fun toJson(value: LocalDateTime): String {
|
||||||
return DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(value)
|
return DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(value)
|
||||||
|
@ -5,19 +5,19 @@ import okhttp3.Response
|
|||||||
/**
|
/**
|
||||||
* Provides an extension to evaluation whether the response is a 1xx code
|
* Provides an extension to evaluation whether the response is a 1xx code
|
||||||
*/
|
*/
|
||||||
val Response.isInformational : Boolean get() = this.code{{#jvm-okhttp3}}(){{/jvm-okhttp3}} in 100..199
|
{{#nonPublicApi}}internal {{/nonPublicApi}}val Response.isInformational : Boolean get() = this.code{{#jvm-okhttp3}}(){{/jvm-okhttp3}} in 100..199
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an extension to evaluation whether the response is a 3xx code
|
* Provides an extension to evaluation whether the response is a 3xx code
|
||||||
*/
|
*/
|
||||||
val Response.isRedirect : Boolean get() = this.code{{#jvm-okhttp3}}(){{/jvm-okhttp3}} in 300..399
|
{{#nonPublicApi}}internal {{/nonPublicApi}}val Response.isRedirect : Boolean get() = this.code{{#jvm-okhttp3}}(){{/jvm-okhttp3}} in 300..399
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an extension to evaluation whether the response is a 4xx code
|
* Provides an extension to evaluation whether the response is a 4xx code
|
||||||
*/
|
*/
|
||||||
val Response.isClientError : Boolean get() = this.code{{#jvm-okhttp3}}(){{/jvm-okhttp3}} in 400..499
|
{{#nonPublicApi}}internal {{/nonPublicApi}}val Response.isClientError : Boolean get() = this.code{{#jvm-okhttp3}}(){{/jvm-okhttp3}} in 400..499
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an extension to evaluation whether the response is a 5xx (Standard) through 999 (non-standard) code
|
* Provides an extension to evaluation whether the response is a 5xx (Standard) through 999 (non-standard) code
|
||||||
*/
|
*/
|
||||||
val Response.isServerError : Boolean get() = this.code{{#jvm-okhttp3}}(){{/jvm-okhttp3}} in 500..999
|
{{#nonPublicApi}}internal {{/nonPublicApi}}val Response.isServerError : Boolean get() = this.code{{#jvm-okhttp3}}(){{/jvm-okhttp3}} in 500..999
|
||||||
|
@ -5,7 +5,7 @@ import com.squareup.moshi.adapters.Rfc3339DateJsonAdapter
|
|||||||
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
|
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
object Serializer {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}object Serializer {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
val moshi: Moshi = Moshi.Builder()
|
val moshi: Moshi = Moshi.Builder()
|
||||||
.add(Date::class.java, Rfc3339DateJsonAdapter().nullSafe())
|
.add(Date::class.java, Rfc3339DateJsonAdapter().nullSafe())
|
||||||
|
@ -4,7 +4,7 @@ import com.squareup.moshi.FromJson
|
|||||||
import com.squareup.moshi.ToJson
|
import com.squareup.moshi.ToJson
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
class UUIDAdapter {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}class UUIDAdapter {
|
||||||
@ToJson
|
@ToJson
|
||||||
fun toJson(uuid: UUID) = uuid.toString()
|
fun toJson(uuid: UUID) = uuid.toString()
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import kotlinx.serialization.*
|
|||||||
import kotlinx.serialization.internal.StringDescriptor
|
import kotlinx.serialization.internal.StringDescriptor
|
||||||
|
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
class {{classname}} @UseExperimental(UnstableDefault::class) constructor(
|
{{#nonPublicApi}}internal {{/nonPublicApi}}class {{classname}} @UseExperimental(UnstableDefault::class) constructor(
|
||||||
baseUrl: kotlin.String = "{{{basePath}}}",
|
baseUrl: kotlin.String = "{{{basePath}}}",
|
||||||
httpClientEngine: HttpClientEngine? = null,
|
httpClientEngine: HttpClientEngine? = null,
|
||||||
serializer: KotlinxSerializer)
|
serializer: KotlinxSerializer)
|
||||||
@ -101,7 +101,7 @@ class {{classname}} @UseExperimental(UnstableDefault::class) constructor(
|
|||||||
|
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
|
|
||||||
companion object {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
|
||||||
internal fun setMappers(serializer: KotlinxSerializer) {
|
internal fun setMappers(serializer: KotlinxSerializer) {
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
{{#hasBodyParam}}
|
{{#hasBodyParam}}
|
||||||
|
@ -24,7 +24,7 @@ import kotlinx.serialization.json.JsonConfiguration
|
|||||||
import {{apiPackage}}.*
|
import {{apiPackage}}.*
|
||||||
import {{modelPackage}}.*
|
import {{modelPackage}}.*
|
||||||
|
|
||||||
open class ApiClient(
|
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient(
|
||||||
private val baseUrl: String,
|
private val baseUrl: String,
|
||||||
httpClientEngine: HttpClientEngine?,
|
httpClientEngine: HttpClientEngine?,
|
||||||
serializer: KotlinxSerializer) {
|
serializer: KotlinxSerializer) {
|
||||||
@ -46,7 +46,7 @@ open class ApiClient(
|
|||||||
httpClientEngine?.let { HttpClient(it, clientConfig) } ?: HttpClient(clientConfig)
|
httpClientEngine?.let { HttpClient(it, clientConfig) } ?: HttpClient(clientConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
|
||||||
protected val UNSAFE_HEADERS = listOf(HttpHeaders.ContentType)
|
protected val UNSAFE_HEADERS = listOf(HttpHeaders.ContentType)
|
||||||
|
|
||||||
private fun setMappers(serializer: KotlinxSerializer) {
|
private fun setMappers(serializer: KotlinxSerializer) {
|
||||||
|
@ -5,14 +5,14 @@ import io.ktor.client.call.typeInfo
|
|||||||
import io.ktor.http.Headers
|
import io.ktor.http.Headers
|
||||||
import io.ktor.http.isSuccess
|
import io.ktor.http.isSuccess
|
||||||
|
|
||||||
open class HttpResponse<T : Any>(val response: io.ktor.client.response.HttpResponse, val provider: BodyProvider<T>) {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}open class HttpResponse<T : Any>(val response: io.ktor.client.response.HttpResponse, val provider: BodyProvider<T>) {
|
||||||
val status: Int = response.status.value
|
val status: Int = response.status.value
|
||||||
val success: Boolean = response.status.isSuccess()
|
val success: Boolean = response.status.isSuccess()
|
||||||
val headers: Map<String, List<String>> = response.headers.mapEntries()
|
val headers: Map<String, List<String>> = response.headers.mapEntries()
|
||||||
suspend fun body(): T = provider.body(response)
|
suspend fun body(): T = provider.body(response)
|
||||||
suspend fun <V : Any> typedBody(type: TypeInfo): V = provider.typedBody(response, type)
|
suspend fun <V : Any> typedBody(type: TypeInfo): V = provider.typedBody(response, type)
|
||||||
|
|
||||||
companion object {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
|
||||||
private fun Headers.mapEntries(): Map<String, List<String>> {
|
private fun Headers.mapEntries(): Map<String, List<String>> {
|
||||||
val result = mutableMapOf<String, List<String>>()
|
val result = mutableMapOf<String, List<String>>()
|
||||||
entries().forEach { result[it.key] = it.value }
|
entries().forEach { result[it.key] = it.value }
|
||||||
@ -21,12 +21,12 @@ open class HttpResponse<T : Any>(val response: io.ktor.client.response.HttpRespo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BodyProvider<T : Any> {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}interface BodyProvider<T : Any> {
|
||||||
suspend fun body(response: io.ktor.client.response.HttpResponse): T
|
suspend fun body(response: io.ktor.client.response.HttpResponse): T
|
||||||
suspend fun <V : Any> typedBody(response: io.ktor.client.response.HttpResponse, type: TypeInfo): V
|
suspend fun <V : Any> typedBody(response: io.ktor.client.response.HttpResponse, type: TypeInfo): V
|
||||||
}
|
}
|
||||||
|
|
||||||
class TypedBodyProvider<T : Any>(private val type: TypeInfo) : BodyProvider<T> {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}class TypedBodyProvider<T : Any>(private val type: TypeInfo) : BodyProvider<T> {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
override suspend fun body(response: io.ktor.client.response.HttpResponse): T =
|
override suspend fun body(response: io.ktor.client.response.HttpResponse): T =
|
||||||
response.call.receive(type) as T
|
response.call.receive(type) as T
|
||||||
@ -36,7 +36,7 @@ class TypedBodyProvider<T : Any>(private val type: TypeInfo) : BodyProvider<T> {
|
|||||||
response.call.receive(type) as V
|
response.call.receive(type) as V
|
||||||
}
|
}
|
||||||
|
|
||||||
class MappedBodyProvider<S : Any, T : Any>(private val provider: BodyProvider<S>, private val block: S.() -> T) : BodyProvider<T> {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}class MappedBodyProvider<S : Any, T : Any>(private val provider: BodyProvider<S>, private val block: S.() -> T) : BodyProvider<T> {
|
||||||
override suspend fun body(response: io.ktor.client.response.HttpResponse): T =
|
override suspend fun body(response: io.ktor.client.response.HttpResponse): T =
|
||||||
block(provider.body(response))
|
block(provider.body(response))
|
||||||
|
|
||||||
@ -44,8 +44,8 @@ class MappedBodyProvider<S : Any, T : Any>(private val provider: BodyProvider<S>
|
|||||||
provider.typedBody(response, type)
|
provider.typedBody(response, type)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified T : Any> io.ktor.client.response.HttpResponse.wrap(): HttpResponse<T> =
|
{{#nonPublicApi}}internal {{/nonPublicApi}}inline fun <reified T : Any> io.ktor.client.response.HttpResponse.wrap(): HttpResponse<T> =
|
||||||
HttpResponse(this, TypedBodyProvider(typeInfo<T>()))
|
HttpResponse(this, TypedBodyProvider(typeInfo<T>()))
|
||||||
|
|
||||||
fun <T : Any, V : Any> HttpResponse<T>.map(block: T.() -> V): HttpResponse<V> =
|
{{#nonPublicApi}}internal {{/nonPublicApi}}fun <T : Any, V : Any> HttpResponse<T>.map(block: T.() -> V): HttpResponse<V> =
|
||||||
HttpResponse(response, MappedBodyProvider(provider, block))
|
HttpResponse(response, MappedBodyProvider(provider, block))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@Serializable
|
@Serializable
|
||||||
private class {{operationIdCamelCase}}Request(val value: List<{{#bodyParam}}{{baseType}}{{/bodyParam}}>) {
|
private class {{operationIdCamelCase}}Request(val value: List<{{#bodyParam}}{{baseType}}{{/bodyParam}}>) {
|
||||||
@Serializer({{operationIdCamelCase}}Request::class)
|
@Serializer({{operationIdCamelCase}}Request::class)
|
||||||
companion object : KSerializer<{{operationIdCamelCase}}Request> {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object : KSerializer<{{operationIdCamelCase}}Request> {
|
||||||
private val serializer: KSerializer<List<{{#bodyParam}}{{baseType}}{{/bodyParam}}>> = {{#bodyParam}}{{baseType}}{{/bodyParam}}.serializer().list
|
private val serializer: KSerializer<List<{{#bodyParam}}{{baseType}}{{/bodyParam}}>> = {{#bodyParam}}{{baseType}}{{/bodyParam}}.serializer().list
|
||||||
override val descriptor = StringDescriptor.withName("{{operationIdCamelCase}}Request")
|
override val descriptor = StringDescriptor.withName("{{operationIdCamelCase}}Request")
|
||||||
override fun serialize(encoder: Encoder, obj: {{operationIdCamelCase}}Request) = serializer.serialize(encoder, obj.value)
|
override fun serialize(encoder: Encoder, obj: {{operationIdCamelCase}}Request) = serializer.serialize(encoder, obj.value)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@Serializable
|
@Serializable
|
||||||
private class {{operationIdCamelCase}}Request(val value: Map<kotlin.String, {{#bodyParam}}{{baseType}}{{/bodyParam}}>) {
|
private class {{operationIdCamelCase}}Request(val value: Map<kotlin.String, {{#bodyParam}}{{baseType}}{{/bodyParam}}>) {
|
||||||
@Serializer({{operationIdCamelCase}}Request::class)
|
@Serializer({{operationIdCamelCase}}Request::class)
|
||||||
companion object : KSerializer<{{operationIdCamelCase}}Request> {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object : KSerializer<{{operationIdCamelCase}}Request> {
|
||||||
private val serializer: KSerializer<Map<kotlin.String, {{#bodyParam}}{{baseType}}{{/bodyParam}}>> = (kotlin.String.serializer() to {{#bodyParam}}{{baseType}}{{/bodyParam}}.serializer()).map
|
private val serializer: KSerializer<Map<kotlin.String, {{#bodyParam}}{{baseType}}{{/bodyParam}}>> = (kotlin.String.serializer() to {{#bodyParam}}{{baseType}}{{/bodyParam}}.serializer()).map
|
||||||
override val descriptor = StringDescriptor.withName("{{operationIdCamelCase}}Request")
|
override val descriptor = StringDescriptor.withName("{{operationIdCamelCase}}Request")
|
||||||
override fun serialize(encoder: Encoder, obj: {{operationIdCamelCase}}Request) = serializer.serialize(encoder, obj.value)
|
override fun serialize(encoder: Encoder, obj: {{operationIdCamelCase}}Request) = serializer.serialize(encoder, obj.value)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@Serializable
|
@Serializable
|
||||||
private class {{operationIdCamelCase}}Response(val value: List<{{returnBaseType}}>) {
|
private class {{operationIdCamelCase}}Response(val value: List<{{returnBaseType}}>) {
|
||||||
@Serializer({{operationIdCamelCase}}Response::class)
|
@Serializer({{operationIdCamelCase}}Response::class)
|
||||||
companion object : KSerializer<{{operationIdCamelCase}}Response> {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object : KSerializer<{{operationIdCamelCase}}Response> {
|
||||||
private val serializer: KSerializer<List<{{returnBaseType}}>> = {{returnBaseType}}.serializer().list
|
private val serializer: KSerializer<List<{{returnBaseType}}>> = {{returnBaseType}}.serializer().list
|
||||||
override val descriptor = StringDescriptor.withName("{{operationIdCamelCase}}Response")
|
override val descriptor = StringDescriptor.withName("{{operationIdCamelCase}}Response")
|
||||||
override fun serialize(encoder: Encoder, obj: {{operationIdCamelCase}}Response) = serializer.serialize(encoder, obj.value)
|
override fun serialize(encoder: Encoder, obj: {{operationIdCamelCase}}Response) = serializer.serialize(encoder, obj.value)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@Serializable
|
@Serializable
|
||||||
private class {{operationIdCamelCase}}Response(val value: Map<kotlin.String, {{returnBaseType}}>) {
|
private class {{operationIdCamelCase}}Response(val value: Map<kotlin.String, {{returnBaseType}}>) {
|
||||||
@Serializer({{operationIdCamelCase}}Response::class)
|
@Serializer({{operationIdCamelCase}}Response::class)
|
||||||
companion object : KSerializer<{{operationIdCamelCase}}Response> {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object : KSerializer<{{operationIdCamelCase}}Response> {
|
||||||
private val serializer: KSerializer<Map<kotlin.String, {{returnBaseType}}>> = (kotlin.String.serializer() to {{returnBaseType}}.serializer()).map
|
private val serializer: KSerializer<Map<kotlin.String, {{returnBaseType}}>> = (kotlin.String.serializer() to {{returnBaseType}}.serializer()).map
|
||||||
override val descriptor = StringDescriptor.withName("{{operationIdCamelCase}}Response")
|
override val descriptor = StringDescriptor.withName("{{operationIdCamelCase}}Response")
|
||||||
override fun serialize(encoder: Encoder, obj: {{operationIdCamelCase}}Response) = serializer.serialize(encoder, obj.value)
|
override fun serialize(encoder: Encoder, obj: {{operationIdCamelCase}}Response) = serializer.serialize(encoder, obj.value)
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
# OpenAPI Generator Ignore
|
||||||
|
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||||
|
|
||||||
|
# Use this file to prevent files from being overwritten by the generator.
|
||||||
|
# The patterns follow closely to .gitignore or .dockerignore.
|
||||||
|
|
||||||
|
# As an example, the C# client generator defines ApiClient.cs.
|
||||||
|
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||||
|
#ApiClient.cs
|
||||||
|
|
||||||
|
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||||
|
#foo/*/qux
|
||||||
|
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||||
|
#foo/**/qux
|
||||||
|
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can also negate patterns with an exclamation (!).
|
||||||
|
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||||
|
#docs/*.md
|
||||||
|
# Then explicitly reverse the ignore rule for a single file:
|
||||||
|
#!docs/README.md
|
@ -0,0 +1 @@
|
|||||||
|
4.2.0-SNAPSHOT
|
90
samples/client/petstore/kotlin-nonpublic/README.md
Normal file
90
samples/client/petstore/kotlin-nonpublic/README.md
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
# org.openapitools.client - Kotlin client library for OpenAPI Petstore
|
||||||
|
|
||||||
|
## Requires
|
||||||
|
|
||||||
|
* Kotlin 1.3.41
|
||||||
|
* Gradle 4.9
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
First, create the gradle wrapper script:
|
||||||
|
|
||||||
|
```
|
||||||
|
gradle wrapper
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, run:
|
||||||
|
|
||||||
|
```
|
||||||
|
./gradlew check assemble
|
||||||
|
```
|
||||||
|
|
||||||
|
This runs all tests and packages the library.
|
||||||
|
|
||||||
|
## Features/Implementation Notes
|
||||||
|
|
||||||
|
* Supports JSON inputs/outputs, File inputs, and Form inputs.
|
||||||
|
* Supports collection formats for query parameters: csv, tsv, ssv, pipes.
|
||||||
|
* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in OpenAPI definitions.
|
||||||
|
* Implementation of ApiClient is intended to reduce method counts, specifically to benefit Android targets.
|
||||||
|
|
||||||
|
<a name="documentation-for-api-endpoints"></a>
|
||||||
|
## Documentation for API Endpoints
|
||||||
|
|
||||||
|
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||||
|
|
||||||
|
Class | Method | HTTP request | Description
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
*PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
|
||||||
|
*PetApi* | [**deletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||||
|
*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
|
||||||
|
*PetApi* | [**findPetsByTags**](docs/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||||
|
*PetApi* | [**getPetById**](docs/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID
|
||||||
|
*PetApi* | [**updatePet**](docs/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet
|
||||||
|
*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||||
|
*PetApi* | [**uploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||||
|
*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
|
||||||
|
*StoreApi* | [**getInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||||
|
*StoreApi* | [**getOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID
|
||||||
|
*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet
|
||||||
|
*UserApi* | [**createUser**](docs/UserApi.md#createuser) | **POST** /user | Create user
|
||||||
|
*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||||
|
*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array
|
||||||
|
*UserApi* | [**deleteUser**](docs/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user
|
||||||
|
*UserApi* | [**getUserByName**](docs/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name
|
||||||
|
*UserApi* | [**loginUser**](docs/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system
|
||||||
|
*UserApi* | [**logoutUser**](docs/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session
|
||||||
|
*UserApi* | [**updateUser**](docs/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user
|
||||||
|
|
||||||
|
|
||||||
|
<a name="documentation-for-models"></a>
|
||||||
|
## Documentation for Models
|
||||||
|
|
||||||
|
- [org.openapitools.client.models.ApiResponse](docs/ApiResponse.md)
|
||||||
|
- [org.openapitools.client.models.Category](docs/Category.md)
|
||||||
|
- [org.openapitools.client.models.Order](docs/Order.md)
|
||||||
|
- [org.openapitools.client.models.Pet](docs/Pet.md)
|
||||||
|
- [org.openapitools.client.models.Tag](docs/Tag.md)
|
||||||
|
- [org.openapitools.client.models.User](docs/User.md)
|
||||||
|
|
||||||
|
|
||||||
|
<a name="documentation-for-authorization"></a>
|
||||||
|
## Documentation for Authorization
|
||||||
|
|
||||||
|
<a name="api_key"></a>
|
||||||
|
### api_key
|
||||||
|
|
||||||
|
- **Type**: API key
|
||||||
|
- **API key parameter name**: api_key
|
||||||
|
- **Location**: HTTP header
|
||||||
|
|
||||||
|
<a name="petstore_auth"></a>
|
||||||
|
### petstore_auth
|
||||||
|
|
||||||
|
- **Type**: OAuth
|
||||||
|
- **Flow**: implicit
|
||||||
|
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||||
|
- **Scopes**:
|
||||||
|
- write:pets: modify pets in your account
|
||||||
|
- read:pets: read your pets
|
||||||
|
|
37
samples/client/petstore/kotlin-nonpublic/build.gradle
Normal file
37
samples/client/petstore/kotlin-nonpublic/build.gradle
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
group 'org.openapitools'
|
||||||
|
version '1.0.0'
|
||||||
|
|
||||||
|
wrapper {
|
||||||
|
gradleVersion = '4.9'
|
||||||
|
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
ext.kotlin_version = '1.3.41'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||||
|
compile "com.squareup.moshi:moshi-kotlin:1.8.0"
|
||||||
|
compile "com.squareup.moshi:moshi-adapters:1.8.0"
|
||||||
|
compile "com.squareup.okhttp3:okhttp:4.2.0"
|
||||||
|
testImplementation "io.kotlintest:kotlintest-runner-junit5:3.1.0"
|
||||||
|
}
|
12
samples/client/petstore/kotlin-nonpublic/docs/ApiResponse.md
Normal file
12
samples/client/petstore/kotlin-nonpublic/docs/ApiResponse.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
# ApiResponse
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**code** | **kotlin.Int** | | [optional]
|
||||||
|
**type** | **kotlin.String** | | [optional]
|
||||||
|
**message** | **kotlin.String** | | [optional]
|
||||||
|
|
||||||
|
|
||||||
|
|
11
samples/client/petstore/kotlin-nonpublic/docs/Category.md
Normal file
11
samples/client/petstore/kotlin-nonpublic/docs/Category.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
# Category
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**id** | **kotlin.Long** | | [optional]
|
||||||
|
**name** | **kotlin.String** | | [optional]
|
||||||
|
|
||||||
|
|
||||||
|
|
22
samples/client/petstore/kotlin-nonpublic/docs/Order.md
Normal file
22
samples/client/petstore/kotlin-nonpublic/docs/Order.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
# Order
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**id** | **kotlin.Long** | | [optional]
|
||||||
|
**petId** | **kotlin.Long** | | [optional]
|
||||||
|
**quantity** | **kotlin.Int** | | [optional]
|
||||||
|
**shipDate** | [**java.time.LocalDateTime**](java.time.LocalDateTime.md) | | [optional]
|
||||||
|
**status** | [**inline**](#StatusEnum) | Order Status | [optional]
|
||||||
|
**complete** | **kotlin.Boolean** | | [optional]
|
||||||
|
|
||||||
|
|
||||||
|
<a name="StatusEnum"></a>
|
||||||
|
## Enum: status
|
||||||
|
Name | Value
|
||||||
|
---- | -----
|
||||||
|
status | placed, approved, delivered
|
||||||
|
|
||||||
|
|
||||||
|
|
22
samples/client/petstore/kotlin-nonpublic/docs/Pet.md
Normal file
22
samples/client/petstore/kotlin-nonpublic/docs/Pet.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
# Pet
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**id** | **kotlin.Long** | | [optional]
|
||||||
|
**category** | [**Category**](Category.md) | | [optional]
|
||||||
|
**name** | **kotlin.String** | |
|
||||||
|
**photoUrls** | **kotlin.Array<kotlin.String>** | |
|
||||||
|
**tags** | [**kotlin.Array<Tag>**](Tag.md) | | [optional]
|
||||||
|
**status** | [**inline**](#StatusEnum) | pet status in the store | [optional]
|
||||||
|
|
||||||
|
|
||||||
|
<a name="StatusEnum"></a>
|
||||||
|
## Enum: status
|
||||||
|
Name | Value
|
||||||
|
---- | -----
|
||||||
|
status | available, pending, sold
|
||||||
|
|
||||||
|
|
||||||
|
|
405
samples/client/petstore/kotlin-nonpublic/docs/PetApi.md
Normal file
405
samples/client/petstore/kotlin-nonpublic/docs/PetApi.md
Normal file
@ -0,0 +1,405 @@
|
|||||||
|
# PetApi
|
||||||
|
|
||||||
|
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||||
|
|
||||||
|
Method | HTTP request | Description
|
||||||
|
------------- | ------------- | -------------
|
||||||
|
[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store
|
||||||
|
[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||||
|
[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
|
||||||
|
[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||||
|
[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID
|
||||||
|
[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet
|
||||||
|
[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||||
|
[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||||
|
|
||||||
|
|
||||||
|
<a name="addPet"></a>
|
||||||
|
# **addPet**
|
||||||
|
> addPet(body)
|
||||||
|
|
||||||
|
Add a new pet to the store
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = PetApi()
|
||||||
|
val body : Pet = // Pet | Pet object that needs to be added to the store
|
||||||
|
try {
|
||||||
|
apiInstance.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
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
|
||||||
|
Configure petstore_auth:
|
||||||
|
ApiClient.accessToken = ""
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json, application/xml
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
<a name="deletePet"></a>
|
||||||
|
# **deletePet**
|
||||||
|
> deletePet(petId, apiKey)
|
||||||
|
|
||||||
|
Deletes a pet
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = PetApi()
|
||||||
|
val petId : kotlin.Long = 789 // kotlin.Long | Pet id to delete
|
||||||
|
val apiKey : kotlin.String = apiKey_example // kotlin.String |
|
||||||
|
try {
|
||||||
|
apiInstance.deletePet(petId, apiKey)
|
||||||
|
} catch (e: ClientException) {
|
||||||
|
println("4xx response calling PetApi#deletePet")
|
||||||
|
e.printStackTrace()
|
||||||
|
} catch (e: ServerException) {
|
||||||
|
println("5xx response calling PetApi#deletePet")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**petId** | **kotlin.Long**| Pet id to delete |
|
||||||
|
**apiKey** | **kotlin.String**| | [optional]
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
|
||||||
|
Configure petstore_auth:
|
||||||
|
ApiClient.accessToken = ""
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
<a name="findPetsByStatus"></a>
|
||||||
|
# **findPetsByStatus**
|
||||||
|
> kotlin.Array<Pet> findPetsByStatus(status)
|
||||||
|
|
||||||
|
Finds Pets by status
|
||||||
|
|
||||||
|
Multiple status values can be provided with comma separated strings
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = PetApi()
|
||||||
|
val status : kotlin.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)
|
||||||
|
println(result)
|
||||||
|
} catch (e: ClientException) {
|
||||||
|
println("4xx response calling PetApi#findPetsByStatus")
|
||||||
|
e.printStackTrace()
|
||||||
|
} catch (e: ServerException) {
|
||||||
|
println("5xx response calling PetApi#findPetsByStatus")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**status** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Status values that need to be considered for filter | [enum: available, pending, sold]
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**kotlin.Array<Pet>**](Pet.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
|
||||||
|
Configure petstore_auth:
|
||||||
|
ApiClient.accessToken = ""
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
<a name="findPetsByTags"></a>
|
||||||
|
# **findPetsByTags**
|
||||||
|
> kotlin.Array<Pet> findPetsByTags(tags)
|
||||||
|
|
||||||
|
Finds Pets by tags
|
||||||
|
|
||||||
|
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = PetApi()
|
||||||
|
val tags : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Tags to filter by
|
||||||
|
try {
|
||||||
|
val result : kotlin.Array<Pet> = apiInstance.findPetsByTags(tags)
|
||||||
|
println(result)
|
||||||
|
} catch (e: ClientException) {
|
||||||
|
println("4xx response calling PetApi#findPetsByTags")
|
||||||
|
e.printStackTrace()
|
||||||
|
} catch (e: ServerException) {
|
||||||
|
println("5xx response calling PetApi#findPetsByTags")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**tags** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Tags to filter by |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**kotlin.Array<Pet>**](Pet.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
|
||||||
|
Configure petstore_auth:
|
||||||
|
ApiClient.accessToken = ""
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
<a name="getPetById"></a>
|
||||||
|
# **getPetById**
|
||||||
|
> Pet getPetById(petId)
|
||||||
|
|
||||||
|
Find pet by ID
|
||||||
|
|
||||||
|
Returns a single pet
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = PetApi()
|
||||||
|
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to return
|
||||||
|
try {
|
||||||
|
val result : Pet = apiInstance.getPetById(petId)
|
||||||
|
println(result)
|
||||||
|
} catch (e: ClientException) {
|
||||||
|
println("4xx response calling PetApi#getPetById")
|
||||||
|
e.printStackTrace()
|
||||||
|
} catch (e: ServerException) {
|
||||||
|
println("5xx response calling PetApi#getPetById")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**petId** | **kotlin.Long**| ID of pet to return |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**Pet**](Pet.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
|
||||||
|
Configure api_key:
|
||||||
|
ApiClient.apiKey["api_key"] = ""
|
||||||
|
ApiClient.apiKeyPrefix["api_key"] = ""
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
<a name="updatePet"></a>
|
||||||
|
# **updatePet**
|
||||||
|
> updatePet(body)
|
||||||
|
|
||||||
|
Update an existing pet
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = PetApi()
|
||||||
|
val body : Pet = // Pet | Pet object that needs to be added to the store
|
||||||
|
try {
|
||||||
|
apiInstance.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
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
|
||||||
|
Configure petstore_auth:
|
||||||
|
ApiClient.accessToken = ""
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json, application/xml
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
<a name="updatePetWithForm"></a>
|
||||||
|
# **updatePetWithForm**
|
||||||
|
> updatePetWithForm(petId, name, status)
|
||||||
|
|
||||||
|
Updates a pet in the store with form data
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = PetApi()
|
||||||
|
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be updated
|
||||||
|
val name : kotlin.String = name_example // kotlin.String | Updated name of the pet
|
||||||
|
val status : kotlin.String = status_example // kotlin.String | Updated status of the pet
|
||||||
|
try {
|
||||||
|
apiInstance.updatePetWithForm(petId, name, status)
|
||||||
|
} catch (e: ClientException) {
|
||||||
|
println("4xx response calling PetApi#updatePetWithForm")
|
||||||
|
e.printStackTrace()
|
||||||
|
} catch (e: ServerException) {
|
||||||
|
println("5xx response calling PetApi#updatePetWithForm")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**petId** | **kotlin.Long**| ID of pet that needs to be updated |
|
||||||
|
**name** | **kotlin.String**| Updated name of the pet | [optional]
|
||||||
|
**status** | **kotlin.String**| Updated status of the pet | [optional]
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
|
||||||
|
Configure petstore_auth:
|
||||||
|
ApiClient.accessToken = ""
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/x-www-form-urlencoded
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
<a name="uploadFile"></a>
|
||||||
|
# **uploadFile**
|
||||||
|
> ApiResponse uploadFile(petId, additionalMetadata, file)
|
||||||
|
|
||||||
|
uploads an image
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = PetApi()
|
||||||
|
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to update
|
||||||
|
val additionalMetadata : kotlin.String = additionalMetadata_example // kotlin.String | Additional data to pass to server
|
||||||
|
val file : java.io.File = BINARY_DATA_HERE // java.io.File | file to upload
|
||||||
|
try {
|
||||||
|
val result : ApiResponse = apiInstance.uploadFile(petId, additionalMetadata, file)
|
||||||
|
println(result)
|
||||||
|
} catch (e: ClientException) {
|
||||||
|
println("4xx response calling PetApi#uploadFile")
|
||||||
|
e.printStackTrace()
|
||||||
|
} catch (e: ServerException) {
|
||||||
|
println("5xx response calling PetApi#uploadFile")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**petId** | **kotlin.Long**| ID of pet to update |
|
||||||
|
**additionalMetadata** | **kotlin.String**| Additional data to pass to server | [optional]
|
||||||
|
**file** | **java.io.File**| file to upload | [optional]
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**ApiResponse**](ApiResponse.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
|
||||||
|
Configure petstore_auth:
|
||||||
|
ApiClient.accessToken = ""
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: multipart/form-data
|
||||||
|
- **Accept**: application/json
|
||||||
|
|
196
samples/client/petstore/kotlin-nonpublic/docs/StoreApi.md
Normal file
196
samples/client/petstore/kotlin-nonpublic/docs/StoreApi.md
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
# StoreApi
|
||||||
|
|
||||||
|
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||||
|
|
||||||
|
Method | HTTP request | Description
|
||||||
|
------------- | ------------- | -------------
|
||||||
|
[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
|
||||||
|
[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||||
|
[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
|
||||||
|
[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet
|
||||||
|
|
||||||
|
|
||||||
|
<a name="deleteOrder"></a>
|
||||||
|
# **deleteOrder**
|
||||||
|
> deleteOrder(orderId)
|
||||||
|
|
||||||
|
Delete purchase order by ID
|
||||||
|
|
||||||
|
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = StoreApi()
|
||||||
|
val orderId : kotlin.String = orderId_example // kotlin.String | ID of the order that needs to be deleted
|
||||||
|
try {
|
||||||
|
apiInstance.deleteOrder(orderId)
|
||||||
|
} catch (e: ClientException) {
|
||||||
|
println("4xx response calling StoreApi#deleteOrder")
|
||||||
|
e.printStackTrace()
|
||||||
|
} catch (e: ServerException) {
|
||||||
|
println("5xx response calling StoreApi#deleteOrder")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**orderId** | **kotlin.String**| ID of the order that needs to be deleted |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
<a name="getInventory"></a>
|
||||||
|
# **getInventory**
|
||||||
|
> kotlin.collections.Map<kotlin.String, kotlin.Int> getInventory()
|
||||||
|
|
||||||
|
Returns pet inventories by status
|
||||||
|
|
||||||
|
Returns a map of status codes to quantities
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = StoreApi()
|
||||||
|
try {
|
||||||
|
val result : kotlin.collections.Map<kotlin.String, kotlin.Int> = apiInstance.getInventory()
|
||||||
|
println(result)
|
||||||
|
} catch (e: ClientException) {
|
||||||
|
println("4xx response calling StoreApi#getInventory")
|
||||||
|
e.printStackTrace()
|
||||||
|
} catch (e: ServerException) {
|
||||||
|
println("5xx response calling StoreApi#getInventory")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
This endpoint does not need any parameter.
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**kotlin.collections.Map<kotlin.String, kotlin.Int>**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
|
||||||
|
Configure api_key:
|
||||||
|
ApiClient.apiKey["api_key"] = ""
|
||||||
|
ApiClient.apiKeyPrefix["api_key"] = ""
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/json
|
||||||
|
|
||||||
|
<a name="getOrderById"></a>
|
||||||
|
# **getOrderById**
|
||||||
|
> Order getOrderById(orderId)
|
||||||
|
|
||||||
|
Find purchase order by ID
|
||||||
|
|
||||||
|
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = StoreApi()
|
||||||
|
val orderId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be fetched
|
||||||
|
try {
|
||||||
|
val result : Order = apiInstance.getOrderById(orderId)
|
||||||
|
println(result)
|
||||||
|
} catch (e: ClientException) {
|
||||||
|
println("4xx response calling StoreApi#getOrderById")
|
||||||
|
e.printStackTrace()
|
||||||
|
} catch (e: ServerException) {
|
||||||
|
println("5xx response calling StoreApi#getOrderById")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**orderId** | **kotlin.Long**| ID of pet that needs to be fetched |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**Order**](Order.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
<a name="placeOrder"></a>
|
||||||
|
# **placeOrder**
|
||||||
|
> Order placeOrder(body)
|
||||||
|
|
||||||
|
Place an order for a pet
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = StoreApi()
|
||||||
|
val body : Order = // Order | order placed for purchasing the pet
|
||||||
|
try {
|
||||||
|
val result : Order = apiInstance.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
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**body** | [**Order**](Order.md)| order placed for purchasing the pet |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**Order**](Order.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
11
samples/client/petstore/kotlin-nonpublic/docs/Tag.md
Normal file
11
samples/client/petstore/kotlin-nonpublic/docs/Tag.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
# Tag
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**id** | **kotlin.Long** | | [optional]
|
||||||
|
**name** | **kotlin.String** | | [optional]
|
||||||
|
|
||||||
|
|
||||||
|
|
17
samples/client/petstore/kotlin-nonpublic/docs/User.md
Normal file
17
samples/client/petstore/kotlin-nonpublic/docs/User.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
# User
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**id** | **kotlin.Long** | | [optional]
|
||||||
|
**username** | **kotlin.String** | | [optional]
|
||||||
|
**firstName** | **kotlin.String** | | [optional]
|
||||||
|
**lastName** | **kotlin.String** | | [optional]
|
||||||
|
**email** | **kotlin.String** | | [optional]
|
||||||
|
**password** | **kotlin.String** | | [optional]
|
||||||
|
**phone** | **kotlin.String** | | [optional]
|
||||||
|
**userStatus** | **kotlin.Int** | User Status | [optional]
|
||||||
|
|
||||||
|
|
||||||
|
|
376
samples/client/petstore/kotlin-nonpublic/docs/UserApi.md
Normal file
376
samples/client/petstore/kotlin-nonpublic/docs/UserApi.md
Normal file
@ -0,0 +1,376 @@
|
|||||||
|
# UserApi
|
||||||
|
|
||||||
|
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||||
|
|
||||||
|
Method | HTTP request | Description
|
||||||
|
------------- | ------------- | -------------
|
||||||
|
[**createUser**](UserApi.md#createUser) | **POST** /user | Create user
|
||||||
|
[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||||
|
[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array
|
||||||
|
[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user
|
||||||
|
[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name
|
||||||
|
[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system
|
||||||
|
[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session
|
||||||
|
[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user
|
||||||
|
|
||||||
|
|
||||||
|
<a name="createUser"></a>
|
||||||
|
# **createUser**
|
||||||
|
> createUser(body)
|
||||||
|
|
||||||
|
Create user
|
||||||
|
|
||||||
|
This can only be done by the logged in user.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = UserApi()
|
||||||
|
val body : User = // User | Created user object
|
||||||
|
try {
|
||||||
|
apiInstance.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
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**body** | [**User**](User.md)| Created user object |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
<a name="createUsersWithArrayInput"></a>
|
||||||
|
# **createUsersWithArrayInput**
|
||||||
|
> createUsersWithArrayInput(body)
|
||||||
|
|
||||||
|
Creates list of users with given input array
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = UserApi()
|
||||||
|
val body : kotlin.Array<User> = // kotlin.Array<User> | List of user object
|
||||||
|
try {
|
||||||
|
apiInstance.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
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**body** | [**kotlin.Array<User>**](User.md)| List of user object |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
<a name="createUsersWithListInput"></a>
|
||||||
|
# **createUsersWithListInput**
|
||||||
|
> createUsersWithListInput(body)
|
||||||
|
|
||||||
|
Creates list of users with given input array
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = UserApi()
|
||||||
|
val body : kotlin.Array<User> = // kotlin.Array<User> | List of user object
|
||||||
|
try {
|
||||||
|
apiInstance.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
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**body** | [**kotlin.Array<User>**](User.md)| List of user object |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
<a name="deleteUser"></a>
|
||||||
|
# **deleteUser**
|
||||||
|
> deleteUser(username)
|
||||||
|
|
||||||
|
Delete user
|
||||||
|
|
||||||
|
This can only be done by the logged in user.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = UserApi()
|
||||||
|
val username : kotlin.String = username_example // kotlin.String | The name that needs to be deleted
|
||||||
|
try {
|
||||||
|
apiInstance.deleteUser(username)
|
||||||
|
} catch (e: ClientException) {
|
||||||
|
println("4xx response calling UserApi#deleteUser")
|
||||||
|
e.printStackTrace()
|
||||||
|
} catch (e: ServerException) {
|
||||||
|
println("5xx response calling UserApi#deleteUser")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**username** | **kotlin.String**| The name that needs to be deleted |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
<a name="getUserByName"></a>
|
||||||
|
# **getUserByName**
|
||||||
|
> User getUserByName(username)
|
||||||
|
|
||||||
|
Get user by user name
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = UserApi()
|
||||||
|
val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing.
|
||||||
|
try {
|
||||||
|
val result : User = apiInstance.getUserByName(username)
|
||||||
|
println(result)
|
||||||
|
} catch (e: ClientException) {
|
||||||
|
println("4xx response calling UserApi#getUserByName")
|
||||||
|
e.printStackTrace()
|
||||||
|
} catch (e: ServerException) {
|
||||||
|
println("5xx response calling UserApi#getUserByName")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**username** | **kotlin.String**| The name that needs to be fetched. Use user1 for testing. |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**User**](User.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
<a name="loginUser"></a>
|
||||||
|
# **loginUser**
|
||||||
|
> kotlin.String loginUser(username, password)
|
||||||
|
|
||||||
|
Logs user into the system
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = UserApi()
|
||||||
|
val username : kotlin.String = username_example // kotlin.String | The user name for login
|
||||||
|
val password : kotlin.String = password_example // kotlin.String | The password for login in clear text
|
||||||
|
try {
|
||||||
|
val result : kotlin.String = apiInstance.loginUser(username, password)
|
||||||
|
println(result)
|
||||||
|
} catch (e: ClientException) {
|
||||||
|
println("4xx response calling UserApi#loginUser")
|
||||||
|
e.printStackTrace()
|
||||||
|
} catch (e: ServerException) {
|
||||||
|
println("5xx response calling UserApi#loginUser")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**username** | **kotlin.String**| The user name for login |
|
||||||
|
**password** | **kotlin.String**| The password for login in clear text |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**kotlin.String**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
<a name="logoutUser"></a>
|
||||||
|
# **logoutUser**
|
||||||
|
> logoutUser()
|
||||||
|
|
||||||
|
Logs out current logged in user session
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = UserApi()
|
||||||
|
try {
|
||||||
|
apiInstance.logoutUser()
|
||||||
|
} catch (e: ClientException) {
|
||||||
|
println("4xx response calling UserApi#logoutUser")
|
||||||
|
e.printStackTrace()
|
||||||
|
} catch (e: ServerException) {
|
||||||
|
println("5xx response calling UserApi#logoutUser")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
This endpoint does not need any parameter.
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
<a name="updateUser"></a>
|
||||||
|
# **updateUser**
|
||||||
|
> updateUser(username, body)
|
||||||
|
|
||||||
|
Updated user
|
||||||
|
|
||||||
|
This can only be done by the logged in user.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```kotlin
|
||||||
|
// Import classes:
|
||||||
|
//import org.openapitools.client.infrastructure.*
|
||||||
|
//import org.openapitools.client.models.*
|
||||||
|
|
||||||
|
val apiInstance = UserApi()
|
||||||
|
val username : kotlin.String = username_example // kotlin.String | name that need to be deleted
|
||||||
|
val body : User = // User | Updated user object
|
||||||
|
try {
|
||||||
|
apiInstance.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
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**username** | **kotlin.String**| name that need to be deleted |
|
||||||
|
**body** | [**User**](User.md)| Updated user object |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
null (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
2
samples/client/petstore/kotlin-nonpublic/settings.gradle
Normal file
2
samples/client/petstore/kotlin-nonpublic/settings.gradle
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
rootProject.name = 'kotlin-petstore-nonpublic'
|
@ -0,0 +1,280 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.client.apis
|
||||||
|
|
||||||
|
import org.openapitools.client.models.ApiResponse
|
||||||
|
import org.openapitools.client.models.Pet
|
||||||
|
|
||||||
|
import org.openapitools.client.infrastructure.ApiClient
|
||||||
|
import org.openapitools.client.infrastructure.ClientException
|
||||||
|
import org.openapitools.client.infrastructure.ClientError
|
||||||
|
import org.openapitools.client.infrastructure.ServerException
|
||||||
|
import org.openapitools.client.infrastructure.ServerError
|
||||||
|
import org.openapitools.client.infrastructure.MultiValueMap
|
||||||
|
import org.openapitools.client.infrastructure.RequestConfig
|
||||||
|
import org.openapitools.client.infrastructure.RequestMethod
|
||||||
|
import org.openapitools.client.infrastructure.ResponseType
|
||||||
|
import org.openapitools.client.infrastructure.Success
|
||||||
|
import org.openapitools.client.infrastructure.toMultiValue
|
||||||
|
|
||||||
|
internal class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiClient(basePath) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new pet to the store
|
||||||
|
*
|
||||||
|
* @param body Pet object that needs to be added to the store
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
fun addPet(body: Pet) : Unit {
|
||||||
|
val localVariableBody: kotlin.Any? = body
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.POST,
|
||||||
|
"/pet",
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<Any?>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> Unit
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a pet
|
||||||
|
*
|
||||||
|
* @param petId Pet id to delete
|
||||||
|
* @param apiKey (optional)
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?) : Unit {
|
||||||
|
val localVariableBody: kotlin.Any? = null
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("api_key" to apiKey.toString())
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.DELETE,
|
||||||
|
"/pet/{petId}".replace("{"+"petId"+"}", "$petId"),
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<Any?>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> Unit
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds Pets by status
|
||||||
|
* Multiple status values can be provided with comma separated strings
|
||||||
|
* @param status Status values that need to be considered for filter
|
||||||
|
* @return kotlin.Array<Pet>
|
||||||
|
*/
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
fun findPetsByStatus(status: kotlin.Array<kotlin.String>) : kotlin.Array<Pet> {
|
||||||
|
val localVariableBody: kotlin.Any? = null
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf("status" to toMultiValue(status.toList(), "csv"))
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.GET,
|
||||||
|
"/pet/findByStatus",
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<kotlin.Array<Pet>>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Pet>
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds Pets by tags
|
||||||
|
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
* @param tags Tags to filter by
|
||||||
|
* @return kotlin.Array<Pet>
|
||||||
|
*/
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
fun findPetsByTags(tags: kotlin.Array<kotlin.String>) : kotlin.Array<Pet> {
|
||||||
|
val localVariableBody: kotlin.Any? = null
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf("tags" to toMultiValue(tags.toList(), "csv"))
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.GET,
|
||||||
|
"/pet/findByTags",
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<kotlin.Array<Pet>>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Pet>
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find pet by ID
|
||||||
|
* Returns a single pet
|
||||||
|
* @param petId ID of pet to return
|
||||||
|
* @return Pet
|
||||||
|
*/
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
fun getPetById(petId: kotlin.Long) : Pet {
|
||||||
|
val localVariableBody: kotlin.Any? = null
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.GET,
|
||||||
|
"/pet/{petId}".replace("{"+"petId"+"}", "$petId"),
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<Pet>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> (response as Success<*>).data as Pet
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an existing pet
|
||||||
|
*
|
||||||
|
* @param body Pet object that needs to be added to the store
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
fun updatePet(body: Pet) : Unit {
|
||||||
|
val localVariableBody: kotlin.Any? = body
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.PUT,
|
||||||
|
"/pet",
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<Any?>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> Unit
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a pet in the store with form data
|
||||||
|
*
|
||||||
|
* @param petId ID of pet that needs to be updated
|
||||||
|
* @param name Updated name of the pet (optional)
|
||||||
|
* @param status Updated status of the pet (optional)
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?) : Unit {
|
||||||
|
val localVariableBody: kotlin.Any? = mapOf("name" to "$name", "status" to "$status")
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("Content-Type" to "")
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.POST,
|
||||||
|
"/pet/{petId}".replace("{"+"petId"+"}", "$petId"),
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<Any?>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> Unit
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* uploads an image
|
||||||
|
*
|
||||||
|
* @param petId ID of pet to update
|
||||||
|
* @param additionalMetadata Additional data to pass to server (optional)
|
||||||
|
* @param file file to upload (optional)
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: java.io.File?) : ApiResponse {
|
||||||
|
val localVariableBody: kotlin.Any? = mapOf("additionalMetadata" to "$additionalMetadata", "file" to "$file")
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("Content-Type" to "")
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.POST,
|
||||||
|
"/pet/{petId}/uploadImage".replace("{"+"petId"+"}", "$petId"),
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<ApiResponse>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> (response as Success<*>).data as ApiResponse
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,152 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.client.apis
|
||||||
|
|
||||||
|
import org.openapitools.client.models.Order
|
||||||
|
|
||||||
|
import org.openapitools.client.infrastructure.ApiClient
|
||||||
|
import org.openapitools.client.infrastructure.ClientException
|
||||||
|
import org.openapitools.client.infrastructure.ClientError
|
||||||
|
import org.openapitools.client.infrastructure.ServerException
|
||||||
|
import org.openapitools.client.infrastructure.ServerError
|
||||||
|
import org.openapitools.client.infrastructure.MultiValueMap
|
||||||
|
import org.openapitools.client.infrastructure.RequestConfig
|
||||||
|
import org.openapitools.client.infrastructure.RequestMethod
|
||||||
|
import org.openapitools.client.infrastructure.ResponseType
|
||||||
|
import org.openapitools.client.infrastructure.Success
|
||||||
|
import org.openapitools.client.infrastructure.toMultiValue
|
||||||
|
|
||||||
|
internal class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiClient(basePath) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete purchase order by ID
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
* @param orderId ID of the order that needs to be deleted
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
fun deleteOrder(orderId: kotlin.String) : Unit {
|
||||||
|
val localVariableBody: kotlin.Any? = null
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.DELETE,
|
||||||
|
"/store/order/{orderId}".replace("{"+"orderId"+"}", "$orderId"),
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<Any?>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> Unit
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns pet inventories by status
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
* @return kotlin.collections.Map<kotlin.String, kotlin.Int>
|
||||||
|
*/
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
fun getInventory() : kotlin.collections.Map<kotlin.String, kotlin.Int> {
|
||||||
|
val localVariableBody: kotlin.Any? = null
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.GET,
|
||||||
|
"/store/inventory",
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<kotlin.collections.Map<kotlin.String, kotlin.Int>>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> (response as Success<*>).data as kotlin.collections.Map<kotlin.String, kotlin.Int>
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find purchase order by ID
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
* @param orderId ID of pet that needs to be fetched
|
||||||
|
* @return Order
|
||||||
|
*/
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
fun getOrderById(orderId: kotlin.Long) : Order {
|
||||||
|
val localVariableBody: kotlin.Any? = null
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.GET,
|
||||||
|
"/store/order/{orderId}".replace("{"+"orderId"+"}", "$orderId"),
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<Order>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> (response as Success<*>).data as Order
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place an order for a pet
|
||||||
|
*
|
||||||
|
* @param body order placed for purchasing the pet
|
||||||
|
* @return Order
|
||||||
|
*/
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
fun placeOrder(body: Order) : Order {
|
||||||
|
val localVariableBody: kotlin.Any? = body
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.POST,
|
||||||
|
"/store/order",
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<Order>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> (response as Success<*>).data as Order
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,273 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.client.apis
|
||||||
|
|
||||||
|
import org.openapitools.client.models.User
|
||||||
|
|
||||||
|
import org.openapitools.client.infrastructure.ApiClient
|
||||||
|
import org.openapitools.client.infrastructure.ClientException
|
||||||
|
import org.openapitools.client.infrastructure.ClientError
|
||||||
|
import org.openapitools.client.infrastructure.ServerException
|
||||||
|
import org.openapitools.client.infrastructure.ServerError
|
||||||
|
import org.openapitools.client.infrastructure.MultiValueMap
|
||||||
|
import org.openapitools.client.infrastructure.RequestConfig
|
||||||
|
import org.openapitools.client.infrastructure.RequestMethod
|
||||||
|
import org.openapitools.client.infrastructure.ResponseType
|
||||||
|
import org.openapitools.client.infrastructure.Success
|
||||||
|
import org.openapitools.client.infrastructure.toMultiValue
|
||||||
|
|
||||||
|
internal class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiClient(basePath) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create user
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* @param body Created user object
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
fun createUser(body: User) : Unit {
|
||||||
|
val localVariableBody: kotlin.Any? = body
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.POST,
|
||||||
|
"/user",
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<Any?>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> Unit
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*
|
||||||
|
* @param body List of user object
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
fun createUsersWithArrayInput(body: kotlin.Array<User>) : Unit {
|
||||||
|
val localVariableBody: kotlin.Any? = body
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.POST,
|
||||||
|
"/user/createWithArray",
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<Any?>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> Unit
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*
|
||||||
|
* @param body List of user object
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
fun createUsersWithListInput(body: kotlin.Array<User>) : Unit {
|
||||||
|
val localVariableBody: kotlin.Any? = body
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.POST,
|
||||||
|
"/user/createWithList",
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<Any?>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> Unit
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete user
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* @param username The name that needs to be deleted
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
fun deleteUser(username: kotlin.String) : Unit {
|
||||||
|
val localVariableBody: kotlin.Any? = null
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.DELETE,
|
||||||
|
"/user/{username}".replace("{"+"username"+"}", "$username"),
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<Any?>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> Unit
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get user by user name
|
||||||
|
*
|
||||||
|
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||||
|
* @return User
|
||||||
|
*/
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
fun getUserByName(username: kotlin.String) : User {
|
||||||
|
val localVariableBody: kotlin.Any? = null
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.GET,
|
||||||
|
"/user/{username}".replace("{"+"username"+"}", "$username"),
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<User>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> (response as Success<*>).data as User
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs user into the system
|
||||||
|
*
|
||||||
|
* @param username The user name for login
|
||||||
|
* @param password The password for login in clear text
|
||||||
|
* @return kotlin.String
|
||||||
|
*/
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
fun loginUser(username: kotlin.String, password: kotlin.String) : kotlin.String {
|
||||||
|
val localVariableBody: kotlin.Any? = null
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf("username" to listOf("$username"), "password" to listOf("$password"))
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.GET,
|
||||||
|
"/user/login",
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<kotlin.String>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> (response as Success<*>).data as kotlin.String
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs out current logged in user session
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
fun logoutUser() : Unit {
|
||||||
|
val localVariableBody: kotlin.Any? = null
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.GET,
|
||||||
|
"/user/logout",
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<Any?>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> Unit
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updated user
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* @param username name that need to be deleted
|
||||||
|
* @param body Updated user object
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
fun updateUser(username: kotlin.String, body: User) : Unit {
|
||||||
|
val localVariableBody: kotlin.Any? = body
|
||||||
|
val localVariableQuery: MultiValueMap = mapOf()
|
||||||
|
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val localVariableConfig = RequestConfig(
|
||||||
|
RequestMethod.PUT,
|
||||||
|
"/user/{username}".replace("{"+"username"+"}", "$username"),
|
||||||
|
query = localVariableQuery,
|
||||||
|
headers = localVariableHeaders
|
||||||
|
)
|
||||||
|
val response = request<Any?>(
|
||||||
|
localVariableConfig,
|
||||||
|
localVariableBody
|
||||||
|
)
|
||||||
|
|
||||||
|
return when (response.responseType) {
|
||||||
|
ResponseType.Success -> Unit
|
||||||
|
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||||
|
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||||
|
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||||
|
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package org.openapitools.client.infrastructure
|
||||||
|
|
||||||
|
typealias MultiValueMap = Map<String,List<String>>
|
||||||
|
|
||||||
|
internal fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
|
||||||
|
"csv" -> ","
|
||||||
|
"tsv" -> "\t"
|
||||||
|
"pipes" -> "|"
|
||||||
|
"ssv" -> " "
|
||||||
|
else -> ""
|
||||||
|
}
|
||||||
|
|
||||||
|
internal val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
|
||||||
|
|
||||||
|
internal fun <T : Any?> toMultiValue(items: Array<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter)
|
||||||
|
= toMultiValue(items.asIterable(), collectionFormat, map)
|
||||||
|
|
||||||
|
internal fun <T : Any?> toMultiValue(items: Iterable<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List<String> {
|
||||||
|
return when(collectionFormat) {
|
||||||
|
"multi" -> items.map(map)
|
||||||
|
else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map))
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,170 @@
|
|||||||
|
package org.openapitools.client.infrastructure
|
||||||
|
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.RequestBody
|
||||||
|
import okhttp3.RequestBody.Companion.asRequestBody
|
||||||
|
import okhttp3.RequestBody.Companion.toRequestBody
|
||||||
|
import okhttp3.FormBody
|
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||||
|
import okhttp3.ResponseBody
|
||||||
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||||
|
import okhttp3.Request
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
internal open class ApiClient(val baseUrl: String) {
|
||||||
|
internal companion object {
|
||||||
|
protected const val ContentType = "Content-Type"
|
||||||
|
protected const val Accept = "Accept"
|
||||||
|
protected const val Authorization = "Authorization"
|
||||||
|
protected const val JsonMediaType = "application/json"
|
||||||
|
protected const val FormDataMediaType = "multipart/form-data"
|
||||||
|
protected const val FormUrlEncMediaType = "application/x-www-form-urlencoded"
|
||||||
|
protected const val XmlMediaType = "application/xml"
|
||||||
|
|
||||||
|
val apiKey: MutableMap<String, String> = mutableMapOf()
|
||||||
|
val apiKeyPrefix: MutableMap<String, String> = mutableMapOf()
|
||||||
|
var username: String? = null
|
||||||
|
var password: String? = null
|
||||||
|
var accessToken: String? = null
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
val client: OkHttpClient by lazy {
|
||||||
|
builder.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
val builder: OkHttpClient.Builder = OkHttpClient.Builder()
|
||||||
|
}
|
||||||
|
|
||||||
|
protected inline fun <reified T> requestBody(content: T, mediaType: String = JsonMediaType): RequestBody =
|
||||||
|
when {
|
||||||
|
content is File -> content.asRequestBody(
|
||||||
|
mediaType.toMediaTypeOrNull()
|
||||||
|
)
|
||||||
|
mediaType == FormDataMediaType || mediaType == FormUrlEncMediaType -> {
|
||||||
|
FormBody.Builder().apply {
|
||||||
|
// content's type *must* be Map<String, Any>
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
(content as Map<String,String>).forEach { (key, value) ->
|
||||||
|
add(key, value)
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
mediaType == JsonMediaType -> Serializer.moshi.adapter(T::class.java).toJson(content).toRequestBody(
|
||||||
|
mediaType.toMediaTypeOrNull()
|
||||||
|
)
|
||||||
|
mediaType == XmlMediaType -> throw UnsupportedOperationException("xml not currently supported.")
|
||||||
|
// TODO: this should be extended with other serializers
|
||||||
|
else -> throw UnsupportedOperationException("requestBody currently only supports JSON body and File body.")
|
||||||
|
}
|
||||||
|
|
||||||
|
protected inline fun <reified T: Any?> responseBody(body: ResponseBody?, mediaType: String? = JsonMediaType): T? {
|
||||||
|
if(body == null) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
val bodyContent = body.string()
|
||||||
|
if (bodyContent.isEmpty()) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return when(mediaType) {
|
||||||
|
JsonMediaType -> Serializer.moshi.adapter(T::class.java).fromJson(bodyContent)
|
||||||
|
else -> throw UnsupportedOperationException("responseBody currently only supports JSON body.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected fun updateAuthParams(requestConfig: RequestConfig) {
|
||||||
|
if (requestConfig.headers["api_key"].isNullOrEmpty()) {
|
||||||
|
if (apiKey["api_key"] != null) {
|
||||||
|
if (apiKeyPrefix["api_key"] != null) {
|
||||||
|
requestConfig.headers["api_key"] = apiKeyPrefix["api_key"]!! + " " + apiKey["api_key"]!!
|
||||||
|
} else {
|
||||||
|
requestConfig.headers["api_key"] = apiKey["api_key"]!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (requestConfig.headers[Authorization].isNullOrEmpty()) {
|
||||||
|
requestConfig.headers[Authorization] = "Bearer " + accessToken
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected inline fun <reified T: Any?> request(requestConfig: RequestConfig, body : Any? = null): ApiInfrastructureResponse<T?> {
|
||||||
|
val httpUrl = baseUrl.toHttpUrlOrNull() ?: throw IllegalStateException("baseUrl is invalid.")
|
||||||
|
|
||||||
|
// take authMethod from operation
|
||||||
|
updateAuthParams(requestConfig)
|
||||||
|
|
||||||
|
val url = httpUrl.newBuilder()
|
||||||
|
.addPathSegments(requestConfig.path.trimStart('/'))
|
||||||
|
.apply {
|
||||||
|
requestConfig.query.forEach { query ->
|
||||||
|
query.value.forEach { queryValue ->
|
||||||
|
addQueryParameter(query.key, queryValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
|
||||||
|
// take content-type/accept from spec or set to default (application/json) if not defined
|
||||||
|
if (requestConfig.headers[ContentType].isNullOrEmpty()) {
|
||||||
|
requestConfig.headers[ContentType] = JsonMediaType
|
||||||
|
}
|
||||||
|
if (requestConfig.headers[Accept].isNullOrEmpty()) {
|
||||||
|
requestConfig.headers[Accept] = JsonMediaType
|
||||||
|
}
|
||||||
|
val headers = requestConfig.headers
|
||||||
|
|
||||||
|
if(headers[ContentType] ?: "" == "") {
|
||||||
|
throw kotlin.IllegalStateException("Missing Content-Type header. This is required.")
|
||||||
|
}
|
||||||
|
|
||||||
|
if(headers[Accept] ?: "" == "") {
|
||||||
|
throw kotlin.IllegalStateException("Missing Accept header. This is required.")
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: support multiple contentType options here.
|
||||||
|
val contentType = (headers[ContentType] as String).substringBefore(";").toLowerCase()
|
||||||
|
|
||||||
|
val request = when (requestConfig.method) {
|
||||||
|
RequestMethod.DELETE -> Request.Builder().url(url).delete(requestBody(body, contentType))
|
||||||
|
RequestMethod.GET -> Request.Builder().url(url)
|
||||||
|
RequestMethod.HEAD -> Request.Builder().url(url).head()
|
||||||
|
RequestMethod.PATCH -> Request.Builder().url(url).patch(requestBody(body, contentType))
|
||||||
|
RequestMethod.PUT -> Request.Builder().url(url).put(requestBody(body, contentType))
|
||||||
|
RequestMethod.POST -> Request.Builder().url(url).post(requestBody(body, contentType))
|
||||||
|
RequestMethod.OPTIONS -> Request.Builder().url(url).method("OPTIONS", null)
|
||||||
|
}.apply {
|
||||||
|
headers.forEach { header -> addHeader(header.key, header.value) }
|
||||||
|
}.build()
|
||||||
|
|
||||||
|
val response = client.newCall(request).execute()
|
||||||
|
val accept = response.header(ContentType)?.substringBefore(";")?.toLowerCase()
|
||||||
|
|
||||||
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
when {
|
||||||
|
response.isRedirect -> return Redirection(
|
||||||
|
response.code,
|
||||||
|
response.headers.toMultimap()
|
||||||
|
)
|
||||||
|
response.isInformational -> return Informational(
|
||||||
|
response.message,
|
||||||
|
response.code,
|
||||||
|
response.headers.toMultimap()
|
||||||
|
)
|
||||||
|
response.isSuccessful -> return Success(
|
||||||
|
responseBody(response.body, accept),
|
||||||
|
response.code,
|
||||||
|
response.headers.toMultimap()
|
||||||
|
)
|
||||||
|
response.isClientError -> return ClientError(
|
||||||
|
response.body?.string(),
|
||||||
|
response.code,
|
||||||
|
response.headers.toMultimap()
|
||||||
|
)
|
||||||
|
else -> return ServerError(
|
||||||
|
null,
|
||||||
|
response.body?.string(),
|
||||||
|
response.code,
|
||||||
|
response.headers.toMultimap()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package org.openapitools.client.infrastructure
|
||||||
|
|
||||||
|
internal enum class ResponseType {
|
||||||
|
Success, Informational, Redirection, ClientError, ServerError
|
||||||
|
}
|
||||||
|
|
||||||
|
internal abstract class ApiInfrastructureResponse<T>(val responseType: ResponseType) {
|
||||||
|
abstract val statusCode: Int
|
||||||
|
abstract val headers: Map<String,List<String>>
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class Success<T>(
|
||||||
|
val data: T,
|
||||||
|
override val statusCode: Int = -1,
|
||||||
|
override val headers: Map<String, List<String>> = mapOf()
|
||||||
|
): ApiInfrastructureResponse<T>(ResponseType.Success)
|
||||||
|
|
||||||
|
internal class Informational<T>(
|
||||||
|
val statusText: String,
|
||||||
|
override val statusCode: Int = -1,
|
||||||
|
override val headers: Map<String, List<String>> = mapOf()
|
||||||
|
) : ApiInfrastructureResponse<T>(ResponseType.Informational)
|
||||||
|
|
||||||
|
internal class Redirection<T>(
|
||||||
|
override val statusCode: Int = -1,
|
||||||
|
override val headers: Map<String, List<String>> = mapOf()
|
||||||
|
) : ApiInfrastructureResponse<T>(ResponseType.Redirection)
|
||||||
|
|
||||||
|
internal class ClientError<T>(
|
||||||
|
val body: Any? = null,
|
||||||
|
override val statusCode: Int = -1,
|
||||||
|
override val headers: Map<String, List<String>> = mapOf()
|
||||||
|
) : ApiInfrastructureResponse<T>(ResponseType.ClientError)
|
||||||
|
|
||||||
|
internal class ServerError<T>(
|
||||||
|
val message: String? = null,
|
||||||
|
val body: Any? = null,
|
||||||
|
override val statusCode: Int = -1,
|
||||||
|
override val headers: Map<String, List<String>>
|
||||||
|
): ApiInfrastructureResponse<T>(ResponseType.ServerError)
|
@ -0,0 +1,29 @@
|
|||||||
|
package org.openapitools.client.infrastructure
|
||||||
|
|
||||||
|
import kotlin.properties.ReadWriteProperty
|
||||||
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
|
internal object ApplicationDelegates {
|
||||||
|
/**
|
||||||
|
* Provides a property delegate, allowing the property to be set once and only once.
|
||||||
|
*
|
||||||
|
* If unset (no default value), a get on the property will throw [IllegalStateException].
|
||||||
|
*/
|
||||||
|
fun <T> setOnce(defaultValue: T? = null) : ReadWriteProperty<Any?, T> = SetOnce(defaultValue)
|
||||||
|
|
||||||
|
private class SetOnce<T>(defaultValue: T? = null) : ReadWriteProperty<Any?, T> {
|
||||||
|
private var isSet = false
|
||||||
|
private var value: T? = defaultValue
|
||||||
|
|
||||||
|
override fun getValue(thisRef: Any?, property: KProperty<*>): T {
|
||||||
|
return value ?: throw IllegalStateException("${property.name} not initialized")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) = synchronized(this) {
|
||||||
|
if (!isSet) {
|
||||||
|
this.value = value
|
||||||
|
isSet = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package org.openapitools.client.infrastructure
|
||||||
|
|
||||||
|
import com.squareup.moshi.FromJson
|
||||||
|
import com.squareup.moshi.ToJson
|
||||||
|
|
||||||
|
internal class ByteArrayAdapter {
|
||||||
|
@ToJson
|
||||||
|
fun toJson(data: ByteArray): String = String(data)
|
||||||
|
|
||||||
|
@FromJson
|
||||||
|
fun fromJson(data: String): ByteArray = data.toByteArray()
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
@file:Suppress("unused")
|
||||||
|
package org.openapitools.client.infrastructure
|
||||||
|
|
||||||
|
import java.lang.RuntimeException
|
||||||
|
|
||||||
|
internal open class ClientException : RuntimeException {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an [ClientException] with no detail message.
|
||||||
|
*/
|
||||||
|
constructor() : super()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an [ClientException] with the specified detail message.
|
||||||
|
|
||||||
|
* @param message the detail message.
|
||||||
|
*/
|
||||||
|
constructor(message: kotlin.String) : super(message)
|
||||||
|
|
||||||
|
internal companion object {
|
||||||
|
private const val serialVersionUID: Long = 123L
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal open class ServerException : RuntimeException {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an [ServerException] with no detail message.
|
||||||
|
*/
|
||||||
|
constructor() : super()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an [ServerException] with the specified detail message.
|
||||||
|
|
||||||
|
* @param message the detail message.
|
||||||
|
*/
|
||||||
|
constructor(message: kotlin.String) : super(message)
|
||||||
|
|
||||||
|
internal companion object {
|
||||||
|
private const val serialVersionUID: Long = 456L
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package org.openapitools.client.infrastructure
|
||||||
|
|
||||||
|
import com.squareup.moshi.FromJson
|
||||||
|
import com.squareup.moshi.ToJson
|
||||||
|
import java.time.LocalDate
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
|
internal class LocalDateAdapter {
|
||||||
|
@ToJson
|
||||||
|
fun toJson(value: LocalDate): String {
|
||||||
|
return DateTimeFormatter.ISO_LOCAL_DATE.format(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
@FromJson
|
||||||
|
fun fromJson(value: String): LocalDate {
|
||||||
|
return LocalDate.parse(value, DateTimeFormatter.ISO_LOCAL_DATE)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package org.openapitools.client.infrastructure
|
||||||
|
|
||||||
|
import com.squareup.moshi.FromJson
|
||||||
|
import com.squareup.moshi.ToJson
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
|
internal class LocalDateTimeAdapter {
|
||||||
|
@ToJson
|
||||||
|
fun toJson(value: LocalDateTime): String {
|
||||||
|
return DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
@FromJson
|
||||||
|
fun fromJson(value: String): LocalDateTime {
|
||||||
|
return LocalDateTime.parse(value, DateTimeFormatter.ISO_LOCAL_DATE_TIME)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package org.openapitools.client.infrastructure
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a config object for a given request.
|
||||||
|
* NOTE: This object doesn't include 'body' because it
|
||||||
|
* allows for caching of the constructed object
|
||||||
|
* for many request definitions.
|
||||||
|
* NOTE: Headers is a Map<String,String> because rfc2616 defines
|
||||||
|
* multi-valued headers as csv-only.
|
||||||
|
*/
|
||||||
|
internal data class RequestConfig(
|
||||||
|
val method: RequestMethod,
|
||||||
|
val path: String,
|
||||||
|
val headers: MutableMap<String, String> = mutableMapOf(),
|
||||||
|
val query: Map<String, List<String>> = mapOf()
|
||||||
|
)
|
@ -0,0 +1,8 @@
|
|||||||
|
package org.openapitools.client.infrastructure
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides enumerated HTTP verbs
|
||||||
|
*/
|
||||||
|
internal enum class RequestMethod {
|
||||||
|
GET, DELETE, HEAD, OPTIONS, PATCH, POST, PUT
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package org.openapitools.client.infrastructure
|
||||||
|
|
||||||
|
import okhttp3.Response
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides an extension to evaluation whether the response is a 1xx code
|
||||||
|
*/
|
||||||
|
internal val Response.isInformational : Boolean get() = this.code in 100..199
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides an extension to evaluation whether the response is a 3xx code
|
||||||
|
*/
|
||||||
|
internal val Response.isRedirect : Boolean get() = this.code in 300..399
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides an extension to evaluation whether the response is a 4xx code
|
||||||
|
*/
|
||||||
|
internal val Response.isClientError : Boolean get() = this.code in 400..499
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides an extension to evaluation whether the response is a 5xx (Standard) through 999 (non-standard) code
|
||||||
|
*/
|
||||||
|
internal val Response.isServerError : Boolean get() = this.code in 500..999
|
@ -0,0 +1,18 @@
|
|||||||
|
package org.openapitools.client.infrastructure
|
||||||
|
|
||||||
|
import com.squareup.moshi.Moshi
|
||||||
|
import com.squareup.moshi.adapters.Rfc3339DateJsonAdapter
|
||||||
|
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
|
internal object Serializer {
|
||||||
|
@JvmStatic
|
||||||
|
val moshi: Moshi = Moshi.Builder()
|
||||||
|
.add(Date::class.java, Rfc3339DateJsonAdapter().nullSafe())
|
||||||
|
.add(LocalDateTimeAdapter())
|
||||||
|
.add(LocalDateAdapter())
|
||||||
|
.add(UUIDAdapter())
|
||||||
|
.add(ByteArrayAdapter())
|
||||||
|
.add(KotlinJsonAdapterFactory())
|
||||||
|
.build()
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package org.openapitools.client.infrastructure
|
||||||
|
|
||||||
|
import com.squareup.moshi.FromJson
|
||||||
|
import com.squareup.moshi.ToJson
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
internal class UUIDAdapter {
|
||||||
|
@ToJson
|
||||||
|
fun toJson(uuid: UUID) = uuid.toString()
|
||||||
|
|
||||||
|
@FromJson
|
||||||
|
fun fromJson(s: String) = UUID.fromString(s)
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.client.models
|
||||||
|
|
||||||
|
|
||||||
|
import com.squareup.moshi.Json
|
||||||
|
/**
|
||||||
|
* Describes the result of uploading an image resource
|
||||||
|
* @param code
|
||||||
|
* @param type
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
|
||||||
|
internal data class ApiResponse (
|
||||||
|
@Json(name = "code")
|
||||||
|
val code: kotlin.Int? = null,
|
||||||
|
@Json(name = "type")
|
||||||
|
val type: kotlin.String? = null,
|
||||||
|
@Json(name = "message")
|
||||||
|
val message: kotlin.String? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.client.models
|
||||||
|
|
||||||
|
|
||||||
|
import com.squareup.moshi.Json
|
||||||
|
/**
|
||||||
|
* A category for a pet
|
||||||
|
* @param id
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
|
||||||
|
internal data class Category (
|
||||||
|
@Json(name = "id")
|
||||||
|
val id: kotlin.Long? = null,
|
||||||
|
@Json(name = "name")
|
||||||
|
val name: kotlin.String? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,55 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.client.models
|
||||||
|
|
||||||
|
|
||||||
|
import com.squareup.moshi.Json
|
||||||
|
/**
|
||||||
|
* An order for a pets from the pet store
|
||||||
|
* @param id
|
||||||
|
* @param petId
|
||||||
|
* @param quantity
|
||||||
|
* @param shipDate
|
||||||
|
* @param status Order Status
|
||||||
|
* @param complete
|
||||||
|
*/
|
||||||
|
|
||||||
|
internal data class Order (
|
||||||
|
@Json(name = "id")
|
||||||
|
val id: kotlin.Long? = null,
|
||||||
|
@Json(name = "petId")
|
||||||
|
val petId: kotlin.Long? = null,
|
||||||
|
@Json(name = "quantity")
|
||||||
|
val quantity: kotlin.Int? = null,
|
||||||
|
@Json(name = "shipDate")
|
||||||
|
val shipDate: java.time.LocalDateTime? = null,
|
||||||
|
/* Order Status */
|
||||||
|
@Json(name = "status")
|
||||||
|
val status: Order.Status? = null,
|
||||||
|
@Json(name = "complete")
|
||||||
|
val complete: kotlin.Boolean? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Order Status
|
||||||
|
* Values: placed,approved,delivered
|
||||||
|
*/
|
||||||
|
|
||||||
|
internal enum class Status(val value: kotlin.String){
|
||||||
|
@Json(name = "placed") placed("placed"),
|
||||||
|
@Json(name = "approved") approved("approved"),
|
||||||
|
@Json(name = "delivered") delivered("delivered");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.client.models
|
||||||
|
|
||||||
|
import org.openapitools.client.models.Category
|
||||||
|
import org.openapitools.client.models.Tag
|
||||||
|
|
||||||
|
import com.squareup.moshi.Json
|
||||||
|
/**
|
||||||
|
* A pet for sale in the pet store
|
||||||
|
* @param id
|
||||||
|
* @param category
|
||||||
|
* @param name
|
||||||
|
* @param photoUrls
|
||||||
|
* @param tags
|
||||||
|
* @param status pet status in the store
|
||||||
|
*/
|
||||||
|
|
||||||
|
internal data class Pet (
|
||||||
|
@Json(name = "name")
|
||||||
|
val name: kotlin.String,
|
||||||
|
@Json(name = "photoUrls")
|
||||||
|
val photoUrls: kotlin.Array<kotlin.String>,
|
||||||
|
@Json(name = "id")
|
||||||
|
val id: kotlin.Long? = null,
|
||||||
|
@Json(name = "category")
|
||||||
|
val category: Category? = null,
|
||||||
|
@Json(name = "tags")
|
||||||
|
val tags: kotlin.Array<Tag>? = null,
|
||||||
|
/* pet status in the store */
|
||||||
|
@Json(name = "status")
|
||||||
|
val status: Pet.Status? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* pet status in the store
|
||||||
|
* Values: available,pending,sold
|
||||||
|
*/
|
||||||
|
|
||||||
|
internal enum class Status(val value: kotlin.String){
|
||||||
|
@Json(name = "available") available("available"),
|
||||||
|
@Json(name = "pending") pending("pending"),
|
||||||
|
@Json(name = "sold") sold("sold");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.client.models
|
||||||
|
|
||||||
|
|
||||||
|
import com.squareup.moshi.Json
|
||||||
|
/**
|
||||||
|
* A tag for a pet
|
||||||
|
* @param id
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
|
||||||
|
internal data class Tag (
|
||||||
|
@Json(name = "id")
|
||||||
|
val id: kotlin.Long? = null,
|
||||||
|
@Json(name = "name")
|
||||||
|
val name: kotlin.String? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.client.models
|
||||||
|
|
||||||
|
|
||||||
|
import com.squareup.moshi.Json
|
||||||
|
/**
|
||||||
|
* A User who is purchasing from the pet store
|
||||||
|
* @param id
|
||||||
|
* @param username
|
||||||
|
* @param firstName
|
||||||
|
* @param lastName
|
||||||
|
* @param email
|
||||||
|
* @param password
|
||||||
|
* @param phone
|
||||||
|
* @param userStatus User Status
|
||||||
|
*/
|
||||||
|
|
||||||
|
internal data class User (
|
||||||
|
@Json(name = "id")
|
||||||
|
val id: kotlin.Long? = null,
|
||||||
|
@Json(name = "username")
|
||||||
|
val username: kotlin.String? = null,
|
||||||
|
@Json(name = "firstName")
|
||||||
|
val firstName: kotlin.String? = null,
|
||||||
|
@Json(name = "lastName")
|
||||||
|
val lastName: kotlin.String? = null,
|
||||||
|
@Json(name = "email")
|
||||||
|
val email: kotlin.String? = null,
|
||||||
|
@Json(name = "password")
|
||||||
|
val password: kotlin.String? = null,
|
||||||
|
@Json(name = "phone")
|
||||||
|
val phone: kotlin.String? = null,
|
||||||
|
/* User Status */
|
||||||
|
@Json(name = "userStatus")
|
||||||
|
val userStatus: kotlin.Int? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user