Skip to content

Commit 8cff171

Browse files
authored
[UNOMI-899] Replace jaxrs-analyzer-maven-plugin with an alternative for Swagger documentation generation (#732)
* UNOMI-906: Add build info file at root of tar.gz * UNOMI-899: Remove jaxrs-analyzer and fix swagger-ui openapi doc. * UNOMI-899: Use karaf features for jackson.
1 parent 73c9ea9 commit 8cff171

File tree

9 files changed

+211
-30
lines changed

9 files changed

+211
-30
lines changed

docker/src/main/docker/docker-compose-build.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,43 @@
1717
version: '2.4'
1818
services:
1919
elasticsearch:
20-
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.28
21-
volumes: # Persist ES data in seperate "esdata" volume
22-
- esdata1:/usr/share/elasticsearch/data
20+
image: docker.elastic.co/elasticsearch/elasticsearch:9.1.3
21+
volumes:
22+
- unomi-3-elasticsearch-data:/usr/share/elasticsearch/data
2323
environment:
2424
- bootstrap.memory_lock=true
2525
- "ES_JAVA_OPTS=-Xms1G -Xmx1G"
2626
- discovery.type=single-node
2727
- xpack.security.enabled=false
2828
- cluster.name=contextElasticSearch
29-
ports: # Expose Elasticsearch ports
30-
- "9200:9200"
29+
networks:
30+
- unomi-3
31+
ports:
32+
- 9200:9200
3133

32-
unomi:
34+
node-1:
3335
build: .
3436
image: apache/unomi:${project.version}
35-
container_name: unomi
3637
environment:
3738
- UNOMI_ELASTICSEARCH_ADDRESSES=elasticsearch:9200
3839
ports:
3940
- 8181:8181
4041
- 9443:9443
4142
- 8102:8102
43+
networks:
44+
- unomi-3
4245
links:
4346
- elasticsearch
4447
depends_on:
4548
- elasticsearch
4649

47-
48-
volumes: # Define seperate volume for Elasticsearch data
49-
esdata1:
50+
volumes:
51+
unomi-3-elasticsearch-data:
5052
driver: local
53+
54+
networks:
55+
unomi-3:
56+
name: unomi-3
57+
ipam:
58+
config:
59+
- subnet: 172.24.32.0/24
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
################################################################################
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
################################################################################
17+
version: '2.4'
18+
services:
19+
elasticsearch:
20+
image: docker.elastic.co/elasticsearch/elasticsearch:9.1.3
21+
volumes:
22+
- unomi-3-elasticsearch-data:/usr/share/elasticsearch/data
23+
environment:
24+
- bootstrap.memory_lock=true
25+
- "ES_JAVA_OPTS=-Xms1G -Xmx1G"
26+
- discovery.type=single-node
27+
- xpack.security.enabled=false
28+
- cluster.name=contextElasticSearch
29+
networks:
30+
- unomi-3
31+
ports:
32+
- 9200:9200
33+
34+
node-1:
35+
image: apache/unomi:${project.version}
36+
environment:
37+
- UNOMI_ELASTICSEARCH_ADDRESSES=elasticsearch:9200
38+
- UNOMI_CLUSTER_NODEID=unomi-3-node-1
39+
ports:
40+
- 8181:8181
41+
- 9443:9443
42+
- 8102:8102
43+
networks:
44+
- unomi-3
45+
links:
46+
- elasticsearch
47+
depends_on:
48+
- elasticsearch
49+
50+
wait-for-node-1:
51+
image: alpine:latest
52+
command: sh -c "echo 'Wait 3 minutes before starting unomi-3-node-2...' && sleep 180"
53+
depends_on:
54+
- node-1
55+
56+
node-2:
57+
image: apache/unomi:${project.version}
58+
environment:
59+
- UNOMI_ELASTICSEARCH_ADDRESSES=elasticsearch:9200
60+
- UNOMI_CLUSTER_NODEID=unomi-3-node-2
61+
ports:
62+
- 8182:8181
63+
- 9444:9443
64+
- 8103:8102
65+
networks:
66+
- unomi-3
67+
links:
68+
- elasticsearch
69+
depends_on:
70+
- wait-for-node-1
71+
72+
volumes:
73+
unomi-3-elasticsearch-data:
74+
driver: local
75+
76+
networks:
77+
unomi-3:
78+
name: unomi-3
79+
ipam:
80+
config:
81+
- subnet: 172.24.32.0/24

docker/src/main/docker/docker-compose.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,42 @@
1717
version: '2.4'
1818
services:
1919
elasticsearch:
20-
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.28
21-
volumes: # Persist ES data in separate "esdata" volume
22-
- esdata1:/usr/share/elasticsearch/data
20+
image: docker.elastic.co/elasticsearch/elasticsearch:9.1.3
21+
volumes:
22+
- unomi-3-elasticsearch-data:/usr/share/elasticsearch/data
2323
environment:
2424
- bootstrap.memory_lock=true
2525
- "ES_JAVA_OPTS=-Xms1G -Xmx1G"
2626
- discovery.type=single-node
2727
- xpack.security.enabled=false
2828
- cluster.name=contextElasticSearch
29-
ports: # Expose Elasticsearch ports
30-
- "9200:9200"
29+
networks:
30+
- unomi-3
31+
ports:
32+
- 9200:9200
3133

32-
unomi:
34+
node-1:
3335
image: apache/unomi:${project.version}
34-
container_name: unomi
3536
environment:
3637
- UNOMI_ELASTICSEARCH_ADDRESSES=elasticsearch:9200
3738
ports:
3839
- 8181:8181
3940
- 9443:9443
4041
- 8102:8102
42+
networks:
43+
- unomi-3
4144
links:
4245
- elasticsearch
4346
depends_on:
4447
- elasticsearch
4548

46-
47-
volumes: # Define separate volume for Elasticsearch data
48-
esdata1:
49+
volumes:
50+
unomi-3-elasticsearch-data:
4951
driver: local
52+
53+
networks:
54+
unomi-3:
55+
name: unomi-3
56+
ipam:
57+
config:
58+
- subnet: 172.24.32.0/24

kar/src/main/feature/feature.xml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
<feature>feature</feature>
3939
<feature>spifly</feature>
4040
<feature>shell-compat</feature>
41+
<feature>jackson</feature>
42+
<feature>jackson-jaxrs</feature>
4143
<configfile finalname="/etc/org.apache.unomi.web.cfg">mvn:org.apache.unomi/unomi-wab/${project.version}/cfg/unomicfg</configfile>
4244
<configfile finalname="/etc/org.apache.unomi.persistence.elasticsearch.cfg">mvn:org.apache.unomi/unomi-persistence-elasticsearch-core/${project.version}/cfg/elasticsearchcfg</configfile>
4345
<configfile finalname="/etc/org.apache.unomi.services.cfg">mvn:org.apache.unomi/unomi-services/${project.version}/cfg/servicescfg</configfile>
@@ -54,21 +56,16 @@
5456
<bundle start-level="55">mvn:org.apache.httpcomponents/httpcore-osgi/${httpcore-osgi.version}</bundle>
5557
<bundle start-level="55">mvn:org.apache.httpcomponents/httpclient-osgi/${httpclient-osgi.version}</bundle>
5658
<bundle start-level="55">mvn:javax.validation/validation-api/${javax-validation.version}</bundle>
57-
<bundle start-level="55">mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle>
58-
<bundle start-level="55">mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version}</bundle>
59-
<bundle start-level="55">mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version}</bundle>
60-
<bundle start-level="55">mvn:com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/${jackson.version}</bundle>
59+
<!-- Jackson bundles not included in any karaf feature -->
6160
<bundle start-level="55">mvn:com.fasterxml.jackson.datatype/jackson-datatype-jsr310/${jackson.version}</bundle>
6261
<bundle start-level="55">mvn:com.fasterxml.jackson.module/jackson-module-jaxb-annotations/${jackson.version}</bundle>
63-
<bundle start-level="55">mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-base/${jackson.version}</bundle>
64-
<bundle start-level="55">mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider/${jackson.version}</bundle>
62+
6563
<bundle start-level="55">mvn:com.github.java-json-tools/btf/${btf.version}</bundle>
6664
<bundle start-level="55">mvn:com.github.java-json-tools/msg-simple/${msg-simple.version}</bundle>
6765
<bundle start-level="55">mvn:com.github.java-json-tools/jackson-coreutils/${jackson-coreutils.version}</bundle>
6866
<bundle start-level="55">mvn:com.github.java-json-tools/json-patch/${json-patch.version}</bundle>
6967
<bundle start-level="55">mvn:com.google.guava/guava/${guava.version}</bundle>
7068
<bundle start-level="55">mvn:org.json/json/${org-json.version}</bundle>
71-
<bundle start-level="55">mvn:org.yaml/snakeyaml/${snakeyaml.version}</bundle>
7269
<bundle start-level="55">mvn:joda-time/joda-time/${joda-time.version}</bundle>
7370
<bundle start-level="55">mvn:jakarta.annotation/jakarta.annotation-api/${jakarta-annotation-api.version}</bundle>
7471
<bundle start-level="55">mvn:com.google.code.findbugs/jsr305/${jsr305.version}</bundle>

