Change default package name value for kotlin server (#387)

* Update default package

* Regenerate samples/server/petstore/kotlin-server/ktor

* Update git ignore

* Add CI
This commit is contained in:
Jérémie Bresson
2018-05-09 10:38:16 +02:00
committed by William Cheng
parent 5fb1660fe1
commit a00261d3da
28 changed files with 363 additions and 267 deletions

1
.gitignore vendored
View File

@@ -176,6 +176,7 @@ effective.pom
samples/client/petstore/kotlin/src/main/kotlin/test/
samples/client/petstore/kotlin-threetenbp/build
samples/client/petstore/kotlin-string/build
samples/server/petstore/kotlin-server/ktor/build
\?
# haskell

View File

@@ -30,3 +30,5 @@ export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-server -l kotlin-server --library=ktor -o samples/server/petstore/kotlin-server/ktor $@"
java ${JAVA_OPTS} -jar ${executable} ${ags}
cp samples.ci/server/petstore/kotlin-server/ktor/pom.xml samples/server/petstore/kotlin-server/ktor/pom.xml

View File

@@ -19,18 +19,17 @@ package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.mustache.*;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.responses.ApiResponse;
import org.openapitools.codegen.mustache.CamelCaseLambda;
import org.openapitools.codegen.mustache.IndentedLambda;
import org.openapitools.codegen.mustache.LowercaseLambda;
import org.openapitools.codegen.mustache.TitlecaseLambda;
import org.openapitools.codegen.mustache.UppercaseLambda;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -67,7 +66,7 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen {
super();
artifactId = "kotlin-server";
packageName = "io.swagger.server";
packageName = "org.openapitools.server";
outputFolder = "generated-code" + File.separator + "kotlin-server";
modelTemplateFiles.put("model.mustache", ".kt");
apiTemplateFiles.put("api.mustache", ".kt");

View File

@@ -905,6 +905,7 @@
<module>samples/server/petstore/jaxrs-resteasy/eap-joda</module>
<module>samples/server/petstore/jaxrs-resteasy/eap-java8</module>
<module>samples/server/petstore/jaxrs-resteasy/joda</module>
<module>samples/server/petstore/kotlin-server/ktor</module>
<module>samples/server/petstore/spring-mvc</module>
<module>samples/server/petstore/spring-mvc-j8-async</module>
<module>samples/server/petstore/spring-mvc-j8-localdatetime</module>

View File

@@ -0,0 +1,46 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools</groupId>
<artifactId>KotlinPetstoreKtorTests</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>kotlin-server-ktor</name>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>bundle-test</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>gradle</executable>
<arguments>
<argument>test</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -1,4 +0,0 @@
build/
gradle/
gradlew
gradlew.bat

View File

@@ -1,11 +1,11 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# 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 Swagger Codgen to ignore just this file by uncommenting the following line:
# 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 (*):

View File

@@ -1 +1 @@
2.3.0
3.0.0-SNAPSHOT

View File

@@ -1,8 +1,8 @@
# io.swagger.server - Kotlin Server library for Swagger Petstore
# org.openapitools.server - Kotlin Server library for OpenAPI Petstore
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key &#x60;special-key&#x60; to test the authorization filters.
This is a sample server Petstore server. For this sample, you can use the api key &#x60;special-key&#x60; to test the authorization filters.
Generated by Swagger Codegen 2.3.0 (2018-01-21T22:11:17.518-05:00).
Generated by OpenAPI Generator 3.0.0-SNAPSHOT (2018-05-09T05:00:11.354+02:00[Europe/Zurich]).
## Requires
@@ -40,7 +40,7 @@ docker run -p 8080:8080 kotlin-server
* Supports JSON inputs/outputs, File inputs, and Form inputs (see ktor documentation for more info).
* ~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 Swagger definitions.
* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in OpenAPI definitions.
<a name="documentation-for-api-endpoints"></a>
## Documentation for API Endpoints
@@ -74,12 +74,12 @@ Class | Method | HTTP request | Description
<a name="documentation-for-models"></a>
## Documentation for Models
- [io.swagger.server.models.ApiResponse](docs/ApiResponse.md)
- [io.swagger.server.models.Category](docs/Category.md)
- [io.swagger.server.models.Order](docs/Order.md)
- [io.swagger.server.models.Pet](docs/Pet.md)
- [io.swagger.server.models.Tag](docs/Tag.md)
- [io.swagger.server.models.User](docs/User.md)
- [org.openapitools.server.models.ApiResponse](docs/ApiResponse.md)
- [org.openapitools.server.models.Category](docs/Category.md)
- [org.openapitools.server.models.Order](docs/Order.md)
- [org.openapitools.server.models.Pet](docs/Pet.md)
- [org.openapitools.server.models.Tag](docs/Tag.md)
- [org.openapitools.server.models.User](docs/User.md)
<a name="documentation-for-authorization"></a>

View File

@@ -1,4 +1,4 @@
group 'io.swagger'
group 'org.openapitools'
version '1.0.0'
task wrapper(type: Wrapper) {

View File

@@ -0,0 +1,46 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools</groupId>
<artifactId>KotlinPetstoreKtorTests</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>kotlin-server-ktor</name>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>bundle-test</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>gradle</executable>
<arguments>
<argument>test</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -1,28 +0,0 @@
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* 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.
*/
package io.swagger.server.models
/**
* Describes the result of uploading an image resource
* @param code
* @param type
* @param message
*/
data class ApiResponse (
val code: kotlin.Int? = null,
val type: kotlin.String? = null,
val message: kotlin.String? = null
) {
}

View File

@@ -1,26 +0,0 @@
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* 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.
*/
package io.swagger.server.models
/**
* A category for a pet
* @param id
* @param name
*/
data class Category (
val id: kotlin.Long? = null,
val name: kotlin.String? = null
) {
}

View File

@@ -1,26 +0,0 @@
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* 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.
*/
package io.swagger.server.models
/**
* A tag for a pet
* @param id
* @param name
*/
data class Tag (
val id: kotlin.Long? = null,
val name: kotlin.String? = null
) {
}

View File

@@ -1,4 +1,4 @@
package io.swagger.server
package org.openapitools.server
import com.codahale.metrics.*
import com.typesafe.config.ConfigFactory
@@ -13,7 +13,7 @@ import io.ktor.locations.*
import io.ktor.metrics.*
import io.ktor.routing.*
import java.util.concurrent.*
import io.swagger.server.apis.*
import org.openapitools.server.apis.*
internal val settings = HoconApplicationConfig(ConfigFactory.defaultApplication(HTTP::class.java.classLoader))

View File

@@ -1,4 +1,4 @@
package io.swagger.server
package org.openapitools.server
// Use this file to hold package-level internal functions that return receiver object passed to the `install` method.
import io.ktor.auth.OAuthServerSettings
@@ -7,13 +7,13 @@ import io.ktor.http.*
import java.time.Duration
import java.util.concurrent.Executors
import io.swagger.server.settings
import org.openapitools.server.settings
/**
* Application block for [HSTS] configuration.
*
* This file may be excluded in .swagger-codegen-ignore,
* This file may be excluded in .openapi-generator-ignore,
* and application specific configuration can be applied in this function.
*
* See http://ktor.io/features/hsts.html
@@ -32,7 +32,7 @@ internal fun ApplicationHstsConfiguration(): HSTS.Configuration.() -> Unit {
/**
* Application block for [Compression] configuration.
*
* This file may be excluded in .swagger-codegen-ignore,
* This file may be excluded in .openapi-generator-ignore,
* and application specific configuration can be applied in this function.
*
* See http://ktor.io/features/compression.html

View File

@@ -1,15 +1,15 @@
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
* 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.
*
* 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
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package io.swagger.server
package org.openapitools.server
import io.ktor.application.ApplicationCall
import io.ktor.http.HttpMethod
@@ -17,7 +17,7 @@ import io.ktor.locations.*
import io.ktor.pipeline.PipelineContext
import io.ktor.routing.Route
import io.ktor.routing.method
import io.swagger.server.models.*
import org.openapitools.server.models.*
// NOTE: ktor-location@0.9.0 is missing extension for Route.delete. This includes it.
@@ -89,7 +89,7 @@ object Paths {
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @param username The name that needs to be fetched. Use user1 for testing.
*/
@Location("/user/{username}") class getUserByName(val username: kotlin.String)

View File

@@ -1,15 +1,15 @@
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
* 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.
*
* 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
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package io.swagger.server.apis
package org.openapitools.server.apis
import com.google.gson.Gson
import io.ktor.application.call
@@ -28,19 +28,19 @@ import io.ktor.routing.*
import kotlinx.coroutines.experimental.asCoroutineDispatcher
import io.swagger.server.ApplicationAuthProviders
import io.swagger.server.Paths
import io.swagger.server.ApplicationExecutors
import io.swagger.server.HTTP.client
import io.swagger.server.infrastructure.ApiPrincipal
import io.swagger.server.infrastructure.apiKeyAuth
import org.openapitools.server.ApplicationAuthProviders
import org.openapitools.server.Paths
import org.openapitools.server.ApplicationExecutors
import org.openapitools.server.HTTP.client
import org.openapitools.server.infrastructure.ApiPrincipal
import org.openapitools.server.infrastructure.apiKeyAuth
// ktor 0.9.x is missing io.ktor.locations.DELETE, this adds it.
// see https://github.com/ktorio/ktor/issues/288
import io.swagger.server.delete
import org.openapitools.server.delete
import io.swagger.server.models.ApiResponse
import io.swagger.server.models.Pet
import org.openapitools.server.models.ApiResponse
import org.openapitools.server.models.Pet
fun Route.PetApi() {
val gson = Gson()
@@ -108,17 +108,24 @@ fun Route.PetApi() {
if (principal == null) {
call.respond(HttpStatusCode.Unauthorized)
} else {
val exampleContentType = "application/xml"
val exampleContentString = """<Pet>
<id>123456789</id>
<name>doggie</name>
<photoUrls>
<photoUrls>aeiou</photoUrls>
</photoUrls>
<tags>
</tags>
<status>aeiou</status>
</Pet>"""
val exampleContentType = "application/json"
val exampleContentString = """{
"photoUrls" : [ "photoUrls", "photoUrls" ],
"name" : "doggie",
"id" : 0,
"category" : {
"name" : "name",
"id" : 6
},
"tags" : [ {
"name" : "name",
"id" : 1
}, {
"name" : "name",
"id" : 1
} ],
"status" : "available"
}"""
when(exampleContentType) {
"application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java))
@@ -152,17 +159,24 @@ fun Route.PetApi() {
if (principal == null) {
call.respond(HttpStatusCode.Unauthorized)
} else {
val exampleContentType = "application/xml"
val exampleContentString = """<Pet>
<id>123456789</id>
<name>doggie</name>
<photoUrls>
<photoUrls>aeiou</photoUrls>
</photoUrls>
<tags>
</tags>
<status>aeiou</status>
</Pet>"""
val exampleContentType = "application/json"
val exampleContentString = """{
"photoUrls" : [ "photoUrls", "photoUrls" ],
"name" : "doggie",
"id" : 0,
"category" : {
"name" : "name",
"id" : 6
},
"tags" : [ {
"name" : "name",
"id" : 1
}, {
"name" : "name",
"id" : 1
} ],
"status" : "available"
}"""
when(exampleContentType) {
"application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java))
@@ -196,17 +210,24 @@ fun Route.PetApi() {
if (principal == null) {
call.respond(HttpStatusCode.Unauthorized)
} else {
val exampleContentType = "application/xml"
val exampleContentString = """<Pet>
<id>123456789</id>
<name>doggie</name>
<photoUrls>
<photoUrls>aeiou</photoUrls>
</photoUrls>
<tags>
</tags>
<status>aeiou</status>
</Pet>"""
val exampleContentType = "application/json"
val exampleContentString = """{
"photoUrls" : [ "photoUrls", "photoUrls" ],
"name" : "doggie",
"id" : 0,
"category" : {
"name" : "name",
"id" : 6
},
"tags" : [ {
"name" : "name",
"id" : 1
}, {
"name" : "name",
"id" : 1
} ],
"status" : "available"
}"""
when(exampleContentType) {
"application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java))

View File

@@ -1,15 +1,15 @@
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
* 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.
*
* 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
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package io.swagger.server.apis
package org.openapitools.server.apis
import com.google.gson.Gson
import io.ktor.application.call
@@ -28,18 +28,18 @@ import io.ktor.routing.*
import kotlinx.coroutines.experimental.asCoroutineDispatcher
import io.swagger.server.ApplicationAuthProviders
import io.swagger.server.Paths
import io.swagger.server.ApplicationExecutors
import io.swagger.server.HTTP.client
import io.swagger.server.infrastructure.ApiPrincipal
import io.swagger.server.infrastructure.apiKeyAuth
import org.openapitools.server.ApplicationAuthProviders
import org.openapitools.server.Paths
import org.openapitools.server.ApplicationExecutors
import org.openapitools.server.HTTP.client
import org.openapitools.server.infrastructure.ApiPrincipal
import org.openapitools.server.infrastructure.apiKeyAuth
// ktor 0.9.x is missing io.ktor.locations.DELETE, this adds it.
// see https://github.com/ktorio/ktor/issues/288
import io.swagger.server.delete
import org.openapitools.server.delete
import io.swagger.server.models.Order
import org.openapitools.server.models.Order
fun Route.StoreApi() {
val gson = Gson()
@@ -56,16 +56,7 @@ fun Route.StoreApi() {
if (principal == null) {
call.respond(HttpStatusCode.Unauthorized)
} else {
val exampleContentType = "application/json"
val exampleContentString = """{
"key" : 0
}"""
when(exampleContentType) {
"application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java))
"application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml)
else -> call.respondText(exampleContentString)
}
call.respond(HttpStatusCode.NotImplemented)
}
}
.apply {
@@ -91,15 +82,15 @@ fun Route.StoreApi() {
}
get<Paths.getOrderById> { it: Paths.getOrderById ->
val exampleContentType = "application/xml"
val exampleContentString = """<Order>
<id>123456789</id>
<petId>123456789</petId>
<quantity>123</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>aeiou</status>
<complete>true</complete>
</Order>"""
val exampleContentType = "application/json"
val exampleContentString = """{
"petId" : 6,
"quantity" : 1,
"id" : 0,
"shipDate" : "2000-01-23T04:56:07.000+00:00",
"complete" : false,
"status" : "placed"
}"""
when(exampleContentType) {
"application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java))
@@ -111,15 +102,15 @@ fun Route.StoreApi() {
route("/store/order") {
post {
val exampleContentType = "application/xml"
val exampleContentString = """<Order>
<id>123456789</id>
<petId>123456789</petId>
<quantity>123</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>aeiou</status>
<complete>true</complete>
</Order>"""
val exampleContentType = "application/json"
val exampleContentString = """{
"petId" : 6,
"quantity" : 1,
"id" : 0,
"shipDate" : "2000-01-23T04:56:07.000+00:00",
"complete" : false,
"status" : "placed"
}"""
when(exampleContentType) {
"application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java))

View File

@@ -1,15 +1,15 @@
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
* 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.
*
* 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
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package io.swagger.server.apis
package org.openapitools.server.apis
import com.google.gson.Gson
import io.ktor.application.call
@@ -28,18 +28,18 @@ import io.ktor.routing.*
import kotlinx.coroutines.experimental.asCoroutineDispatcher
import io.swagger.server.ApplicationAuthProviders
import io.swagger.server.Paths
import io.swagger.server.ApplicationExecutors
import io.swagger.server.HTTP.client
import io.swagger.server.infrastructure.ApiPrincipal
import io.swagger.server.infrastructure.apiKeyAuth
import org.openapitools.server.ApplicationAuthProviders
import org.openapitools.server.Paths
import org.openapitools.server.ApplicationExecutors
import org.openapitools.server.HTTP.client
import org.openapitools.server.infrastructure.ApiPrincipal
import org.openapitools.server.infrastructure.apiKeyAuth
// ktor 0.9.x is missing io.ktor.locations.DELETE, this adds it.
// see https://github.com/ktorio/ktor/issues/288
import io.swagger.server.delete
import org.openapitools.server.delete
import io.swagger.server.models.User
import org.openapitools.server.models.User
fun Route.UserApi() {
val gson = Gson()
@@ -72,17 +72,17 @@ fun Route.UserApi() {
get<Paths.getUserByName> { it: Paths.getUserByName ->
val exampleContentType = "application/xml"
val exampleContentString = """<User>
<id>123456789</id>
<username>aeiou</username>
<firstName>aeiou</firstName>
<lastName>aeiou</lastName>
<email>aeiou</email>
<password>aeiou</password>
<phone>aeiou</phone>
<userStatus>123</userStatus>
</User>"""
val exampleContentType = "application/json"
val exampleContentString = """{
"firstName" : "firstName",
"lastName" : "lastName",
"password" : "password",
"userStatus" : 6,
"phone" : "phone",
"id" : 0,
"email" : "email",
"username" : "username"
}"""
when(exampleContentType) {
"application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java))
@@ -93,14 +93,7 @@ fun Route.UserApi() {
get<Paths.loginUser> { it: Paths.loginUser ->
val exampleContentType = "application/xml"
val exampleContentString = """aeiou"""
when(exampleContentType) {
"application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java))
"application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml)
else -> call.respondText(exampleContentString)
}
call.respond(HttpStatusCode.NotImplemented)
}

View File

@@ -1,4 +1,4 @@
package io.swagger.server.infrastructure
package org.openapitools.server.infrastructure
import io.ktor.application.ApplicationCall
import io.ktor.application.call

View File

@@ -0,0 +1,28 @@
/**
* 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.
*
* OpenAPI spec version: 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.server.models
/**
* Describes the result of uploading an image resource
* @param code
* @param type
* @param message
*/
data class ApiResponse (
val code: kotlin.Int? = null,
val type: kotlin.String? = null,
val message: kotlin.String? = null
) {
}

View File

@@ -0,0 +1,26 @@
/**
* 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.
*
* OpenAPI spec version: 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.server.models
/**
* A category for a pet
* @param id
* @param name
*/
data class Category (
val id: kotlin.Long? = null,
val name: kotlin.String? = null
) {
}

View File

@@ -1,15 +1,15 @@
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
* 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.
*
* 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
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package io.swagger.server.models
package org.openapitools.server.models
/**

View File

@@ -1,18 +1,18 @@
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
* 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.
*
* 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
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package io.swagger.server.models
package org.openapitools.server.models
import io.swagger.server.models.Category
import io.swagger.server.models.Tag
import org.openapitools.server.models.Category
import org.openapitools.server.models.Tag
/**
* A pet for sale in the pet store

View File

@@ -0,0 +1,26 @@
/**
* 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.
*
* OpenAPI spec version: 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.server.models
/**
* A tag for a pet
* @param id
* @param name
*/
data class Tag (
val id: kotlin.Long? = null,
val name: kotlin.String? = null
) {
}

View File

@@ -1,15 +1,15 @@
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
* 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.
*
* 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
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package io.swagger.server.models
package org.openapitools.server.models
/**

View File

@@ -3,11 +3,11 @@ ktor {
environment = development
port = 8080
autoreload = true
watch = [ io.swagger.server ]
watch = [ org.openapitools.server ]
}
application {
modules = [ io.swagger.server.AppMainKt.main ]
modules = [ org.openapitools.server.AppMainKt.main ]
}
}