forked from OpenAPITools/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Kotlin][Server] Skip new post processing routine for kotlin server j…
…axrs (OpenAPITools#18180) * Skip post processing when generating JAXRS spec with Kotlin This feature was previously added to work with the javalin5 library * Add sample that proves what we expect after fixing this * Update sample * Added new samples to samples workflow * Revert from jdk17 pipeline
- Loading branch information
Showing
14 changed files
with
330 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
generatorName: kotlin-server | ||
outputDir: samples/server/others/kotlin-server/jaxrs-spec-array-response | ||
library: jaxrs-spec | ||
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/issue18177-array.yaml | ||
templateDir: modules/openapi-generator/src/main/resources/kotlin-server | ||
additionalProperties: | ||
interfaceOnly: "true" | ||
useJakartaEe: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
modules/openapi-generator/src/test/resources/3_0/kotlin/issue18177-array.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
openapi: 3.0.0 | ||
servers: | ||
- url: 'https://example.org/v1' | ||
info: | ||
description: >- | ||
Example created | ||
version: 1.0.0 | ||
title: OpenAPI Stuff API created to reproduce issue | ||
license: | ||
name: Apache-2.0 | ||
url: 'https://www.apache.org/licenses/LICENSE-2.0.html' | ||
tags: | ||
- name: stuff | ||
description: All about the stuff | ||
security: | ||
- bearerAuth: [] | ||
paths: | ||
/stuff: | ||
get: | ||
tags: | ||
- stuff | ||
summary: Finds stuff | ||
description: Finds stuff | ||
operationId: findStuff | ||
responses: | ||
'200': | ||
description: successful operation | ||
content: | ||
application/json: | ||
schema: | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/Stuff' | ||
'400': | ||
description: Invalid status value | ||
/uniquestuff: | ||
get: | ||
tags: | ||
- stuff | ||
summary: Finds unique stuff | ||
description: Finds unique stuff | ||
operationId: find unique Stuff | ||
responses: | ||
'200': | ||
description: successful operation | ||
content: | ||
application/json: | ||
schema: | ||
type: array | ||
uniqueItems: true | ||
items: | ||
$ref: '#/components/schemas/Stuff' | ||
'400': | ||
description: Invalid status value | ||
externalDocs: | ||
description: Find out more about Swagger | ||
url: 'http://swagger.io' | ||
components: | ||
securitySchemes: | ||
bearerAuth: | ||
type: http | ||
scheme: bearer | ||
bearerFormat: JWT | ||
schemas: | ||
Stuff: | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
format: int64 | ||
name: | ||
type: string | ||
tag: | ||
type: string | ||
required: | ||
- name | ||
|
23 changes: 23 additions & 0 deletions
23
samples/server/others/kotlin-server/jaxrs-spec-array-response/.openapi-generator-ignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
6 changes: 6 additions & 0 deletions
6
samples/server/others/kotlin-server/jaxrs-spec-array-response/.openapi-generator/FILES
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
README.md | ||
build.gradle | ||
gradle.properties | ||
settings.gradle | ||
src/main/kotlin/org/openapitools/server/apis/StuffApi.kt | ||
src/main/kotlin/org/openapitools/server/models/Stuff.kt |
1 change: 1 addition & 0 deletions
1
samples/server/others/kotlin-server/jaxrs-spec-array-response/.openapi-generator/VERSION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
7.5.0-SNAPSHOT |
56 changes: 56 additions & 0 deletions
56
samples/server/others/kotlin-server/jaxrs-spec-array-response/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# org.openapitools.server - Kotlin Server library for OpenAPI Stuff API created to reproduce issue | ||
|
||
## 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 *https://example.org/v1* | ||
|
||
Class | Method | HTTP request | Description | ||
------------ | ------------- | ------------- | ------------- | ||
*StuffApi* | [**findStuff**](docs/StuffApi.md#findstuff) | **GET** /stuff | Finds stuff | ||
*StuffApi* | [**findUniqueStuff**](docs/StuffApi.md#finduniquestuff) | **GET** /uniquestuff | Finds unique stuff | ||
|
||
|
||
<a id="documentation-for-models"></a> | ||
## Documentation for Models | ||
|
||
- [org.openapitools.server.models.Stuff](docs/Stuff.md) | ||
|
||
|
||
<a id="documentation-for-authorization"></a> | ||
## Documentation for Authorization | ||
|
||
|
||
Authentication schemes defined for the API: | ||
<a id="bearerAuth"></a> | ||
### bearerAuth | ||
|
||
- **Type**: HTTP Bearer Token authentication (JWT) | ||
|
51 changes: 51 additions & 0 deletions
51
samples/server/others/kotlin-server/jaxrs-spec-array-response/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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 = "2.1.1" | ||
ext.jakarta_ws_rs_version = "3.1.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") | ||
testImplementation("junit:junit:4.13.2") | ||
} |
1 change: 1 addition & 0 deletions
1
samples/server/others/kotlin-server/jaxrs-spec-array-response/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.gradle.caching=true |
1 change: 1 addition & 0 deletions
1
samples/server/others/kotlin-server/jaxrs-spec-array-response/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = 'kotlin-server' |
26 changes: 26 additions & 0 deletions
26
...server/jaxrs-spec-array-response/src/main/kotlin/org/openapitools/server/apis/StuffApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.openapitools.server.apis; | ||
|
||
import org.openapitools.server.models.Stuff | ||
|
||
import jakarta.ws.rs.* | ||
import jakarta.ws.rs.core.Response | ||
|
||
|
||
import java.io.InputStream | ||
|
||
|
||
|
||
@Path("/") | ||
@jakarta.annotation.Generated(value = arrayOf("org.openapitools.codegen.languages.KotlinServerCodegen"), comments = "Generator version: 7.5.0-SNAPSHOT") | ||
interface StuffApi { | ||
|
||
@GET | ||
@Path("/stuff") | ||
@Produces("application/json") | ||
fun findStuff(): kotlin.collections.List<Stuff> | ||
|
||
@GET | ||
@Path("/uniquestuff") | ||
@Produces("application/json") | ||
fun findUniqueStuff(): kotlin.collections.Set<Stuff> | ||
} |
39 changes: 39 additions & 0 deletions
39
...-server/jaxrs-spec-array-response/src/main/kotlin/org/openapitools/server/models/Stuff.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* OpenAPI Stuff API created to reproduce issue | ||
* Example created | ||
* | ||
* 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 | ||
/** | ||
* | ||
* | ||
* @param name | ||
* @param id | ||
* @param tag | ||
*/ | ||
|
||
|
||
data class Stuff ( | ||
|
||
|
||
@JsonProperty("name") | ||
val name: kotlin.String, | ||
|
||
|
||
@JsonProperty("id") | ||
val id: kotlin.Long? = null, | ||
|
||
|
||
@JsonProperty("tag") | ||
val tag: kotlin.String? = null | ||
|
||
) | ||
|