package/pom.xml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
<properties>
4545
<appendedResourcesDirectory>${basedir}/../etc/appended-resources</appendedResourcesDirectory>
46+
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
4647
</properties>
4748

4849
<dependencies>
@@ -134,6 +135,53 @@
134135
</resource>
135136
</resources>
136137
<plugins>
138+
<plugin>
139+
<groupId>org.codehaus.mojo</groupId>
140+
<artifactId>buildnumber-maven-plugin</artifactId>
141+
<executions>
142+
<execution>
143+
<phase>validate</phase>
144+
<goals>
145+
<goal>create</goal>
146+
</goals>
147+
</execution>
148+
</executions>
149+
<configuration>
150+
<doCheck>false</doCheck>
151+
<doUpdate>false</doUpdate>
152+
<shortRevisionLength>8</shortRevisionLength>
153+
</configuration>
154+
</plugin>
155+
<plugin>
156+
<groupId>org.apache.maven.plugins</groupId>
157+
<artifactId>maven-resources-plugin</artifactId>
158+
<executions>
159+
<execution>
160+
<id>process-resources</id>
161+
<goals>
162+
<goal>resources</goal>
163+
</goals>
164+
<configuration>
165+
<resources>
166+
<resource>
167+
<directory>${project.basedir}/src/main/resources</directory>
168+
<filtering>true</filtering>
169+
<includes>
170+
<include>BUILD</include>
171+
</includes>
172+
</resource>
173+
<resource>
174+
<directory>${project.basedir}/src/main/resources</directory>
175+
<filtering>false</filtering>
176+
<excludes>
177+
<exclude>BUILD</exclude>
178+
</excludes>
179+
</resource>
180+
</resources>
181+
</configuration>
182+
</execution>
183+
</executions>
184+
</plugin>
137185
<plugin>
138186
<groupId>org.apache.maven.plugins</groupId>
139187
<artifactId>maven-dependency-plugin</artifactId>

