Skip to content

Commit bbb163d

Browse files
committed
Merge branch 'master' into update-from-template-github_com_xdev-software_standard-maven-template_master-merged
2 parents c597656 + 4627a09 commit bbb163d

8 files changed

Lines changed: 266 additions & 2 deletions

File tree

‎.config/topo/upstream.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
- url: https://github.com/xdev-software/standard-maven-template.git
1+
- url: https://github.com/xdev-software/openapi-client-maven-template.git
22
branch: master

‎.github/FUNDING.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
open_collective: openapi_generator

‎.run/Run Demo.run.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
<option name="Make" enabled="true" />
1313
</method>
1414
</configuration>
15-
</component>
15+
</component>

‎README.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/template-placeholder?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/template-placeholder)
22
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/template-placeholder/check-build.yml?branch=develop)](https://github.com/xdev-software/template-placeholder/actions/workflows/check-build.yml?query=branch%3Adevelop)
3+
[![API Specification Editor](https://img.shields.io/badge/API--Spec-Editor-85ea2d?logo=swagger)](https://editor.swagger.io/?url=https://raw.githubusercontent.com/xdev-software/template-placeholder/develop/openapi/openapi.yml)
34

45
# template-placeholder
56

7+
This client [is generated](./template-placeholder/pom.xml) from an [``openapi.yml``](./openapi/openapi.yml) using [OpenAPI Generator](https://openapi-generator.tech/).
68

79
## Installation
810
[Installation guide for the latest release](https://github.com/xdev-software/template-placeholder/releases/latest#Installation)
911

12+
## Demo
13+
A minimal demo is also available [here](./template-placeholder-demo/src/main/java/software/xdev/Application.java).
14+
1015
## Support
1116
If you need support as soon as possible and you can't wait for any pull request, feel free to use [our support](https://xdev.software/en/services-products/support).
1217

‎demos/template-placeholder-demo/pom.xml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
<properties>
1717
<mainClass>software.xdev.Application</mainClass>
18+
19+
<log4j2-version>2.26.1</log4j2-version>
1820
</properties>
1921

2022
<dependencies>
@@ -23,6 +25,19 @@
2325
<artifactId>template-placeholder</artifactId>
2426
<version>${project.version}</version>
2527
</dependency>
28+
29+
<!-- Logging -->
30+
<!-- SLF4J comes from Apache Httpclient -->
31+
<dependency>
32+
<groupId>org.apache.logging.log4j</groupId>
33+
<artifactId>log4j-core</artifactId>
34+
<version>${log4j2-version}</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.apache.logging.log4j</groupId>
38+
<artifactId>log4j-slf4j-impl</artifactId>
39+
<version>${log4j2-version}</version>
40+
</dependency>
2641
</dependencies>
2742

2843
<build>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
This `openapi.yml` was written manually as INSERT_NAME_HERE fails to provide an API schema or something similar.
2+
3+
The Java API Client can be generated using `mvn clean compile -P openapi-generator`.
4+
5+
Helpful links:
6+
* https://jsonformatter.org/json-to-jsonschema
7+
* https://swagger.io/specification/
8+
* https://editor.swagger.io/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

‎src/template-placeholder/pom.xml‎

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,238 @@
1616
<name>template-placeholder</name>
1717
<description>template-placeholder</description>
1818

19+
<properties>
20+
<generatedDirRelative>src/generated/java</generatedDirRelative>
21+
<generatedDir>${project.basedir}/${generatedDirRelative}</generatedDir>
22+
</properties>
23+
24+
<dependencies>
25+
<!-- HTTP client: apache client -->
26+
<dependency>
27+
<groupId>org.apache.httpcomponents.client5</groupId>
28+
<artifactId>httpclient5</artifactId>
29+
<version>5.6.5</version>
30+
</dependency>
31+
32+
<!-- JSON processing: jackson -->
33+
<dependency>
34+
<groupId>tools.jackson.core</groupId>
35+
<artifactId>jackson-databind</artifactId>
36+
<version>3.2.4</version>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.openapitools</groupId>
40+
<artifactId>jackson-databind-nullable</artifactId>
41+
<version>0.2.12</version>
42+
</dependency>
43+
44+
<dependency>
45+
<groupId>jakarta.annotation</groupId>
46+
<artifactId>jakarta.annotation-api</artifactId>
47+
<version>3.0.0</version>
48+
</dependency>
49+
</dependencies>
50+
51+
<build>
52+
<plugins>
53+
<plugin>
54+
<groupId>org.codehaus.mojo</groupId>
55+
<artifactId>build-helper-maven-plugin</artifactId>
56+
<version>3.6.2</version>
57+
<executions>
58+
<execution>
59+
<phase>generate-sources</phase>
60+
<goals>
61+
<goal>add-source</goal>
62+
</goals>
63+
<configuration>
64+
<sources>
65+
<source>${generatedDirRelative}</source>
66+
</sources>
67+
</configuration>
68+
</execution>
69+
</executions>
70+
</plugin>
71+
</plugins>
72+
</build>
73+
<profiles>
74+
<profile>
75+
<id>openapi-generator</id>
76+
<properties>
77+
<componentName>INSERT_NAME_HERE</componentName>
78+
79+
<openApiRelativeGeneratorDir>src/gen</openApiRelativeGeneratorDir>
80+
<openApiGeneratorDir>
81+
${project.basedir}/target/generated-sources/openapi/${openApiRelativeGeneratorDir}
82+
</openApiGeneratorDir>
83+
</properties>
84+
<build>
85+
<plugins>
86+
<plugin>
87+
<groupId>org.apache.maven.plugins</groupId>
88+
<artifactId>maven-clean-plugin</artifactId>
89+
<version>3.5.0</version>
90+
<executions>
91+
<execution>
92+
<id>pre-generation-clean</id>
93+
<phase>initialize</phase>
94+
<goals>
95+
<goal>clean</goal>
96+
</goals>
97+
<configuration>
98+
<excludeDefaultDirectories>true</excludeDefaultDirectories>
99+
<filesets>
100+
<fileset>
101+
<directory>${generatedDir}</directory>
102+
</fileset>
103+
</filesets>
104+
</configuration>
105+
</execution>
106+
<execution>
107+
<id>post-generation-clean</id>
108+
<phase>process-resources</phase>
109+
<goals>
110+
<goal>clean</goal>
111+
</goals>
112+
</execution>
113+
</executions>
114+
</plugin>
115+
<plugin>
116+
<groupId>org.openapitools</groupId>
117+
<artifactId>openapi-generator-maven-plugin</artifactId>
118+
<version>7.27.0</version>
119+
<executions>
120+
<execution>
121+
<goals>
122+
<goal>generate</goal>
123+
</goals>
124+
<configuration>
125+
<inputSpec>${project.basedir}/openapi/openapi.yml</inputSpec>
126+
<generatorName>java</generatorName>
127+
<configOptions>
128+
<sourceFolder>${openApiRelativeGeneratorDir}</sourceFolder>
129+
<library>apache-httpclient</library>
130+
<apiPackage>software.xdev.${componentName}.api</apiPackage>
131+
<modelPackage>software.xdev.${componentName}.model</modelPackage>
132+
<invokerPackage>software.xdev.${componentName}.client</invokerPackage>
133+
<!-- Otherwise throw and catch everywhere -->
134+
<useRuntimeException>true</useRuntimeException>
135+
<!-- Some fields of API have been ignored because they are unused -->
136+
<disallowAdditionalPropertiesIfNotPresent>false
137+
</disallowAdditionalPropertiesIfNotPresent>
138+
<!-- Use newer Jakarta EE instead of Javax -->
139+
<useJakartaEe>true</useJakartaEe>
140+
<hideGenerationTimestamp>true</hideGenerationTimestamp>
141+
<useJackson3>true</useJackson3>
142+
</configOptions>
143+
<!-- No tests and documentation because we don't use that -->
144+
<generateModelTests>false</generateModelTests>
145+
<generateApiTests>false</generateApiTests>
146+
<generateModelDocumentation>false</generateModelDocumentation>
147+
<generateApiDocumentation>false</generateApiDocumentation>
148+
</configuration>
149+
</execution>
150+
</executions>
151+
</plugin>
152+
<plugin>
153+
<groupId>org.apache.maven.plugins</groupId>
154+
<artifactId>maven-resources-plugin</artifactId>
155+
<version>3.5.0</version>
156+
<executions>
157+
<execution>
158+
<id>copy-generated-resources</id>
159+
<phase>process-sources</phase>
160+
<goals>
161+
<goal>copy-resources</goal>
162+
</goals>
163+
<configuration>
164+
<outputDirectory>${generatedDir}</outputDirectory>
165+
<resources>
166+
<resource>
167+
<directory>${openApiGeneratorDir}</directory>
168+
</resource>
169+
</resources>
170+
</configuration>
171+
</execution>
172+
</executions>
173+
</plugin>
174+
<plugin>
175+
<groupId>software.xdev</groupId>
176+
<artifactId>find-and-replace-maven-plugin</artifactId>
177+
<version>1.0.5</version>
178+
<executions>
179+
<execution>
180+
<!-- Remove so that we don't need additional dependency -->
181+
<id>remove-unused-import-com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider</id>
182+
<phase>process-sources</phase>
183+
<goals>
184+
<goal>file-contents</goal>
185+
</goals>
186+
<configuration>
187+
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/client/</baseDir>
188+
<fileMask>ApiClient.java</fileMask>
189+
<!-- @formatter:off DO NOT INTRODUCE LINE BREAK -->
190+
<findRegex>^import com\.fasterxml\.jackson\.jaxrs\.json\.JacksonJsonProvider;(\r?\n)</findRegex>
191+
<!-- @formatter:on -->
192+
<replaceLineBased>false</replaceLineBased>
193+
</configuration>
194+
</execution>
195+
<execution>
196+
<!-- Changes with each generator version -->
197+
<id>remove-generated-annotation</id>
198+
<phase>process-sources</phase>
199+
<goals>
200+
<goal>file-contents</goal>
201+
</goals>
202+
<configuration>
203+
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/</baseDir>
204+
<recursive>true</recursive>
205+
<fileMask>.java</fileMask>
206+
<findRegex>^@jakarta\.annotation\.Generated.*(\r?\n)</findRegex>
207+
<replaceAll>false</replaceAll>
208+
<replaceLineBased>false</replaceLineBased>
209+
</configuration>
210+
</execution>
211+
<execution>
212+
<!-- Requiring Java serialization indicates a serious misuse of the API -->
213+
<id>remove-serialVersionUID</id>
214+
<phase>process-sources</phase>
215+
<goals>
216+
<goal>file-contents</goal>
217+
</goals>
218+
<configuration>
219+
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/</baseDir>
220+
<recursive>true</recursive>
221+
<fileMask>.java</fileMask>
222+
<findRegex>^.*serialVersionUID.*(\r?\n)(\s*\r?\n)?</findRegex>
223+
<replaceAll>false</replaceAll>
224+
<replaceLineBased>false</replaceLineBased>
225+
</configuration>
226+
</execution>
227+
</executions>
228+
</plugin>
229+
</plugins>
230+
</build>
231+
</profile>
232+
<profile>
233+
<id>pmd</id>
234+
<build>
235+
<plugins>
236+
<plugin>
237+
<groupId>org.apache.maven.plugins</groupId>
238+
<artifactId>maven-pmd-plugin</artifactId>
239+
<version>3.28.0</version>
240+
<configuration>
241+
<rulesets>
242+
<ruleset>../../.config/pmd/java/ruleset.xml</ruleset>
243+
</rulesets>
244+
<excludeRoots>
245+
<excludeRoot>${generatedDir}</excludeRoot>
246+
</excludeRoots>
247+
</configuration>
248+
</plugin>
249+
</plugins>
250+
</build>
251+
</profile>
252+
</profiles>
19253
</project>

0 commit comments

Comments
 (0)