Skip to content

Commit b42857b

Browse files
committed
fixes #4 update petstore with the new generator
1 parent 18cb21b commit b42857b

27 files changed

+446
-240
lines changed

openapi/petstore/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
plugins {
33
application
4-
kotlin("jvm") version "1.3.21"
4+
kotlin("jvm") version "1.3.50"
55
// https://github.com/ben-manes/gradle-versions-plugin
66
id("com.github.ben-manes.versions") version "0.20.0"
77
// https://github.com/johnrengelman/shadow

openapi/petstore/build.sh

100644100755
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ showHelp() {
2020

2121
build() {
2222
echo "Building ..."
23-
mvn clean install
23+
24+
./gradlew clean build
25+
2426
echo "Successfully built!"
2527
}
2628

@@ -35,7 +37,7 @@ cleanup() {
3537
publish() {
3638
echo "Building Docker image with version $VERSION"
3739
docker build -t $IMAGE_NAME:$VERSION -t $IMAGE_NAME:latest -f ./docker/Dockerfile . --no-cache=true
38-
docker build -t $IMAGE_NAME:$VERSION-redhat -f ./docker/Dockerfile-Redhat . --no-cache=true
40+
docker build -t $IMAGE_NAME:$VERSION-redhat -f ./docker/Dockerfile-Slim . --no-cache=true
3941
echo "Images built with version $VERSION"
4042
echo "Pushing image to DockerHub"
4143
docker push $IMAGE_NAME

openapi/petstore/docker/Dockerfile

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11

2-
FROM openjdk:8-jre-alpine
3-
#EXPOSE 8443
4-
ADD /build/libs/petstore.jar server.jar
5-
CMD ["/bin/sh","-c","java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1 -Dlight-4j-config-dir=/config -Dlogback.configurationFile=/config/logback.xml -jar /server.jar"]
2+
FROM azul/zulu-openjdk-alpine:11 as packager
3+
4+
RUN { \
5+
java --version ; \
6+
echo "jlink version:" && \
7+
$JAVA_HOME/bin/jlink --version ; \
8+
}
9+
10+
ENV JAVA_MINIMAL=/opt/jre
11+
12+
# build modules distribution
13+
RUN $JAVA_HOME/bin/jlink \
14+
--verbose \
15+
--add-modules \
16+
java.base,java.sql,java.naming,java.desktop,java.xml,jdk.crypto.cryptoki,jdk.crypto.ec,jdk.unsupported,java.management,java.security.jgss,java.net.http \
17+
--compress 2 \
18+
--strip-debug \
19+
--no-header-files \
20+
--no-man-pages \
21+
--output "$JAVA_MINIMAL"
22+
23+
# Second stage, add only our minimal "JRE" distr and our app
24+
FROM alpine
25+
26+
ENV JAVA_MINIMAL=/opt/jre
27+
ENV PATH="$PATH:$JAVA_MINIMAL/bin"
28+
29+
COPY --from=packager "$JAVA_MINIMAL" "$JAVA_MINIMAL"
30+
31+
COPY /build/libs/petstore.jar server.jar
32+
33+
CMD ["/bin/sh","-c","java -Dlight-4j-config-dir=/config -Dlogback.configurationFile=/config/logback.xml -jar /server.jar"]

openapi/petstore/docker/Dockerfile-Redhat

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
FROM openjdk:11.0.3-slim
3+
4+
COPY /build/libs/petstore.jar server.jar
5+
6+
CMD ["/bin/sh","-c","java -Dlight-4j-config-dir=/config -Dlogback.configurationFile=/config/logback.xml -jar /server.jar"]

openapi/petstore/gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
# Versions of Frequently used Libraries
33
kafkaVersion=2.0.0
4-
light4jVersion=1.6.5-SNAPSHOT
5-
jacksonVersion=2.10.4
4+
light4jVersion=2.0.24-SNAPSHOT
5+
jacksonVersion=2.12.1
66
undertowVersion=2.1.3.Final
77
logbackVersion=1.2.3
88
jsonSchemaValidatorVersion=1.0.29

openapi/petstore/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://repo.gradle.org/gradle/kotlin-dsl-snapshots-local/gradle-kotlin-dsl-5.2-20190201174223+0000-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip

openapi/petstore/src/main/kotlin/com/networknt/petstore/handler/PetsPostHandler.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class PetsPostHandler : LightHttpHandler {
88

99
@Throws(Exception::class)
1010
override fun handleRequest(exchange: HttpServerExchange) {
11-
exchange.endExchange()
11+
exchange.responseHeaders.add(HttpString("Content-Type"), "application/json")
12+
exchange.responseSender.send("{}")
1213
}
1314
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.networknt.petstore.model;
22
data class Error (
3-
val message: String,
3+
val code: Integer,
44

55

6-
val code: Int
6+
val message: String
77
)
88

openapi/petstore/src/main/kotlin/com/networknt/petstore/model/Pet.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.networknt.petstore.model;
22
data class Pet (
3-
val name: String,
3+
val id: java.lang.Long,
44

5-
val id: Long,
5+
val name: String,
66

77

88
val tag: String

0 commit comments

Comments
 (0)