package/src/main/resources/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Version: ${project.version}
2+
Build tag: ${buildNumber}
3+
Build timestamp: ${maven.build.timestamp}

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<maven.compiler.release>${java.version}</maven.compiler.release>
6565

6666
<karaf.version>4.4.8</karaf.version>
67-
<elasticsearch.version>9.0.3</elasticsearch.version>
67+
<elasticsearch.version>9.1.3</elasticsearch.version>
6868
<elasticsearch.test.version>9.1.3</elasticsearch.test.version>
6969
<javax-validation.version>1.1.0.Final</javax-validation.version>
7070
<commons-lang3.version>3.18.0</commons-lang3.version>
@@ -73,7 +73,7 @@
7373
<commons-beanutils.version>1.11.0</commons-beanutils.version>
7474
<commons-collections.version>3.2.2</commons-collections.version>
7575
<mvel2.version>2.5.2.Final</mvel2.version>
76-
<snakeyaml.version>2.4</snakeyaml.version>
76+
<snakeyaml.version>2.3</snakeyaml.version>
7777
<opencsv.version>3.10</opencsv.version>
7878
<log4j.version>2.19.0</log4j.version>
7979
<lucene.version>9.12.2</lucene.version>
@@ -92,7 +92,7 @@
9292
<jakarta-annotation-api.version>3.0.0</jakarta-annotation-api.version>
9393
<jakarta-json-api.version>2.1.2</jakarta-json-api.version>
9494
<swagger-ui.version>5.27.1</swagger-ui.version>
95-
<cxf.version>3.6.5</cxf.version>
95+
<cxf.version>3.6.8</cxf.version>
9696
<rs-api.version>2.1</rs-api.version>
9797
<groovy.version>4.0.28</groovy.version>
9898
<httpclient-osgi.version>4.5.14</httpclient-osgi.version>

rest/src/main/java/org/apache/unomi/rest/server/RestServer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.cxf.jaxrs.openapi.OpenApiCustomizer;
2727
import org.apache.cxf.jaxrs.openapi.OpenApiFeature;
2828
import org.apache.cxf.jaxrs.security.SimpleAuthorizingFilter;
29+
import org.apache.cxf.jaxrs.swagger.ui.SwaggerUiConfig;
2930
import org.apache.cxf.message.Message;
3031
import org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter;
3132
import org.apache.unomi.api.ContextRequest;
@@ -236,6 +237,8 @@ public void run() {
236237
openApiFeature.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
237238
openApiFeature.setScan(false);
238239
openApiFeature.setUseContextBasedConfig(true);
240+
SwaggerUiConfig swaggerUiConfig = new SwaggerUiConfig().url("openapi.json").deepLinking(true).queryConfigEnabled(false);
241+
openApiFeature.setSwaggerUiConfig(swaggerUiConfig);
239242
OpenApiCustomizer customizer = new OpenApiCustomizer();
240243
customizer.setDynamicBasePath(true);
241244
openApiFeature.setCustomizer(customizer);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
window.onload = function() {
18+
window.ui = SwaggerUIBundle({
19+
url: "/openapi.json",
20+
dom_id: '#swagger-ui',
21+
deepLinking: true,
22+
presets: [
23+
SwaggerUIBundle.presets.apis,
24+
SwaggerUIStandalonePreset
25+
],
26+
plugins: [
27+
SwaggerUIBundle.plugins.DownloadUrl
28+
],
29+
layout: "StandaloneLayout"
30+
});
31+
};

0 commit comments

Comments
 (0)