Skip to content

Commit d186306

Browse files
committed
fix status annotation and add compile-test samples
1 parent b92e778 commit d186306

108 files changed

Lines changed: 5971 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/samples-kotlin-server-jdk17.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
# server
3737
- samples/server/petstore/kotlin-server-required-and-nullable-properties
3838
- samples/server/petstore/kotlin-springboot-3
39+
- samples/server/petstore/kotlin-springboot-3-no-response-entity
3940
- samples/server/petstore/kotlin-springboot-additionalproperties
4041
- samples/server/petstore/kotlin-springboot-delegate-nodefaults
4142
- samples/server/petstore/kotlin-springboot-request-cookie

.github/workflows/samples-kotlin-server.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
sample:
3030
# server
3131
- samples/server/petstore/kotlin-springboot
32+
- samples/server/petstore/kotlin-springboot-no-response-entity
33+
- samples/server/petstore/kotlin-springboot-no-response-entity-delegate
3234
- samples/server/petstore/kotlin-springboot-multipart-request-model
3335
- samples/server/petstore/kotlin-springboot-bigdecimal-default
3436
- samples/server/petstore/kotlin-springboot-delegate
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
generatorName: kotlin-spring
2+
outputDir: samples/server/petstore/kotlin-springboot-3-no-response-entity
3+
library: spring-boot
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
6+
additionalProperties:
7+
documentationProvider: none
8+
annotationLibrary: none
9+
useSwaggerUI: "false"
10+
serviceImplementation: "true"
11+
serializableModel: "true"
12+
beanValidations: "true"
13+
useSpringBoot3: "true"
14+
requestMappingMode: api_interface
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
generatorName: kotlin-spring
2+
outputDir: samples/server/petstore/kotlin-springboot-no-response-entity-delegate
3+
library: spring-boot
4+
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
6+
additionalProperties:
7+
documentationProvider: none
8+
annotationLibrary: none
9+
useSwaggerUI: "false"
10+
serviceImplementation: "true"
11+
serializableModel: "true"
12+
beanValidations: "true"
13+
useResponseEntity: "false"
14+
delegatePattern: true
15+
requestMappingMode: controller
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
generatorName: kotlin-spring
2+
outputDir: samples/server/petstore/kotlin-springboot-no-response-entity
3+
library: spring-boot
4+
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
6+
additionalProperties:
7+
documentationProvider: none
8+
annotationLibrary: none
9+
useSwaggerUI: "false"
10+
serviceImplementation: "true"
11+
serializableModel: "true"
12+
beanValidations: "true"
13+
useResponseEntity: "false"
14+
requestMappingMode: controller

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.openapitools.codegen.model.ModelsMap;
3434
import org.openapitools.codegen.model.OperationMap;
3535
import org.openapitools.codegen.model.OperationsMap;
36+
import org.openapitools.codegen.templating.mustache.SpringHttpStatusLambda;
3637
import org.openapitools.codegen.utils.ModelUtils;
3738
import org.openapitools.codegen.utils.URLPathUtils;
3839
import org.slf4j.Logger;
@@ -473,6 +474,7 @@ public void processOpts() {
473474
this.setUseResponseEntity(Boolean.parseBoolean(additionalProperties.get(USE_RESPONSE_ENTITY).toString()));
474475
}
475476
writePropertyBack(USE_RESPONSE_ENTITY, useResponseEntity);
477+
additionalProperties.put("springHttpStatus", new SpringHttpStatusLambda());
476478

477479
// Set basePackage from invokerPackage
478480
if (!additionalProperties.containsKey(BASE_PACKAGE)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
README.md
2+
build.gradle.kts
3+
gradle/wrapper/gradle-wrapper.jar
4+
gradle/wrapper/gradle-wrapper.properties
5+
gradlew
6+
gradlew.bat
7+
pom.xml
8+
settings.gradle
9+
src/main/kotlin/org/openapitools/Application.kt
10+
src/main/kotlin/org/openapitools/api/ApiUtil.kt
11+
src/main/kotlin/org/openapitools/api/Exceptions.kt
12+
src/main/kotlin/org/openapitools/api/PetApiController.kt
13+
src/main/kotlin/org/openapitools/api/PetApiService.kt
14+
src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt
15+
src/main/kotlin/org/openapitools/api/StoreApiController.kt
16+
src/main/kotlin/org/openapitools/api/StoreApiService.kt
17+
src/main/kotlin/org/openapitools/api/StoreApiServiceImpl.kt
18+
src/main/kotlin/org/openapitools/api/UserApiController.kt
19+
src/main/kotlin/org/openapitools/api/UserApiService.kt
20+
src/main/kotlin/org/openapitools/api/UserApiServiceImpl.kt
21+
src/main/kotlin/org/openapitools/model/Category.kt
22+
src/main/kotlin/org/openapitools/model/ModelApiResponse.kt
23+
src/main/kotlin/org/openapitools/model/Order.kt
24+
src/main/kotlin/org/openapitools/model/Pet.kt
25+
src/main/kotlin/org/openapitools/model/Tag.kt
26+
src/main/kotlin/org/openapitools/model/User.kt
27+
src/main/resources/application.yaml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.18.0-SNAPSHOT
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# openAPIPetstore
2+
3+
This Kotlin based [Spring Boot](https://spring.io/projects/spring-boot) application has been generated using the [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator).
4+
5+
## Getting Started
6+
7+
This document assumes you have either maven or gradle available, either via the wrapper or otherwise. This does not come with a gradle / maven wrapper checked in.
8+
9+
By default a [`pom.xml`](pom.xml) file will be generated. If you specified `gradleBuildFile=true` when generating this project, a `build.gradle.kts` will also be generated. Note this uses [Gradle Kotlin DSL](https://github.com/gradle/kotlin-dsl).
10+
11+
To build the project using maven, run:
12+
```bash
13+
mvn package && java -jar target/openapi-spring-1.0.0.jar
14+
```
15+
16+
To build the project using gradle, run:
17+
```bash
18+
gradle build && java -jar build/libs/openapi-spring-1.0.0.jar
19+
```
20+
21+
If all builds successfully, the server should run on [http://localhost:8080/](http://localhost:8080/)

0 commit comments

Comments
 (0)