forked from loafle/openapi-generator-original
Merge remote-tracking branch 'origin/master' into 2.3.0
This commit is contained in:
commit
1da52bf8ba
@ -742,6 +742,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you
|
||||
- [FH Münster - University of Applied Sciences](http://www.fh-muenster.de)
|
||||
- [Fotition](https://www.fotition.com/)
|
||||
- [Gear Zero Network](https://www.gearzero.ca)
|
||||
- [General Electric](https://www.ge.com/)
|
||||
- [Germin8](http://www.germin8.com)
|
||||
- [GigaSpaces](http://www.gigaspaces.com)
|
||||
- [goTransverse](http://www.gotransverse.com/api)
|
||||
|
@ -125,16 +125,16 @@ public class KotlinClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
typeMapping.put("date-time", "java.time.LocalDateTime");
|
||||
typeMapping.put("date", "java.time.LocalDateTime");
|
||||
typeMapping.put("file", "java.io.File");
|
||||
typeMapping.put("array", "kotlin.collections.List");
|
||||
typeMapping.put("list", "kotlin.collections.List");
|
||||
typeMapping.put("array", "kotlin.Array");
|
||||
typeMapping.put("list", "kotlin.Array");
|
||||
typeMapping.put("map", "kotlin.collections.Map");
|
||||
typeMapping.put("object", "kotlin.Any");
|
||||
typeMapping.put("binary", "kotlin.Array<kotlin.Byte>");
|
||||
typeMapping.put("Date", "java.time.LocalDateTime");
|
||||
typeMapping.put("DateTime", "java.time.LocalDateTime");
|
||||
|
||||
instantiationTypes.put("array", "listOf");
|
||||
instantiationTypes.put("list", "listOf");
|
||||
instantiationTypes.put("array", "arrayOf");
|
||||
instantiationTypes.put("list", "arrayOf");
|
||||
instantiationTypes.put("map", "mapOf");
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
@ -241,6 +241,7 @@ public class KotlinClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
final String infrastructureFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", "/");
|
||||
|
||||
supportingFiles.add(new SupportingFile("infrastructure/ApiClient.kt.mustache", infrastructureFolder, "ApiClient.kt"));
|
||||
supportingFiles.add(new SupportingFile("infrastructure/ApiAbstractions.kt.mustache", infrastructureFolder, "ApiAbstractions.kt"));
|
||||
supportingFiles.add(new SupportingFile("infrastructure/ApiInfrastructureResponse.kt.mustache", infrastructureFolder, "ApiInfrastructureResponse.kt"));
|
||||
supportingFiles.add(new SupportingFile("infrastructure/ApplicationDelegates.kt.mustache", infrastructureFolder, "ApplicationDelegates.kt"));
|
||||
supportingFiles.add(new SupportingFile("infrastructure/RequestConfig.kt.mustache", infrastructureFolder, "RequestConfig.kt"));
|
||||
|
@ -479,7 +479,7 @@ public class ApiClient {
|
||||
*/
|
||||
public boolean isJsonMime(String mime) {
|
||||
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
|
||||
return mime != null && mime.matches(jsonMime);
|
||||
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -443,7 +443,7 @@ public class ApiClient {
|
||||
*/
|
||||
public boolean isJsonMime(String mime) {
|
||||
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
|
||||
return mime != null && mime.matches(jsonMime);
|
||||
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -568,7 +568,7 @@ public class ApiClient {
|
||||
*/
|
||||
public boolean isJsonMime(String mime) {
|
||||
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
|
||||
return mime != null && mime.matches(jsonMime);
|
||||
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -225,6 +225,15 @@
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
{{/performBeanValidation}}
|
||||
{{#parcelableModel}}
|
||||
<!-- Needed for Parcelable support-->
|
||||
<dependency>
|
||||
<groupId>com.google.android</groupId>
|
||||
<artifactId>android</artifactId>
|
||||
<version>4.1.1.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
{{/parcelableModel}}
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -203,6 +203,16 @@
|
||||
<version>${jodatime-version}</version>
|
||||
</dependency>
|
||||
|
||||
{{#parcelableModel}}
|
||||
<!-- Needed for Parcelable support-->
|
||||
<dependency>
|
||||
<groupId>com.google.android</groupId>
|
||||
<artifactId>android</artifactId>
|
||||
<version>4.1.1.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
{{/parcelableModel}}
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -267,6 +267,16 @@
|
||||
</dependency>
|
||||
{{/usePlay24WS}}
|
||||
|
||||
{{#parcelableModel}}
|
||||
<!-- Needed for Parcelable support-->
|
||||
<dependency>
|
||||
<groupId>com.google.android</groupId>
|
||||
<artifactId>android</artifactId>
|
||||
<version>4.1.1.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
{{/parcelableModel}}
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -274,6 +274,17 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
{{/useBeanValidation}}
|
||||
|
||||
{{#parcelableModel}}
|
||||
<!-- Needed for Parcelable support-->
|
||||
<dependency>
|
||||
<groupId>com.google.android</groupId>
|
||||
<artifactId>android</artifactId>
|
||||
<version>4.1.1.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
{{/parcelableModel}}
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -2,6 +2,6 @@
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator}}", visible = true )
|
||||
@JsonSubTypes({
|
||||
{{#children}}
|
||||
@JsonSubTypes.Type(value = {{name}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"),
|
||||
@JsonSubTypes.Type(value = {{classname}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"),
|
||||
{{/children}}
|
||||
}){{/jackson}}
|
||||
|
@ -18,6 +18,7 @@ import java.io.InputStream;
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
@ -33,7 +34,28 @@ import javax.validation.constraints.*;
|
||||
{{>generatedAnnotation}}
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
private final {{classname}}Service delegate = {{classname}}ServiceFactory.get{{classname}}();
|
||||
private final {{classname}}Service delegate;
|
||||
|
||||
public {{classname}}(@Context ServletConfig servletContext) {
|
||||
{{classname}}Service delegate = null;
|
||||
|
||||
if (servletContext != null) {
|
||||
String implClass = servletContext.getInitParameter("{{classname}}.implementation");
|
||||
if (implClass != null && !"".equals(implClass.trim())) {
|
||||
try {
|
||||
delegate = ({{classname}}Service) Class.forName(implClass).newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (delegate == null) {
|
||||
delegate = {{classname}}ServiceFactory.get{{classname}}();
|
||||
}
|
||||
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
{{#operation}}
|
||||
@{{httpMethod}}
|
||||
|
@ -2,6 +2,6 @@
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator}}", visible = true )
|
||||
@JsonSubTypes({
|
||||
{{#children}}
|
||||
@JsonSubTypes.Type(value = {{name}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"),
|
||||
@JsonSubTypes.Type(value = {{classname}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"),
|
||||
{{/children}}
|
||||
}){{/jackson}}
|
||||
|
@ -2,6 +2,6 @@
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator}}", visible = true )
|
||||
@JsonSubTypes({
|
||||
{{#children}}
|
||||
@JsonSubTypes.Type(value = {{name}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"),
|
||||
@JsonSubTypes.Type(value = {{classname}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"),
|
||||
{{/children}}
|
||||
}){{/jackson}}
|
||||
|
@ -2,6 +2,6 @@
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator}}", visible = true )
|
||||
@JsonSubTypes({
|
||||
{{#children}}
|
||||
@JsonSubTypes.Type(value = {{name}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"),
|
||||
@JsonSubTypes.Type(value = {{classname}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"),
|
||||
{{/children}}
|
||||
}){{/jackson}}
|
||||
|
@ -434,6 +434,8 @@ export default class ApiClient {
|
||||
|
||||
if (returnType === 'Blob') {
|
||||
request.responseType('blob');
|
||||
} else if (returnType === 'String') {
|
||||
request.responseType('string');
|
||||
}
|
||||
|
||||
// Attach previously saved cookies, if enabled
|
||||
|
@ -19,7 +19,7 @@ class {{classname}}(basePath: kotlin.String = "{{{basePath}}}") : ApiClient(base
|
||||
@Suppress("UNCHECKED_CAST"){{/returnType}}
|
||||
fun {{operationId}}({{#allParams}}{{paramName}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}} {
|
||||
val localVariableBody: kotlin.Any? = {{#hasBodyParam}}{{#bodyParams}}{{paramName}}{{/bodyParams}}{{/hasBodyParam}}{{^hasBodyParam}}{{^hasFormParams}}null{{/hasFormParams}}{{#hasFormParams}}mapOf({{#formParams}}"{{{baseName}}}" to "${{paramName}}"{{#hasMore}}, {{/hasMore}}{{/formParams}}){{/hasFormParams}}{{/hasBodyParam}}
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = {{^hasQueryParams}}mapOf(){{/hasQueryParams}}{{#hasQueryParams}}mapOf({{#queryParams}}"{{paramName}}" to {{#isContainer}}{{paramName}}.joinToString(separator = collectionDelimiter("{{collectionFormat}}")){{/isContainer}}{{^isContainer}}{{paramName}}{{/isContainer}}{{#hasMore}}, {{/hasMore}}{{/queryParams}}){{/hasQueryParams}}
|
||||
val localVariableQuery: MultiValueMap = {{^hasQueryParams}}mapOf(){{/hasQueryParams}}{{#hasQueryParams}}mapOf({{#queryParams}}"{{paramName}}" to {{#isContainer}}toMultiValue({{paramName}}.toList(), "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf("${{paramName}}"){{/isContainer}}{{#hasMore}}, {{/hasMore}}{{/queryParams}}){{/hasQueryParams}}
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = {{^headerParams}}mapOf({{#hasFormParams}}"Content-Type" to "multipart/form-data"{{/hasFormParams}}){{/headerParams}}{{#headerParams}}mapOf("{{paramName}}" to {{#isContainer}}{{paramName}}.joinToString(separator = collectionDelimiter("{{collectionFormat}}")){{/isContainer}}{{^isContainer}}{{paramName}}{{/isContainer}}){{/headerParams}}
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.{{httpMethod}},
|
||||
@ -43,13 +43,5 @@ class {{classname}}(basePath: kotlin.String = "{{{basePath}}}") : ApiClient(base
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
|
||||
private fun collectionDelimiter(collectionFormat: kotlin.String) = when(collectionFormat) {
|
||||
"csv" -> ","
|
||||
"tsv" -> "\t"
|
||||
"pipes" -> "|"
|
||||
"ssv" -> " "
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
{{/operations}}
|
@ -0,0 +1,20 @@
|
||||
package {{packageName}}.infrastructure
|
||||
|
||||
typealias MultiValueMap = Map<String,List<String>>
|
||||
|
||||
fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
|
||||
"csv" -> ","
|
||||
"tsv" -> "\t"
|
||||
"pipes" -> "|"
|
||||
"ssv" -> " "
|
||||
else -> ""
|
||||
}
|
||||
|
||||
val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
|
||||
|
||||
fun <T: Any?> toMultiValue(items: List<T>, collectionFormat: String, map: (item: Any?) -> String = defaultMultiValueConverter): List<String> {
|
||||
return when(collectionFormat) {
|
||||
"multi" -> items.map(map)
|
||||
else -> listOf(items.map(map).joinToString(separator = collectionDelimiter(collectionFormat)))
|
||||
}
|
||||
}
|
@ -60,7 +60,11 @@ open class ApiClient(val baseUrl: String) {
|
||||
var urlBuilder = httpUrl.newBuilder()
|
||||
.addPathSegments(requestConfig.path.trimStart('/'))
|
||||
|
||||
requestConfig.query.forEach { k, v -> urlBuilder = urlBuilder.addQueryParameter(k,v) }
|
||||
requestConfig.query.forEach { k, v ->
|
||||
v.forEach { queryValue ->
|
||||
urlBuilder = urlBuilder.addQueryParameter(k,queryValue)
|
||||
}
|
||||
}
|
||||
|
||||
val url = urlBuilder.build()
|
||||
val headers = requestConfig.headers + defaultHeaders
|
||||
@ -73,6 +77,7 @@ open class ApiClient(val baseUrl: String) {
|
||||
throw kotlin.IllegalStateException("Missing Accept header. This is required.")
|
||||
}
|
||||
|
||||
// TODO: support multiple contentType,accept options here.
|
||||
val contentType = (headers[ContentType] as String).substringBefore(";").toLowerCase()
|
||||
val accept = (headers[Accept] as String).substringBefore(";").toLowerCase()
|
||||
|
||||
|
@ -5,9 +5,11 @@ package {{packageName}}.infrastructure
|
||||
* 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.
|
||||
*/
|
||||
data class RequestConfig(
|
||||
val method: RequestMethod,
|
||||
val path: String,
|
||||
val headers: Map<String, String> = mapOf(),
|
||||
val query: Map<String, String> = mapOf())
|
||||
val query: Map<String, List<String>> = mapOf())
|
@ -104,10 +104,10 @@ public class KotlinClientCodegenModelTest {
|
||||
Assert.assertEquals(property.baseName, "examples");
|
||||
Assert.assertEquals(property.getter, "getExamples");
|
||||
Assert.assertEquals(property.setter, "setExamples");
|
||||
Assert.assertEquals(property.datatype, "kotlin.collections.List<kotlin.String>");
|
||||
Assert.assertEquals(property.datatype, "kotlin.Array<kotlin.String>");
|
||||
Assert.assertEquals(property.name, "examples");
|
||||
Assert.assertEquals(property.defaultValue, "null");
|
||||
Assert.assertEquals(property.baseType, "kotlin.collections.List");
|
||||
Assert.assertEquals(property.baseType, "kotlin.Array");
|
||||
Assert.assertEquals(property.containerType, "array");
|
||||
Assert.assertFalse(property.required);
|
||||
Assert.assertTrue(property.isContainer);
|
||||
|
24
pom.xml
24
pom.xml
@ -791,17 +791,12 @@
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<!-- servers -->
|
||||
<module>samples/server/petstore/scalatra</module>
|
||||
<!-- <module>samples/server/petstore/erlang-server</module> note: make sample compilation work -->
|
||||
<!-- clients -->
|
||||
<module>samples/client/petstore/ruby</module>
|
||||
<module>samples/client/petstore/swift3/default/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/swift3/promisekit/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/swift3/rxswift/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/swift/default/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/swift/promisekit/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/swift/rxswift/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/objc/default/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/objc/core-data/SwaggerClientTests</module>
|
||||
<!--<module>samples/client/petstore/bash</module>-->
|
||||
<module>samples/client/petstore/ruby</module>
|
||||
<module>samples/client/petstore/scala</module>
|
||||
<module>samples/client/petstore/akka-scala</module>
|
||||
<module>samples/client/petstore/javascript</module>
|
||||
@ -813,9 +808,14 @@
|
||||
<module>samples/client/petstore/typescript-angular</module>
|
||||
<module>samples/client/petstore/typescript-node/npm</module>
|
||||
<module>samples/client/petstore/typescript-jquery/npm</module>
|
||||
<!-- servers -->
|
||||
<module>samples/server/petstore/scalatra</module>
|
||||
<!-- <module>samples/server/petstore/erlang-server</module> note: make sample compilation work -->
|
||||
<module>samples/client/petstore/swift3/default/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/swift3/promisekit/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/swift3/rxswift/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/swift/default/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/swift/promisekit/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/swift/rxswift/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/objc/default/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/objc/core-data/SwaggerClientTests</module>
|
||||
</modules>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
@ -750,7 +750,7 @@ public class ApiClient {
|
||||
*/
|
||||
public boolean isJsonMime(String mime) {
|
||||
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
|
||||
return mime != null && mime.matches(jsonMime);
|
||||
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -230,6 +230,8 @@
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -472,7 +472,7 @@ public class ApiClient {
|
||||
*/
|
||||
public boolean isJsonMime(String mime) {
|
||||
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
|
||||
return mime != null && mime.matches(jsonMime);
|
||||
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -437,7 +437,7 @@ public class ApiClient {
|
||||
*/
|
||||
public boolean isJsonMime(String mime) {
|
||||
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
|
||||
return mime != null && mime.matches(jsonMime);
|
||||
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -438,7 +438,7 @@ public class ApiClient {
|
||||
*/
|
||||
public boolean isJsonMime(String mime) {
|
||||
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
|
||||
return mime != null && mime.matches(jsonMime);
|
||||
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -438,7 +438,7 @@ public class ApiClient {
|
||||
*/
|
||||
public boolean isJsonMime(String mime) {
|
||||
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
|
||||
return mime != null && mime.matches(jsonMime);
|
||||
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,22 +71,12 @@ public class FakeApiExample {
|
||||
public static void main(String[] args) {
|
||||
|
||||
FakeApi apiInstance = new FakeApi();
|
||||
BigDecimal number = new BigDecimal(); // BigDecimal | None
|
||||
Double _double = 3.4D; // Double | None
|
||||
String string = "string_example"; // String | None
|
||||
byte[] _byte = B; // byte[] | None
|
||||
Integer integer = 56; // Integer | None
|
||||
Integer int32 = 56; // Integer | None
|
||||
Long int64 = 789L; // Long | None
|
||||
Float _float = 3.4F; // Float | None
|
||||
byte[] binary = B; // byte[] | None
|
||||
LocalDate date = new LocalDate(); // LocalDate | None
|
||||
DateTime dateTime = new DateTime(); // DateTime | None
|
||||
String password = "password_example"; // String | None
|
||||
Boolean body = true; // Boolean | Input boolean as post body
|
||||
try {
|
||||
apiInstance.testEndpointParameters(number, _double, string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
|
||||
Boolean result = apiInstance.fakeOuterBooleanSerialize(body);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling FakeApi#testEndpointParameters");
|
||||
System.err.println("Exception when calling FakeApi#fakeOuterBooleanSerialize");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -96,12 +86,17 @@ public class FakeApiExample {
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean |
|
||||
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite |
|
||||
*FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number |
|
||||
*FakeApi* | [**fakeOuterStringSerialize**](docs/FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string |
|
||||
*FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model
|
||||
*FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
*FakeApi* | [**testEnumQueryParameters**](docs/FakeApi.md#testEnumQueryParameters) | **GET** /fake | To test enum query parameters
|
||||
*FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters
|
||||
*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
|
||||
@ -110,9 +105,9 @@ Class | Method | HTTP request | Description
|
||||
*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* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
|
||||
*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
|
||||
*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID
|
||||
*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet
|
||||
*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
|
||||
@ -132,9 +127,11 @@ Class | Method | HTTP request | Description
|
||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||
- [ArrayTest](docs/ArrayTest.md)
|
||||
- [Cat](docs/Cat.md)
|
||||
- [Capitalization](docs/Capitalization.md)
|
||||
- [Category](docs/Category.md)
|
||||
- [Dog](docs/Dog.md)
|
||||
- [ClassModel](docs/ClassModel.md)
|
||||
- [Client](docs/Client.md)
|
||||
- [EnumArrays](docs/EnumArrays.md)
|
||||
- [EnumClass](docs/EnumClass.md)
|
||||
- [EnumTest](docs/EnumTest.md)
|
||||
- [FormatTest](docs/FormatTest.md)
|
||||
@ -147,11 +144,15 @@ Class | Method | HTTP request | Description
|
||||
- [Name](docs/Name.md)
|
||||
- [NumberOnly](docs/NumberOnly.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [OuterComposite](docs/OuterComposite.md)
|
||||
- [OuterEnum](docs/OuterEnum.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||
- [SpecialModelName](docs/SpecialModelName.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [User](docs/User.md)
|
||||
- [Cat](docs/Cat.md)
|
||||
- [Dog](docs/Dog.md)
|
||||
|
||||
|
||||
## Documentation for Authorization
|
||||
@ -163,6 +164,10 @@ Authentication schemes defined for the API:
|
||||
- **API key parameter name**: api_key
|
||||
- **Location**: HTTP header
|
||||
|
||||
### http_basic_test
|
||||
|
||||
- **Type**: HTTP basic authentication
|
||||
|
||||
### petstore_auth
|
||||
|
||||
- **Type**: OAuth
|
||||
@ -175,7 +180,7 @@ Authentication schemes defined for the API:
|
||||
|
||||
## Recommendation
|
||||
|
||||
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue.
|
||||
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
|
||||
|
||||
## Author
|
||||
|
||||
|
@ -1,52 +0,0 @@
|
||||
# FakeclassnametagsApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**testClassname**](FakeclassnametagsApi.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
|
||||
|
||||
|
||||
<a name="testClassname"></a>
|
||||
# **testClassname**
|
||||
> Client testClassname(body)
|
||||
|
||||
To test class name in snake case
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
//import io.swagger.client.ApiException;
|
||||
//import io.swagger.client.api.FakeclassnametagsApi;
|
||||
|
||||
|
||||
FakeclassnametagsApi apiInstance = new FakeclassnametagsApi();
|
||||
Client body = new Client(); // Client | client model
|
||||
try {
|
||||
Client result = apiInstance.testClassname(body);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling FakeclassnametagsApi#testClassname");
|
||||
e.printStackTrace();
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Client**](Client.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Client**](Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
@ -194,6 +194,13 @@
|
||||
<artifactId>threetenbp</artifactId>
|
||||
<version>${threetenbp-version}</version>
|
||||
</dependency>
|
||||
<!-- Needed for Parcelable support-->
|
||||
<dependency>
|
||||
<groupId>com.google.android</groupId>
|
||||
<artifactId>android</artifactId>
|
||||
<version>4.1.1.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -549,7 +549,7 @@ public class ApiClient {
|
||||
*/
|
||||
public boolean isJsonMime(String mime) {
|
||||
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
|
||||
return mime != null && mime.matches(jsonMime);
|
||||
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,8 +34,6 @@ public class ProgressRequestBody extends RequestBody {
|
||||
|
||||
private final ProgressRequestListener progressListener;
|
||||
|
||||
private BufferedSink bufferedSink;
|
||||
|
||||
public ProgressRequestBody(RequestBody requestBody, ProgressRequestListener progressListener) {
|
||||
this.requestBody = requestBody;
|
||||
this.progressListener = progressListener;
|
||||
@ -53,13 +51,9 @@ public class ProgressRequestBody extends RequestBody {
|
||||
|
||||
@Override
|
||||
public void writeTo(BufferedSink sink) throws IOException {
|
||||
if (bufferedSink == null) {
|
||||
bufferedSink = Okio.buffer(sink(sink));
|
||||
}
|
||||
|
||||
BufferedSink bufferedSink = Okio.buffer(sink(sink));
|
||||
requestBody.writeTo(bufferedSink);
|
||||
bufferedSink.flush();
|
||||
|
||||
}
|
||||
|
||||
private Sink sink(Sink sink) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Swagger Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
@ -8,28 +8,19 @@
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package io.swagger.client.api;
|
||||
|
||||
import io.swagger.client.ApiException;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.DateTime;
|
||||
import java.math.BigDecimal;
|
||||
import io.swagger.client.model.Client;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
import io.swagger.client.model.OuterComposite;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -39,11 +30,92 @@ import java.util.Map;
|
||||
/**
|
||||
* API tests for FakeApi
|
||||
*/
|
||||
@Ignore
|
||||
public class FakeApiTest {
|
||||
|
||||
private final FakeApi api = new FakeApi();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Test serialization of outer boolean types
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void fakeOuterBooleanSerializeTest() throws ApiException {
|
||||
Boolean body = null;
|
||||
Boolean response = api.fakeOuterBooleanSerialize(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Test serialization of object with outer number type
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void fakeOuterCompositeSerializeTest() throws ApiException {
|
||||
OuterComposite body = null;
|
||||
OuterComposite response = api.fakeOuterCompositeSerialize(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Test serialization of outer number types
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void fakeOuterNumberSerializeTest() throws ApiException {
|
||||
BigDecimal body = null;
|
||||
BigDecimal response = api.fakeOuterNumberSerialize(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Test serialization of outer string types
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void fakeOuterStringSerializeTest() throws ApiException {
|
||||
String body = null;
|
||||
String response = api.fakeOuterStringSerialize(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test \"client\" model
|
||||
*
|
||||
* To test \"client\" model
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void testClientModelTest() throws ApiException {
|
||||
Client body = null;
|
||||
Client response = api.testClientModel(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
*
|
||||
@ -56,35 +128,42 @@ public class FakeApiTest {
|
||||
public void testEndpointParametersTest() throws ApiException {
|
||||
BigDecimal number = null;
|
||||
Double _double = null;
|
||||
String string = null;
|
||||
String patternWithoutDelimiter = null;
|
||||
byte[] _byte = null;
|
||||
Integer integer = null;
|
||||
Integer int32 = null;
|
||||
Long int64 = null;
|
||||
Float _float = null;
|
||||
String string = null;
|
||||
byte[] binary = null;
|
||||
LocalDate date = null;
|
||||
DateTime dateTime = null;
|
||||
String password = null;
|
||||
// api.testEndpointParameters(number, _double, string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
|
||||
String paramCallback = null;
|
||||
api.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test enum query parameters
|
||||
* To test enum parameters
|
||||
*
|
||||
*
|
||||
* To test enum parameters
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void testEnumQueryParametersTest() throws ApiException {
|
||||
public void testEnumParametersTest() throws ApiException {
|
||||
List<String> enumFormStringArray = null;
|
||||
String enumFormString = null;
|
||||
List<String> enumHeaderStringArray = null;
|
||||
String enumHeaderString = null;
|
||||
List<String> enumQueryStringArray = null;
|
||||
String enumQueryString = null;
|
||||
BigDecimal enumQueryInteger = null;
|
||||
Integer enumQueryInteger = null;
|
||||
Double enumQueryDouble = null;
|
||||
// api.testEnumQueryParameters(enumQueryString, enumQueryInteger, enumQueryDouble);
|
||||
api.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package io.swagger.client.api;
|
||||
|
||||
import io.swagger.client.ApiException;
|
||||
import io.swagger.client.model.Client;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* API tests for FakeclassnametagsApi
|
||||
*/
|
||||
public class FakeclassnametagsApiTest {
|
||||
|
||||
private final FakeclassnametagsApi api = new FakeclassnametagsApi();
|
||||
|
||||
|
||||
/**
|
||||
* To test class name in snake case
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void testClassnameTest() throws ApiException {
|
||||
Client body = null;
|
||||
// Client response = api.testClassname(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Swagger Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
@ -8,28 +8,17 @@
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package io.swagger.client.api;
|
||||
|
||||
import io.swagger.client.ApiException;
|
||||
import io.swagger.client.model.Pet;
|
||||
import java.io.File;
|
||||
import io.swagger.client.model.ModelApiResponse;
|
||||
import io.swagger.client.model.Pet;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -39,6 +28,7 @@ import java.util.Map;
|
||||
/**
|
||||
* API tests for PetApi
|
||||
*/
|
||||
@Ignore
|
||||
public class PetApiTest {
|
||||
|
||||
private final PetApi api = new PetApi();
|
||||
@ -55,7 +45,7 @@ public class PetApiTest {
|
||||
@Test
|
||||
public void addPetTest() throws ApiException {
|
||||
Pet body = null;
|
||||
// api.addPet(body);
|
||||
api.addPet(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -72,7 +62,7 @@ public class PetApiTest {
|
||||
public void deletePetTest() throws ApiException {
|
||||
Long petId = null;
|
||||
String apiKey = null;
|
||||
// api.deletePet(petId, apiKey);
|
||||
api.deletePet(petId, apiKey);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -88,7 +78,7 @@ public class PetApiTest {
|
||||
@Test
|
||||
public void findPetsByStatusTest() throws ApiException {
|
||||
List<String> status = null;
|
||||
// List<Pet> response = api.findPetsByStatus(status);
|
||||
List<Pet> response = api.findPetsByStatus(status);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -104,7 +94,7 @@ public class PetApiTest {
|
||||
@Test
|
||||
public void findPetsByTagsTest() throws ApiException {
|
||||
List<String> tags = null;
|
||||
// List<Pet> response = api.findPetsByTags(tags);
|
||||
List<Pet> response = api.findPetsByTags(tags);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -120,7 +110,7 @@ public class PetApiTest {
|
||||
@Test
|
||||
public void getPetByIdTest() throws ApiException {
|
||||
Long petId = null;
|
||||
// Pet response = api.getPetById(petId);
|
||||
Pet response = api.getPetById(petId);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -136,7 +126,7 @@ public class PetApiTest {
|
||||
@Test
|
||||
public void updatePetTest() throws ApiException {
|
||||
Pet body = null;
|
||||
// api.updatePet(body);
|
||||
api.updatePet(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -154,7 +144,7 @@ public class PetApiTest {
|
||||
Long petId = null;
|
||||
String name = null;
|
||||
String status = null;
|
||||
// api.updatePetWithForm(petId, name, status);
|
||||
api.updatePetWithForm(petId, name, status);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -172,7 +162,7 @@ public class PetApiTest {
|
||||
Long petId = null;
|
||||
String additionalMetadata = null;
|
||||
File file = null;
|
||||
// ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file);
|
||||
ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Swagger Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
@ -8,18 +8,6 @@
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
@ -28,6 +16,7 @@ package io.swagger.client.api;
|
||||
import io.swagger.client.ApiException;
|
||||
import io.swagger.client.model.Order;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -37,6 +26,7 @@ import java.util.Map;
|
||||
/**
|
||||
* API tests for StoreApi
|
||||
*/
|
||||
@Ignore
|
||||
public class StoreApiTest {
|
||||
|
||||
private final StoreApi api = new StoreApi();
|
||||
@ -53,7 +43,7 @@ public class StoreApiTest {
|
||||
@Test
|
||||
public void deleteOrderTest() throws ApiException {
|
||||
String orderId = null;
|
||||
// api.deleteOrder(orderId);
|
||||
api.deleteOrder(orderId);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -68,7 +58,7 @@ public class StoreApiTest {
|
||||
*/
|
||||
@Test
|
||||
public void getInventoryTest() throws ApiException {
|
||||
// Map<String, Integer> response = api.getInventory();
|
||||
Map<String, Integer> response = api.getInventory();
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -84,7 +74,7 @@ public class StoreApiTest {
|
||||
@Test
|
||||
public void getOrderByIdTest() throws ApiException {
|
||||
Long orderId = null;
|
||||
// Order response = api.getOrderById(orderId);
|
||||
Order response = api.getOrderById(orderId);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -100,7 +90,7 @@ public class StoreApiTest {
|
||||
@Test
|
||||
public void placeOrderTest() throws ApiException {
|
||||
Order body = null;
|
||||
// Order response = api.placeOrder(body);
|
||||
Order response = api.placeOrder(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Swagger Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
@ -8,18 +8,6 @@
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
@ -28,6 +16,7 @@ package io.swagger.client.api;
|
||||
import io.swagger.client.ApiException;
|
||||
import io.swagger.client.model.User;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -37,6 +26,7 @@ import java.util.Map;
|
||||
/**
|
||||
* API tests for UserApi
|
||||
*/
|
||||
@Ignore
|
||||
public class UserApiTest {
|
||||
|
||||
private final UserApi api = new UserApi();
|
||||
@ -53,7 +43,7 @@ public class UserApiTest {
|
||||
@Test
|
||||
public void createUserTest() throws ApiException {
|
||||
User body = null;
|
||||
// api.createUser(body);
|
||||
api.createUser(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -69,7 +59,7 @@ public class UserApiTest {
|
||||
@Test
|
||||
public void createUsersWithArrayInputTest() throws ApiException {
|
||||
List<User> body = null;
|
||||
// api.createUsersWithArrayInput(body);
|
||||
api.createUsersWithArrayInput(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -85,7 +75,7 @@ public class UserApiTest {
|
||||
@Test
|
||||
public void createUsersWithListInputTest() throws ApiException {
|
||||
List<User> body = null;
|
||||
// api.createUsersWithListInput(body);
|
||||
api.createUsersWithListInput(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -101,7 +91,7 @@ public class UserApiTest {
|
||||
@Test
|
||||
public void deleteUserTest() throws ApiException {
|
||||
String username = null;
|
||||
// api.deleteUser(username);
|
||||
api.deleteUser(username);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -117,7 +107,7 @@ public class UserApiTest {
|
||||
@Test
|
||||
public void getUserByNameTest() throws ApiException {
|
||||
String username = null;
|
||||
// User response = api.getUserByName(username);
|
||||
User response = api.getUserByName(username);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -134,7 +124,7 @@ public class UserApiTest {
|
||||
public void loginUserTest() throws ApiException {
|
||||
String username = null;
|
||||
String password = null;
|
||||
// String response = api.loginUser(username, password);
|
||||
String response = api.loginUser(username, password);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -149,7 +139,7 @@ public class UserApiTest {
|
||||
*/
|
||||
@Test
|
||||
public void logoutUserTest() throws ApiException {
|
||||
// api.logoutUser();
|
||||
api.logoutUser();
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@ -166,7 +156,7 @@ public class UserApiTest {
|
||||
public void updateUserTest() throws ApiException {
|
||||
String username = null;
|
||||
User body = null;
|
||||
// api.updateUser(username, body);
|
||||
api.updateUser(username, body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
@ -549,7 +549,7 @@ public class ApiClient {
|
||||
*/
|
||||
public boolean isJsonMime(String mime) {
|
||||
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
|
||||
return mime != null && mime.matches(jsonMime);
|
||||
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,6 +43,8 @@ public class ApiClientTest {
|
||||
assertTrue(apiClient.isJsonMime("example/foo+json;x;y"));
|
||||
assertTrue(apiClient.isJsonMime("example/foo+json\t;"));
|
||||
assertTrue(apiClient.isJsonMime("Example/fOO+JSON"));
|
||||
|
||||
assertTrue(apiClient.isJsonMime("application/json-patch+json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -203,6 +203,7 @@
|
||||
<version>${jodatime-version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -232,6 +232,7 @@
|
||||
<version>${play-version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -201,6 +201,7 @@
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -211,6 +211,7 @@
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -211,6 +211,7 @@
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -7,8 +7,8 @@ Name | Type | Description | Notes
|
||||
**id** | **kotlin.Long** | | [optional]
|
||||
**category** | [**Category**](Category.md) | | [optional]
|
||||
**name** | **kotlin.String** | |
|
||||
**photoUrls** | **kotlin.collections.List<kotlin.String>** | |
|
||||
**tags** | [**kotlin.collections.List<Tag>**](Tag.md) | | [optional]
|
||||
**photoUrls** | **kotlin.Array<kotlin.String>** | |
|
||||
**tags** | [**kotlin.Array<Tag>**](Tag.md) | | [optional]
|
||||
**status** | [**inline**](#StatusEnum) | pet status in the store | [optional]
|
||||
|
||||
|
||||
|
@ -110,7 +110,7 @@ null (empty response body)
|
||||
|
||||
<a name="findPetsByStatus"></a>
|
||||
# **findPetsByStatus**
|
||||
> kotlin.collections.List<Pet> findPetsByStatus(status)
|
||||
> kotlin.Array<Pet> findPetsByStatus(status)
|
||||
|
||||
Finds Pets by status
|
||||
|
||||
@ -123,9 +123,9 @@ Multiple status values can be provided with comma separated strings
|
||||
//import io.swagger.client.models.*
|
||||
|
||||
val apiInstance = PetApi()
|
||||
val status : kotlin.collections.List<kotlin.String> = // kotlin.collections.List<kotlin.String> | Status values that need to be considered for filter
|
||||
val status : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Status values that need to be considered for filter
|
||||
try {
|
||||
val result : kotlin.collections.List<Pet> = apiInstance.findPetsByStatus(status)
|
||||
val result : kotlin.Array<Pet> = apiInstance.findPetsByStatus(status)
|
||||
println(result)
|
||||
} catch (e: ClientException) {
|
||||
println("4xx response calling PetApi#findPetsByStatus")
|
||||
@ -140,11 +140,11 @@ try {
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**status** | [**kotlin.collections.List<kotlin.String>**](kotlin.String.md)| Status values that need to be considered for filter | [enum: available, pending, sold]
|
||||
**status** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Status values that need to be considered for filter | [enum: available, pending, sold]
|
||||
|
||||
### Return type
|
||||
|
||||
[**kotlin.collections.List<Pet>**](Pet.md)
|
||||
[**kotlin.Array<Pet>**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@ -157,7 +157,7 @@ Name | Type | Description | Notes
|
||||
|
||||
<a name="findPetsByTags"></a>
|
||||
# **findPetsByTags**
|
||||
> kotlin.collections.List<Pet> findPetsByTags(tags)
|
||||
> kotlin.Array<Pet> findPetsByTags(tags)
|
||||
|
||||
Finds Pets by tags
|
||||
|
||||
@ -170,9 +170,9 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3
|
||||
//import io.swagger.client.models.*
|
||||
|
||||
val apiInstance = PetApi()
|
||||
val tags : kotlin.collections.List<kotlin.String> = // kotlin.collections.List<kotlin.String> | Tags to filter by
|
||||
val tags : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Tags to filter by
|
||||
try {
|
||||
val result : kotlin.collections.List<Pet> = apiInstance.findPetsByTags(tags)
|
||||
val result : kotlin.Array<Pet> = apiInstance.findPetsByTags(tags)
|
||||
println(result)
|
||||
} catch (e: ClientException) {
|
||||
println("4xx response calling PetApi#findPetsByTags")
|
||||
@ -187,11 +187,11 @@ try {
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**tags** | [**kotlin.collections.List<kotlin.String>**](kotlin.String.md)| Tags to filter by |
|
||||
**tags** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Tags to filter by |
|
||||
|
||||
### Return type
|
||||
|
||||
[**kotlin.collections.List<Pet>**](Pet.md)
|
||||
[**kotlin.Array<Pet>**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
|
@ -75,7 +75,7 @@ Creates list of users with given input array
|
||||
//import io.swagger.client.models.*
|
||||
|
||||
val apiInstance = UserApi()
|
||||
val body : kotlin.collections.List<User> = // kotlin.collections.List<User> | List of user object
|
||||
val body : kotlin.Array<User> = // kotlin.Array<User> | List of user object
|
||||
try {
|
||||
apiInstance.createUsersWithArrayInput(body)
|
||||
} catch (e: ClientException) {
|
||||
@ -91,7 +91,7 @@ try {
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**kotlin.collections.List<User>**](User.md)| List of user object |
|
||||
**body** | [**kotlin.Array<User>**](User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
@ -121,7 +121,7 @@ Creates list of users with given input array
|
||||
//import io.swagger.client.models.*
|
||||
|
||||
val apiInstance = UserApi()
|
||||
val body : kotlin.collections.List<User> = // kotlin.collections.List<User> | List of user object
|
||||
val body : kotlin.Array<User> = // kotlin.Array<User> | List of user object
|
||||
try {
|
||||
apiInstance.createUsersWithListInput(body)
|
||||
} catch (e: ClientException) {
|
||||
@ -137,7 +137,7 @@ try {
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**kotlin.collections.List<User>**](User.md)| List of user object |
|
||||
**body** | [**kotlin.Array<User>**](User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
|
@ -26,7 +26,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun addPet(body: Pet) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -58,7 +58,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun deletePet(petId: kotlin.Long, apiKey: kotlin.String) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf("apiKey" to apiKey)
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -85,12 +85,12 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
* Finds Pets by status
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
* @param status Status values that need to be considered for filter
|
||||
* @return kotlin.collections.List<Pet>
|
||||
* @return kotlin.Array<Pet>
|
||||
*/
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun findPetsByStatus(status: kotlin.collections.List<kotlin.String>) : kotlin.collections.List<Pet> {
|
||||
fun findPetsByStatus(status: kotlin.Array<kotlin.String>) : kotlin.Array<Pet> {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf("status" to status.joinToString(separator = collectionDelimiter("csv")))
|
||||
val localVariableQuery: MultiValueMap = mapOf("status" to toMultiValue(status.toList(), "csv"))
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -98,13 +98,13 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders
|
||||
)
|
||||
val response = request<kotlin.collections.List<Pet>>(
|
||||
val response = request<kotlin.Array<Pet>>(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
)
|
||||
|
||||
return when (response.responseType) {
|
||||
ResponseType.Success -> (response as Success<*>).data as kotlin.collections.List<Pet>
|
||||
ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Pet>
|
||||
ResponseType.Informational -> TODO()
|
||||
ResponseType.Redirection -> TODO()
|
||||
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||
@ -117,12 +117,12 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
* Finds Pets by tags
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
* @param tags Tags to filter by
|
||||
* @return kotlin.collections.List<Pet>
|
||||
* @return kotlin.Array<Pet>
|
||||
*/
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun findPetsByTags(tags: kotlin.collections.List<kotlin.String>) : kotlin.collections.List<Pet> {
|
||||
fun findPetsByTags(tags: kotlin.Array<kotlin.String>) : kotlin.Array<Pet> {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf("tags" to tags.joinToString(separator = collectionDelimiter("csv")))
|
||||
val localVariableQuery: MultiValueMap = mapOf("tags" to toMultiValue(tags.toList(), "csv"))
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -130,13 +130,13 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders
|
||||
)
|
||||
val response = request<kotlin.collections.List<Pet>>(
|
||||
val response = request<kotlin.Array<Pet>>(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
)
|
||||
|
||||
return when (response.responseType) {
|
||||
ResponseType.Success -> (response as Success<*>).data as kotlin.collections.List<Pet>
|
||||
ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Pet>
|
||||
ResponseType.Informational -> TODO()
|
||||
ResponseType.Redirection -> TODO()
|
||||
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
|
||||
@ -154,7 +154,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getPetById(petId: kotlin.Long) : Pet {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -185,7 +185,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun updatePet(body: Pet) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.PUT,
|
||||
@ -218,7 +218,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
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: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf("Content-Type" to "multipart/form-data")
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -252,7 +252,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
@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: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf("Content-Type" to "multipart/form-data")
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -275,12 +275,4 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun collectionDelimiter(collectionFormat: kotlin.String) = when(collectionFormat) {
|
||||
"csv" -> ","
|
||||
"tsv" -> "\t"
|
||||
"pipes" -> "|"
|
||||
"ssv" -> " "
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
*/
|
||||
fun deleteOrder(orderId: kotlin.String) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -56,7 +56,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getInventory() : kotlin.collections.Map<kotlin.String, kotlin.Int> {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -88,7 +88,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getOrderById(orderId: kotlin.Long) : Order {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -120,7 +120,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun placeOrder(body: Order) : Order {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -143,12 +143,4 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun collectionDelimiter(collectionFormat: kotlin.String) = when(collectionFormat) {
|
||||
"csv" -> ","
|
||||
"tsv" -> "\t"
|
||||
"pipes" -> "|"
|
||||
"ssv" -> " "
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun createUser(body: User) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -54,9 +54,9 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
* @param body List of user object
|
||||
* @return void
|
||||
*/
|
||||
fun createUsersWithArrayInput(body: kotlin.collections.List<User>) : Unit {
|
||||
fun createUsersWithArrayInput(body: kotlin.Array<User>) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -85,9 +85,9 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
* @param body List of user object
|
||||
* @return void
|
||||
*/
|
||||
fun createUsersWithListInput(body: kotlin.collections.List<User>) : Unit {
|
||||
fun createUsersWithListInput(body: kotlin.Array<User>) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -118,7 +118,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun deleteUser(username: kotlin.String) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -150,7 +150,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getUserByName(username: kotlin.String) : User {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -183,7 +183,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun loginUser(username: kotlin.String, password: kotlin.String) : kotlin.String {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf("username" to username, "password" to password)
|
||||
val localVariableQuery: MultiValueMap = mapOf("username" to listOf("$username"), "password" to listOf("$password"))
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -213,7 +213,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun logoutUser() : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -245,7 +245,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun updateUser(username: kotlin.String, body: User) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.PUT,
|
||||
@ -268,12 +268,4 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun collectionDelimiter(collectionFormat: kotlin.String) = when(collectionFormat) {
|
||||
"csv" -> ","
|
||||
"tsv" -> "\t"
|
||||
"pipes" -> "|"
|
||||
"ssv" -> " "
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package io.swagger.client.infrastructure
|
||||
|
||||
typealias MultiValueMap = Map<String,List<String>>
|
||||
|
||||
fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
|
||||
"csv" -> ","
|
||||
"tsv" -> "\t"
|
||||
"pipes" -> "|"
|
||||
"ssv" -> " "
|
||||
else -> ""
|
||||
}
|
||||
|
||||
val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
|
||||
|
||||
fun <T: Any?> toMultiValue(items: List<T>, collectionFormat: String, map: (item: Any?) -> String = defaultMultiValueConverter): List<String> {
|
||||
return when(collectionFormat) {
|
||||
"multi" -> items.map(map)
|
||||
else -> listOf(items.map(map).joinToString(separator = collectionDelimiter(collectionFormat)))
|
||||
}
|
||||
}
|
@ -60,7 +60,11 @@ open class ApiClient(val baseUrl: String) {
|
||||
var urlBuilder = httpUrl.newBuilder()
|
||||
.addPathSegments(requestConfig.path.trimStart('/'))
|
||||
|
||||
requestConfig.query.forEach { k, v -> urlBuilder = urlBuilder.addQueryParameter(k,v) }
|
||||
requestConfig.query.forEach { k, v ->
|
||||
v.forEach { queryValue ->
|
||||
urlBuilder = urlBuilder.addQueryParameter(k,queryValue)
|
||||
}
|
||||
}
|
||||
|
||||
val url = urlBuilder.build()
|
||||
val headers = requestConfig.headers + defaultHeaders
|
||||
@ -73,6 +77,7 @@ open class ApiClient(val baseUrl: String) {
|
||||
throw kotlin.IllegalStateException("Missing Accept header. This is required.")
|
||||
}
|
||||
|
||||
// TODO: support multiple contentType,accept options here.
|
||||
val contentType = (headers[ContentType] as String).substringBefore(";").toLowerCase()
|
||||
val accept = (headers[Accept] as String).substringBefore(";").toLowerCase()
|
||||
|
||||
|
@ -5,9 +5,11 @@ package io.swagger.client.infrastructure
|
||||
* 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.
|
||||
*/
|
||||
data class RequestConfig(
|
||||
val method: RequestMethod,
|
||||
val path: String,
|
||||
val headers: Map<String, String> = mapOf(),
|
||||
val query: Map<String, String> = mapOf())
|
||||
val query: Map<String, List<String>> = mapOf())
|
@ -25,10 +25,10 @@ import io.swagger.client.models.Tag
|
||||
*/
|
||||
data class Pet (
|
||||
val name: kotlin.String,
|
||||
val photoUrls: kotlin.collections.List<kotlin.String>,
|
||||
val photoUrls: kotlin.Array<kotlin.String>,
|
||||
val id: kotlin.Long? = null,
|
||||
val category: Category? = null,
|
||||
val tags: kotlin.collections.List<Tag>? = null,
|
||||
val tags: kotlin.Array<Tag>? = null,
|
||||
/* pet status in the store */
|
||||
val status: Pet.Status? = null
|
||||
) {
|
||||
|
@ -2,16 +2,21 @@ package io.swagger.client.functional
|
||||
|
||||
import io.kotlintest.matchers.should
|
||||
import io.kotlintest.matchers.beGreaterThan
|
||||
import io.kotlintest.matchers.shouldEqual
|
||||
import io.kotlintest.specs.ShouldSpec
|
||||
import io.swagger.client.apis.PetApi
|
||||
import io.swagger.client.models.Pet
|
||||
|
||||
class EvaluateTest : ShouldSpec() {
|
||||
init {
|
||||
should("query against pet statuses") {
|
||||
val api = PetApi()
|
||||
val results = api.findPetsByStatus(listOf("sold"))
|
||||
val results = api.findPetsByStatus(arrayOf("sold"))
|
||||
|
||||
results.size should beGreaterThan(1)
|
||||
|
||||
// Pet is lazily deserialized here. Need to iterate to verify all "sold" statuses.
|
||||
results.all { it.status == Pet.Status.sold } shouldEqual true
|
||||
}
|
||||
|
||||
// TODO: Handle default (200) response
|
||||
|
@ -20,6 +20,7 @@ import java.io.InputStream;
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
@ -32,7 +33,28 @@ import javax.validation.constraints.*;
|
||||
@io.swagger.annotations.Api(description = "the fake API")
|
||||
|
||||
public class FakeApi {
|
||||
private final FakeApiService delegate = FakeApiServiceFactory.getFakeApi();
|
||||
private final FakeApiService delegate;
|
||||
|
||||
public FakeApi(@Context ServletConfig servletContext) {
|
||||
FakeApiService delegate = null;
|
||||
|
||||
if (servletContext != null) {
|
||||
String implClass = servletContext.getInitParameter("FakeApi.implementation");
|
||||
if (implClass != null && !"".equals(implClass.trim())) {
|
||||
try {
|
||||
delegate = (FakeApiService) Class.forName(implClass).newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (delegate == null) {
|
||||
delegate = FakeApiServiceFactory.getFakeApi();
|
||||
}
|
||||
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/outer/boolean")
|
||||
|
@ -19,6 +19,7 @@ import java.io.InputStream;
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
@ -31,7 +32,28 @@ import javax.validation.constraints.*;
|
||||
@io.swagger.annotations.Api(description = "the pet API")
|
||||
|
||||
public class PetApi {
|
||||
private final PetApiService delegate = PetApiServiceFactory.getPetApi();
|
||||
private final PetApiService delegate;
|
||||
|
||||
public PetApi(@Context ServletConfig servletContext) {
|
||||
PetApiService delegate = null;
|
||||
|
||||
if (servletContext != null) {
|
||||
String implClass = servletContext.getInitParameter("PetApi.implementation");
|
||||
if (implClass != null && !"".equals(implClass.trim())) {
|
||||
try {
|
||||
delegate = (PetApiService) Class.forName(implClass).newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (delegate == null) {
|
||||
delegate = PetApiServiceFactory.getPetApi();
|
||||
}
|
||||
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@POST
|
||||
|
||||
|
@ -18,6 +18,7 @@ import java.io.InputStream;
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
@ -30,7 +31,28 @@ import javax.validation.constraints.*;
|
||||
@io.swagger.annotations.Api(description = "the store API")
|
||||
|
||||
public class StoreApi {
|
||||
private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi();
|
||||
private final StoreApiService delegate;
|
||||
|
||||
public StoreApi(@Context ServletConfig servletContext) {
|
||||
StoreApiService delegate = null;
|
||||
|
||||
if (servletContext != null) {
|
||||
String implClass = servletContext.getInitParameter("StoreApi.implementation");
|
||||
if (implClass != null && !"".equals(implClass.trim())) {
|
||||
try {
|
||||
delegate = (StoreApiService) Class.forName(implClass).newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (delegate == null) {
|
||||
delegate = StoreApiServiceFactory.getStoreApi();
|
||||
}
|
||||
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/order/{order_id}")
|
||||
|
@ -18,6 +18,7 @@ import java.io.InputStream;
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
@ -30,7 +31,28 @@ import javax.validation.constraints.*;
|
||||
@io.swagger.annotations.Api(description = "the user API")
|
||||
|
||||
public class UserApi {
|
||||
private final UserApiService delegate = UserApiServiceFactory.getUserApi();
|
||||
private final UserApiService delegate;
|
||||
|
||||
public UserApi(@Context ServletConfig servletContext) {
|
||||
UserApiService delegate = null;
|
||||
|
||||
if (servletContext != null) {
|
||||
String implClass = servletContext.getInitParameter("UserApi.implementation");
|
||||
if (implClass != null && !"".equals(implClass.trim())) {
|
||||
try {
|
||||
delegate = (UserApiService) Class.forName(implClass).newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (delegate == null) {
|
||||
delegate = UserApiServiceFactory.getUserApi();
|
||||
}
|
||||
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@POST
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user