Skip to content

Commit

Permalink
Merge pull request #4001 from MDeLuise/fix-openapiVersion
Browse files Browse the repository at this point in the history
Display Custom Version and Build Number in Swagger UI
  • Loading branch information
Coduz authored Apr 10, 2024
2 parents 81a090d + aa5608a commit ec9ec75
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
5 changes: 5 additions & 0 deletions assembly/api/descriptors/kapua-api-jetty.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,10 @@
<source>${project.build.directory}/tmp/openapi.yaml</source>
<outputDirectory>var/opt/jetty/webapps/root/doc</outputDirectory>
</file>
<file>
<source>${project.basedir}/entrypoint/run-api</source>
<outputDirectory>var/opt/jetty</outputDirectory>
<fileMode>0777</fileMode>
</file>
</files>
</assembly>
2 changes: 2 additions & 0 deletions assembly/api/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ RUN chown -R 1000:0 /opt/jetty /var/opt/jetty && \
chmod -R g=u /opt/jetty /var/opt/jetty

USER 1000

ENTRYPOINT /var/opt/jetty/run-api
44 changes: 44 additions & 0 deletions assembly/api/entrypoint/run-api
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/sh
################################################################################
# Copyright (c) 2024, 2022 Red Hat Inc and others
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat Inc - initial API and implementation
# Eurotech
################################################################################

openapiFile=webapps/root/doc/openapi.yaml;

if [ -n "$COMMONS_VERSION" ]; then
# Replace the version and the build number in the openapi file
awk -v version="$COMMONS_VERSION" -v build_number="$COMMONS_BUILD_NUMBER" '{
if (!subbed && /version:/) {
gsub(/version: .*/, "version: " version "-" build_number)
subbed = 1
}
print
}' "$openapiFile" > "$openapiFile.tmp";

mv "$openapiFile.tmp" "$openapiFile";
fi;

# Append the Java option for commons.version if defined
if [ -n "$COMMONS_VERSION" ]; then
echo "Using commons version: $COMMONS_VERSION";
JAVA_OPTS="${JAVA_OPTS} -Dcommons.version=$COMMONS_VERSION"
fi

# Append the Java option for commons.build.number if defined
if [ -n "$COMMONS_BUILD_NUMBER" ]; then
echo "Using commons build number: $COMMONS_BUILD_NUMBER";
JAVA_OPTS="${JAVA_OPTS} -Dcommons.build.number=$COMMONS_BUILD_NUMBER";
fi

# Continue with startup
exec /var/opt/jetty/run-jetty "$@";
3 changes: 1 addition & 2 deletions assembly/console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@
<artifactId>kapua-security-certificate-internal</artifactId>
</dependency>

<!-- dependencies added otherwise the unix assembly doesn't know the arctifact
to add -->
<!-- dependencies added otherwise the unix assembly doesn't know the artifact to add -->
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-device-management-all-api</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions deployment/docker/compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ services:
- AUTH_TOKEN_TTL=${AUTH_TOKEN_TTL:-1800000}
- REFRESH_AUTH_TOKEN_TTL=${REFRESH_AUTH_TOKEN_TTL:-18000000}
- CORS_ENDPOINTS_REFRESH_INTERVAL=${CORS_ENDPOINTS_REFRESH_INTERVAL:-60}
- COMMONS_VERSION
- COMMONS_BUILD_NUMBER
job-engine:
container_name: job-engine
image: kapua/kapua-job-engine:${IMAGE_VERSION}
Expand Down

0 comments on commit ec9ec75

Please sign in to comment.