forked from loafle/openapi-generator-original
Added support for using mutiny instead of coroutines for asynchronous kotlin server APIs (#15262)
This commit is contained in:
parent
bf181906e0
commit
c6a100cce2
1
.github/workflows/samples-kotlin-server.yaml
vendored
1
.github/workflows/samples-kotlin-server.yaml
vendored
@ -29,6 +29,7 @@ jobs:
|
|||||||
- samples/server/petstore/kotlin-springboot-springfox
|
- samples/server/petstore/kotlin-springboot-springfox
|
||||||
- samples/server/petstore/kotlin-server/ktor
|
- samples/server/petstore/kotlin-server/ktor
|
||||||
- samples/server/petstore/kotlin-server/jaxrs-spec
|
- samples/server/petstore/kotlin-server/jaxrs-spec
|
||||||
|
- samples/server/petstore/kotlin-server/jaxrs-spec-mutiny
|
||||||
- samples/server/petstore/kotlin-server-modelMutable
|
- samples/server/petstore/kotlin-server-modelMutable
|
||||||
# no build.gradle file
|
# no build.gradle file
|
||||||
#- samples/server/petstore/kotlin-vertx-modelMutable
|
#- samples/server/petstore/kotlin-vertx-modelMutable
|
||||||
|
9
bin/configs/kotlin-server-jaxrs-spec-mutiny.yaml
Normal file
9
bin/configs/kotlin-server-jaxrs-spec-mutiny.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
generatorName: kotlin-server
|
||||||
|
outputDir: samples/server/petstore/kotlin-server/jaxrs-spec-mutiny
|
||||||
|
library: jaxrs-spec
|
||||||
|
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||||
|
templateDir: modules/openapi-generator/src/main/resources/kotlin-server
|
||||||
|
additionalProperties:
|
||||||
|
returnResponse: "true"
|
||||||
|
interfaceOnly: "true"
|
||||||
|
useMutiny: "true"
|
@ -45,6 +45,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|useBeanValidation|Use BeanValidation API annotations. This option is currently supported only when using jaxrs-spec library.| |false|
|
|useBeanValidation|Use BeanValidation API annotations. This option is currently supported only when using jaxrs-spec library.| |false|
|
||||||
|useCoroutines|Whether to use the Coroutines. This option is currently supported only when using jaxrs-spec library.| |false|
|
|useCoroutines|Whether to use the Coroutines. This option is currently supported only when using jaxrs-spec library.| |false|
|
||||||
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|
||||||
|
|useMutiny|Whether to use Mutiny (should not be used with useCoroutines). This option is currently supported only when using jaxrs-spec library.| |false|
|
||||||
|
|
||||||
## IMPORT MAPPING
|
## IMPORT MAPPING
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
|
|||||||
private boolean interfaceOnly = false;
|
private boolean interfaceOnly = false;
|
||||||
private boolean useBeanValidation = false;
|
private boolean useBeanValidation = false;
|
||||||
private boolean useCoroutines = false;
|
private boolean useCoroutines = false;
|
||||||
|
private boolean useMutiny = false;
|
||||||
private boolean returnResponse = false;
|
private boolean returnResponse = false;
|
||||||
|
|
||||||
// This is here to potentially warn the user when an option is not supported by the target framework.
|
// This is here to potentially warn the user when an option is not supported by the target framework.
|
||||||
@ -64,6 +65,7 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
|
|||||||
.put(Constants.JAXRS_SPEC, Arrays.asList(
|
.put(Constants.JAXRS_SPEC, Arrays.asList(
|
||||||
USE_BEANVALIDATION,
|
USE_BEANVALIDATION,
|
||||||
Constants.USE_COROUTINES,
|
Constants.USE_COROUTINES,
|
||||||
|
Constants.USE_MUTINY,
|
||||||
Constants.RETURN_RESPONSE,
|
Constants.RETURN_RESPONSE,
|
||||||
Constants.INTERFACE_ONLY
|
Constants.INTERFACE_ONLY
|
||||||
))
|
))
|
||||||
@ -128,6 +130,7 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
|
|||||||
addSwitch(Constants.INTERFACE_ONLY, Constants.INTERFACE_ONLY_DESC, interfaceOnly);
|
addSwitch(Constants.INTERFACE_ONLY, Constants.INTERFACE_ONLY_DESC, interfaceOnly);
|
||||||
addSwitch(USE_BEANVALIDATION, Constants.USE_BEANVALIDATION_DESC, useBeanValidation);
|
addSwitch(USE_BEANVALIDATION, Constants.USE_BEANVALIDATION_DESC, useBeanValidation);
|
||||||
addSwitch(Constants.USE_COROUTINES, Constants.USE_COROUTINES_DESC, useCoroutines);
|
addSwitch(Constants.USE_COROUTINES, Constants.USE_COROUTINES_DESC, useCoroutines);
|
||||||
|
addSwitch(Constants.USE_MUTINY, Constants.USE_MUTINY_DESC, useMutiny);
|
||||||
addSwitch(Constants.RETURN_RESPONSE, Constants.RETURN_RESPONSE_DESC, returnResponse);
|
addSwitch(Constants.RETURN_RESPONSE, Constants.RETURN_RESPONSE_DESC, returnResponse);
|
||||||
addSwitch(USE_JAKARTA_EE, Constants.USE_JAKARTA_EE_DESC, useJakartaEe);
|
addSwitch(USE_JAKARTA_EE, Constants.USE_JAKARTA_EE_DESC, useJakartaEe);
|
||||||
}
|
}
|
||||||
@ -226,6 +229,13 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(Constants.USE_MUTINY)) {
|
||||||
|
useMutiny = Boolean.parseBoolean(additionalProperties.get(Constants.USE_MUTINY).toString());
|
||||||
|
if (!useMutiny) {
|
||||||
|
additionalProperties.remove(Constants.USE_MUTINY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(Constants.RETURN_RESPONSE)) {
|
if (additionalProperties.containsKey(Constants.RETURN_RESPONSE)) {
|
||||||
returnResponse = Boolean.parseBoolean(additionalProperties.get(Constants.RETURN_RESPONSE).toString());
|
returnResponse = Boolean.parseBoolean(additionalProperties.get(Constants.RETURN_RESPONSE).toString());
|
||||||
if (!returnResponse) {
|
if (!returnResponse) {
|
||||||
@ -348,6 +358,8 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
|
|||||||
public static final String RETURN_RESPONSE = "returnResponse";
|
public static final String RETURN_RESPONSE = "returnResponse";
|
||||||
public static final String RETURN_RESPONSE_DESC = "Whether generate API interface should return javax.ws.rs.core.Response instead of a deserialized entity. Only useful if interfaceOnly is true. This option is currently supported only when using jaxrs-spec library.";
|
public static final String RETURN_RESPONSE_DESC = "Whether generate API interface should return javax.ws.rs.core.Response instead of a deserialized entity. Only useful if interfaceOnly is true. This option is currently supported only when using jaxrs-spec library.";
|
||||||
public static final String USE_JAKARTA_EE_DESC = "whether to use Jakarta EE namespace instead of javax";
|
public static final String USE_JAKARTA_EE_DESC = "whether to use Jakarta EE namespace instead of javax";
|
||||||
|
public static final String USE_MUTINY = "useMutiny";
|
||||||
|
public static final String USE_MUTINY_DESC = "Whether to use Mutiny (should not be used with useCoroutines). This option is currently supported only when using jaxrs-spec library.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -10,4 +10,4 @@
|
|||||||
{{/isOAuth}}{{/authMethods}} }{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-tags}} })
|
{{/isOAuth}}{{/authMethods}} }{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-tags}} })
|
||||||
@ApiResponses(value = { {{#responses}}
|
@ApiResponses(value = { {{#responses}}
|
||||||
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#returnContainer}}, responseContainer = "{{{.}}}"{{/returnContainer}}){{^-last}},{{/-last}}{{/responses}} }){{/useSwaggerAnnotations}}
|
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#returnContainer}}, responseContainer = "{{{.}}}"{{/returnContainer}}){{^-last}},{{/-last}}{{/responses}} }){{/useSwaggerAnnotations}}
|
||||||
{{#useCoroutines}}suspend {{/useCoroutines}}fun {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}){{#returnResponse}}: Response{{/returnResponse}}{{^returnResponse}}{{#returnType}}: {{{returnType}}}{{/returnType}}{{/returnResponse}}
|
{{#useCoroutines}}suspend {{/useCoroutines}}fun {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}){{#returnResponse}}: {{#useMutiny}}io.smallrye.mutiny.Uni<{{/useMutiny}}Response{{#useMutiny}}>{{/useMutiny}}{{/returnResponse}}{{^returnResponse}}{{#returnType}}: {{#useMutiny}}io.smallrye.mutiny.Uni<{{/useMutiny}}{{{returnType}}}{{#useMutiny}}>{{/useMutiny}}{{/returnType}}{{/returnResponse}}{{^returnResponse}}{{^returnType}}{{#useMutiny}}: io.smallrye.mutiny.Uni<Void>{{/useMutiny}}{{/returnType}}{{/returnResponse}}
|
@ -7,7 +7,7 @@ wrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = "1.4.32"
|
ext.kotlin_version = "1.7.20"
|
||||||
ext.swagger_annotations_version = "1.5.3"
|
ext.swagger_annotations_version = "1.5.3"
|
||||||
{{#useJakartaEe}}
|
{{#useJakartaEe}}
|
||||||
ext.jakarta_annotations_version = "2.1.1"
|
ext.jakarta_annotations_version = "2.1.1"
|
||||||
@ -17,6 +17,9 @@ buildscript {
|
|||||||
ext.jakarta_annotations_version = "1.3.5"
|
ext.jakarta_annotations_version = "1.3.5"
|
||||||
ext.jakarta_ws_rs_version = "2.1.6"
|
ext.jakarta_ws_rs_version = "2.1.6"
|
||||||
{{/useJakartaEe}}
|
{{/useJakartaEe}}
|
||||||
|
{{#useMutiny}}
|
||||||
|
ext.mutiny_version = "2.2.0"
|
||||||
|
{{/useMutiny}}
|
||||||
ext.jackson_version = "2.9.9"
|
ext.jackson_version = "2.9.9"
|
||||||
{{#useBeanValidation}}
|
{{#useBeanValidation}}
|
||||||
ext.beanvalidation_version = "2.0.2"
|
ext.beanvalidation_version = "2.0.2"
|
||||||
@ -59,5 +62,9 @@ dependencies {
|
|||||||
{{#useBeanValidation}}
|
{{#useBeanValidation}}
|
||||||
implementation("jakarta.validation:jakarta.validation-api:$beanvalidation_version")
|
implementation("jakarta.validation:jakarta.validation-api:$beanvalidation_version")
|
||||||
{{/useBeanValidation}}
|
{{/useBeanValidation}}
|
||||||
|
{{#useMutiny}}
|
||||||
|
implementation("io.smallrye.reactive:mutiny:$mutiny_version")
|
||||||
|
implementation("io.smallrye.reactive:mutiny-kotlin:$mutiny_version")
|
||||||
|
{{/useMutiny}}
|
||||||
testImplementation("junit:junit:4.13.2")
|
testImplementation("junit:junit:4.13.2")
|
||||||
}
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
# OpenAPI Generator Ignore
|
||||||
|
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||||
|
|
||||||
|
# Use this file to prevent files from being overwritten by the generator.
|
||||||
|
# The patterns follow closely to .gitignore or .dockerignore.
|
||||||
|
|
||||||
|
# As an example, the C# client generator defines ApiClient.cs.
|
||||||
|
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||||
|
#ApiClient.cs
|
||||||
|
|
||||||
|
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||||
|
#foo/*/qux
|
||||||
|
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||||
|
#foo/**/qux
|
||||||
|
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can also negate patterns with an exclamation (!).
|
||||||
|
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||||
|
#docs/*.md
|
||||||
|
# Then explicitly reverse the ignore rule for a single file:
|
||||||
|
#!docs/README.md
|
@ -0,0 +1,13 @@
|
|||||||
|
README.md
|
||||||
|
build.gradle
|
||||||
|
gradle.properties
|
||||||
|
settings.gradle
|
||||||
|
src/main/kotlin/org/openapitools/server/apis/PetApi.kt
|
||||||
|
src/main/kotlin/org/openapitools/server/apis/StoreApi.kt
|
||||||
|
src/main/kotlin/org/openapitools/server/apis/UserApi.kt
|
||||||
|
src/main/kotlin/org/openapitools/server/models/Category.kt
|
||||||
|
src/main/kotlin/org/openapitools/server/models/ModelApiResponse.kt
|
||||||
|
src/main/kotlin/org/openapitools/server/models/Order.kt
|
||||||
|
src/main/kotlin/org/openapitools/server/models/Pet.kt
|
||||||
|
src/main/kotlin/org/openapitools/server/models/Tag.kt
|
||||||
|
src/main/kotlin/org/openapitools/server/models/User.kt
|
@ -0,0 +1 @@
|
|||||||
|
7.0.0-SNAPSHOT
|
@ -0,0 +1,91 @@
|
|||||||
|
# org.openapitools.server - Kotlin Server library for OpenAPI Petstore
|
||||||
|
|
||||||
|
## Requires
|
||||||
|
|
||||||
|
* Kotlin 1.4.31
|
||||||
|
* Gradle 6.8.2
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
First, create the gradle wrapper script:
|
||||||
|
|
||||||
|
```
|
||||||
|
gradle wrapper
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, run:
|
||||||
|
|
||||||
|
```
|
||||||
|
./gradlew check assemble
|
||||||
|
```
|
||||||
|
|
||||||
|
This runs all tests and packages the library.
|
||||||
|
|
||||||
|
## Features/Implementation Notes
|
||||||
|
|
||||||
|
* Supports JSON inputs/outputs, File inputs, and Form inputs.
|
||||||
|
* Supports collection formats for query parameters: csv, tsv, ssv, pipes.
|
||||||
|
* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in OpenAPI definitions.
|
||||||
|
|
||||||
|
<a id="documentation-for-api-endpoints"></a>
|
||||||
|
## Documentation for API Endpoints
|
||||||
|
|
||||||
|
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||||
|
|
||||||
|
Class | Method | HTTP request | Description
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
*PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
|
||||||
|
*PetApi* | [**deletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||||
|
*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
|
||||||
|
*PetApi* | [**findPetsByTags**](docs/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||||
|
*PetApi* | [**getPetById**](docs/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID
|
||||||
|
*PetApi* | [**updatePet**](docs/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet
|
||||||
|
*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||||
|
*PetApi* | [**uploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||||
|
*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
|
||||||
|
*StoreApi* | [**getInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||||
|
*StoreApi* | [**getOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID
|
||||||
|
*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet
|
||||||
|
*UserApi* | [**createUser**](docs/UserApi.md#createuser) | **POST** /user | Create user
|
||||||
|
*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||||
|
*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array
|
||||||
|
*UserApi* | [**deleteUser**](docs/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user
|
||||||
|
*UserApi* | [**getUserByName**](docs/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name
|
||||||
|
*UserApi* | [**loginUser**](docs/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system
|
||||||
|
*UserApi* | [**logoutUser**](docs/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session
|
||||||
|
*UserApi* | [**updateUser**](docs/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user
|
||||||
|
|
||||||
|
|
||||||
|
<a id="documentation-for-models"></a>
|
||||||
|
## Documentation for Models
|
||||||
|
|
||||||
|
- [org.openapitools.server.models.Category](docs/Category.md)
|
||||||
|
- [org.openapitools.server.models.ModelApiResponse](docs/ModelApiResponse.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 id="documentation-for-authorization"></a>
|
||||||
|
## Documentation for Authorization
|
||||||
|
|
||||||
|
|
||||||
|
Authentication schemes defined for the API:
|
||||||
|
<a id="petstore_auth"></a>
|
||||||
|
### petstore_auth
|
||||||
|
|
||||||
|
- **Type**: OAuth
|
||||||
|
- **Flow**: implicit
|
||||||
|
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||||
|
- **Scopes**:
|
||||||
|
- write:pets: modify pets in your account
|
||||||
|
- read:pets: read your pets
|
||||||
|
|
||||||
|
<a id="api_key"></a>
|
||||||
|
### api_key
|
||||||
|
|
||||||
|
- **Type**: API key
|
||||||
|
- **API key parameter name**: api_key
|
||||||
|
- **Location**: HTTP header
|
||||||
|
|
@ -0,0 +1,54 @@
|
|||||||
|
group "org.openapitools"
|
||||||
|
version "1.0.0"
|
||||||
|
|
||||||
|
wrapper {
|
||||||
|
gradleVersion = "6.9"
|
||||||
|
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
ext.kotlin_version = "1.7.20"
|
||||||
|
ext.swagger_annotations_version = "1.5.3"
|
||||||
|
ext.jakarta_annotations_version = "1.3.5"
|
||||||
|
ext.jakarta_ws_rs_version = "2.1.6"
|
||||||
|
ext.mutiny_version = "2.2.0"
|
||||||
|
ext.jackson_version = "2.9.9"
|
||||||
|
repositories {
|
||||||
|
maven { url "https://repo1.maven.org/maven2" }
|
||||||
|
maven { url "https://plugins.gradle.org/m2/" }
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: "java"
|
||||||
|
apply plugin: "kotlin"
|
||||||
|
apply plugin: "application"
|
||||||
|
|
||||||
|
sourceCompatibility = 1.8
|
||||||
|
|
||||||
|
compileKotlin {
|
||||||
|
kotlinOptions.jvmTarget = "1.8"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileTestKotlin {
|
||||||
|
kotlinOptions.jvmTarget = "1.8"
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven { setUrl("https://repo1.maven.org/maven2") }
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
|
||||||
|
implementation("ch.qos.logback:logback-classic:1.2.1")
|
||||||
|
implementation("jakarta.ws.rs:jakarta.ws.rs-api:$jakarta_ws_rs_version")
|
||||||
|
implementation("jakarta.annotation:jakarta.annotation-api:$jakarta_annotations_version")
|
||||||
|
implementation("io.swagger:swagger-annotations:$swagger_annotations_version")
|
||||||
|
implementation("com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version")
|
||||||
|
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version")
|
||||||
|
implementation("io.smallrye.reactive:mutiny:$mutiny_version")
|
||||||
|
implementation("io.smallrye.reactive:mutiny-kotlin:$mutiny_version")
|
||||||
|
testImplementation("junit:junit:4.13.2")
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
org.gradle.caching=true
|
@ -0,0 +1 @@
|
|||||||
|
rootProject.name = 'kotlin-server'
|
@ -0,0 +1,57 @@
|
|||||||
|
package org.openapitools.server.apis;
|
||||||
|
|
||||||
|
import org.openapitools.server.models.ModelApiResponse
|
||||||
|
import org.openapitools.server.models.Pet
|
||||||
|
|
||||||
|
import javax.ws.rs.*
|
||||||
|
import javax.ws.rs.core.Response
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.InputStream
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Path("/")
|
||||||
|
@javax.annotation.Generated(value = arrayOf("org.openapitools.codegen.languages.KotlinServerCodegen"))
|
||||||
|
interface PetApi {
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/pet")
|
||||||
|
@Consumes("application/json", "application/xml")
|
||||||
|
fun addPet( body: Pet): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@DELETE
|
||||||
|
@Path("/pet/{petId}")
|
||||||
|
fun deletePet(@PathParam("petId") petId: kotlin.Long,@HeaderParam("api_key") apiKey: kotlin.String?): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/pet/findByStatus")
|
||||||
|
@Produces("application/xml", "application/json")
|
||||||
|
fun findPetsByStatus(@QueryParam("status") status: kotlin.collections.List<kotlin.String>): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/pet/findByTags")
|
||||||
|
@Produces("application/xml", "application/json")
|
||||||
|
fun findPetsByTags(@QueryParam("tags") tags: kotlin.collections.List<kotlin.String>): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/pet/{petId}")
|
||||||
|
@Produces("application/xml", "application/json")
|
||||||
|
fun getPetById(@PathParam("petId") petId: kotlin.Long): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("/pet")
|
||||||
|
@Consumes("application/json", "application/xml")
|
||||||
|
fun updatePet( body: Pet): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/pet/{petId}")
|
||||||
|
@Consumes("application/x-www-form-urlencoded")
|
||||||
|
fun updatePetWithForm(@PathParam("petId") petId: kotlin.Long,@FormParam(value = "name") name: kotlin.String?,@FormParam(value = "status") status: kotlin.String?): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/pet/{petId}/uploadImage")
|
||||||
|
@Consumes("multipart/form-data")
|
||||||
|
@Produces("application/json")
|
||||||
|
fun uploadFile(@PathParam("petId") petId: kotlin.Long,@FormParam(value = "additionalMetadata") additionalMetadata: kotlin.String?, @FormParam(value = "file") fileInputStream: InputStream?): io.smallrye.mutiny.Uni<Response>
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package org.openapitools.server.apis;
|
||||||
|
|
||||||
|
import org.openapitools.server.models.Order
|
||||||
|
|
||||||
|
import javax.ws.rs.*
|
||||||
|
import javax.ws.rs.core.Response
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.InputStream
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Path("/")
|
||||||
|
@javax.annotation.Generated(value = arrayOf("org.openapitools.codegen.languages.KotlinServerCodegen"))
|
||||||
|
interface StoreApi {
|
||||||
|
|
||||||
|
@DELETE
|
||||||
|
@Path("/store/order/{orderId}")
|
||||||
|
fun deleteOrder(@PathParam("orderId") orderId: kotlin.String): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/store/inventory")
|
||||||
|
@Produces("application/json")
|
||||||
|
fun getInventory(): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/store/order/{orderId}")
|
||||||
|
@Produces("application/xml", "application/json")
|
||||||
|
fun getOrderById(@PathParam("orderId") orderId: kotlin.Long): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/store/order")
|
||||||
|
@Produces("application/xml", "application/json")
|
||||||
|
fun placeOrder( body: Order): io.smallrye.mutiny.Uni<Response>
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package org.openapitools.server.apis;
|
||||||
|
|
||||||
|
import org.openapitools.server.models.User
|
||||||
|
|
||||||
|
import javax.ws.rs.*
|
||||||
|
import javax.ws.rs.core.Response
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.InputStream
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Path("/")
|
||||||
|
@javax.annotation.Generated(value = arrayOf("org.openapitools.codegen.languages.KotlinServerCodegen"))
|
||||||
|
interface UserApi {
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/user")
|
||||||
|
fun createUser( body: User): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/user/createWithArray")
|
||||||
|
fun createUsersWithArrayInput( body: kotlin.collections.List<User>): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/user/createWithList")
|
||||||
|
fun createUsersWithListInput( body: kotlin.collections.List<User>): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@DELETE
|
||||||
|
@Path("/user/{username}")
|
||||||
|
fun deleteUser(@PathParam("username") username: kotlin.String): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/user/{username}")
|
||||||
|
@Produces("application/xml", "application/json")
|
||||||
|
fun getUserByName(@PathParam("username") username: kotlin.String): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/user/login")
|
||||||
|
@Produces("application/xml", "application/json")
|
||||||
|
fun loginUser(@QueryParam("username") username: kotlin.String,@QueryParam("password") password: kotlin.String): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/user/logout")
|
||||||
|
fun logoutUser(): io.smallrye.mutiny.Uni<Response>
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("/user/{username}")
|
||||||
|
fun updateUser(@PathParam("username") username: kotlin.String, body: User): io.smallrye.mutiny.Uni<Response>
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.server.models
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
/**
|
||||||
|
* A category for a pet
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
data class Category (
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("id")
|
||||||
|
val id: kotlin.Long? = null,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("name")
|
||||||
|
val name: kotlin.String? = null
|
||||||
|
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.server.models
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
/**
|
||||||
|
* Describes the result of uploading an image resource
|
||||||
|
*
|
||||||
|
* @param code
|
||||||
|
* @param type
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
data class ModelApiResponse (
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("code")
|
||||||
|
val code: kotlin.Int? = null,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("type")
|
||||||
|
val type: kotlin.String? = null,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("message")
|
||||||
|
val message: kotlin.String? = null
|
||||||
|
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,67 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.server.models
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
/**
|
||||||
|
* An order for a pets from the pet store
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param petId
|
||||||
|
* @param quantity
|
||||||
|
* @param shipDate
|
||||||
|
* @param status Order Status
|
||||||
|
* @param complete
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
data class Order (
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("id")
|
||||||
|
val id: kotlin.Long? = null,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("petId")
|
||||||
|
val petId: kotlin.Long? = null,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("quantity")
|
||||||
|
val quantity: kotlin.Int? = null,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("shipDate")
|
||||||
|
val shipDate: java.time.OffsetDateTime? = null,
|
||||||
|
|
||||||
|
/* Order Status */
|
||||||
|
|
||||||
|
@JsonProperty("status")
|
||||||
|
val status: Order.Status? = null,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("complete")
|
||||||
|
val complete: kotlin.Boolean? = false
|
||||||
|
|
||||||
|
) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order Status
|
||||||
|
*
|
||||||
|
* Values: placed,approved,delivered
|
||||||
|
*/
|
||||||
|
enum class Status(val value: kotlin.String) {
|
||||||
|
@JsonProperty(value = "placed") placed("placed"),
|
||||||
|
@JsonProperty(value = "approved") approved("approved"),
|
||||||
|
@JsonProperty(value = "delivered") delivered("delivered");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,69 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.server.models
|
||||||
|
|
||||||
|
import org.openapitools.server.models.Category
|
||||||
|
import org.openapitools.server.models.Tag
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
/**
|
||||||
|
* A pet for sale in the pet store
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @param photoUrls
|
||||||
|
* @param id
|
||||||
|
* @param category
|
||||||
|
* @param tags
|
||||||
|
* @param status pet status in the store
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
data class Pet (
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("name")
|
||||||
|
val name: kotlin.String,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("photoUrls")
|
||||||
|
val photoUrls: kotlin.collections.List<kotlin.String>,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("id")
|
||||||
|
val id: kotlin.Long? = null,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("category")
|
||||||
|
val category: Category? = null,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("tags")
|
||||||
|
val tags: kotlin.collections.List<Tag>? = null,
|
||||||
|
|
||||||
|
/* pet status in the store */
|
||||||
|
|
||||||
|
@JsonProperty("status")
|
||||||
|
val status: Pet.Status? = null
|
||||||
|
|
||||||
|
) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pet status in the store
|
||||||
|
*
|
||||||
|
* Values: available,pending,sold
|
||||||
|
*/
|
||||||
|
enum class Status(val value: kotlin.String) {
|
||||||
|
@JsonProperty(value = "available") available("available"),
|
||||||
|
@JsonProperty(value = "pending") pending("pending"),
|
||||||
|
@JsonProperty(value = "sold") sold("sold");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.server.models
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
/**
|
||||||
|
* A tag for a pet
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
data class Tag (
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("id")
|
||||||
|
val id: kotlin.Long? = null,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("name")
|
||||||
|
val name: kotlin.String? = null
|
||||||
|
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,65 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.server.models
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
/**
|
||||||
|
* A User who is purchasing from the pet store
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param username
|
||||||
|
* @param firstName
|
||||||
|
* @param lastName
|
||||||
|
* @param email
|
||||||
|
* @param password
|
||||||
|
* @param phone
|
||||||
|
* @param userStatus User Status
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
data class User (
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("id")
|
||||||
|
val id: kotlin.Long? = null,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("username")
|
||||||
|
val username: kotlin.String? = null,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("firstName")
|
||||||
|
val firstName: kotlin.String? = null,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("lastName")
|
||||||
|
val lastName: kotlin.String? = null,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("email")
|
||||||
|
val email: kotlin.String? = null,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("password")
|
||||||
|
val password: kotlin.String? = null,
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("phone")
|
||||||
|
val phone: kotlin.String? = null,
|
||||||
|
|
||||||
|
/* User Status */
|
||||||
|
|
||||||
|
@JsonProperty("userStatus")
|
||||||
|
val userStatus: kotlin.Int? = null
|
||||||
|
|
||||||
|
)
|
||||||
|
|
@ -7,7 +7,7 @@ wrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = "1.4.32"
|
ext.kotlin_version = "1.7.20"
|
||||||
ext.swagger_annotations_version = "1.5.3"
|
ext.swagger_annotations_version = "1.5.3"
|
||||||
ext.jakarta_annotations_version = "1.3.5"
|
ext.jakarta_annotations_version = "1.3.5"
|
||||||
ext.jakarta_ws_rs_version = "2.1.6"
|
ext.jakarta_ws_rs_version = "2.1.6"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user