Skip to content

Commit a13312c

Browse files
committed
Merge branch 'master' into update-from-template-github_com_xdev-software_standard-maven-template_master-merged
2 parents 5fca134 + 540ac8c commit a13312c

8 files changed

Lines changed: 243 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
@@ -13,4 +13,4 @@
1313
<option name="Make" enabled="true" />
1414
</method>
1515
</configuration>
16-
</component>
16+
</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

‎openapi/INFO.md‎

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`` inside [``template-placeholder``](../template-placeholder/).
4+
5+
Helpful links:
6+
* https://jsonformatter.org/json-to-jsonschema
7+
* https://swagger.io/specification/
8+
* https://editor.swagger.io/

‎openapi/openapi.yml‎

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

‎template-placeholder-demo/pom.xml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2828

2929
<mainClass>software.xdev.Application</mainClass>
30+
31+
<log4j2-version>2.26.1</log4j2-version>
3032
</properties>
3133

3234
<dependencies>
@@ -35,6 +37,19 @@
3537
<artifactId>template-placeholder</artifactId>
3638
<version>${project.version}</version>
3739
</dependency>
40+
41+
<!-- Logging -->
42+
<!-- SLF4J comes from Apache Httpclient -->
43+
<dependency>
44+
<groupId>org.apache.logging.log4j</groupId>
45+
<artifactId>log4j-core</artifactId>
46+
<version>${log4j2-version}</version>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.apache.logging.log4j</groupId>
50+
<artifactId>log4j-slf4j-impl</artifactId>
51+
<version>${log4j2-version}</version>
52+
</dependency>
3853
</dependencies>
3954

4055
<build>

‎template-placeholder/pom.xml‎

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,37 @@
4747

4848
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4949
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
50+
51+
<generatedDirRelative>src/generated/java</generatedDirRelative>
5052
</properties>
5153

54+
<dependencies>
55+
<!-- HTTP client: apache client -->
56+
<dependency>
57+
<groupId>org.apache.httpcomponents.client5</groupId>
58+
<artifactId>httpclient5</artifactId>
59+
<version>5.6.3</version>
60+
</dependency>
61+
62+
<!-- JSON processing: jackson -->
63+
<dependency>
64+
<groupId>tools.jackson.core</groupId>
65+
<artifactId>jackson-databind</artifactId>
66+
<version>3.2.1</version>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.openapitools</groupId>
70+
<artifactId>jackson-databind-nullable</artifactId>
71+
<version>0.2.11</version>
72+
</dependency>
73+
74+
<dependency>
75+
<groupId>jakarta.annotation</groupId>
76+
<artifactId>jakarta.annotation-api</artifactId>
77+
<version>3.0.0</version>
78+
</dependency>
79+
</dependencies>
80+
5281
<build>
5382
<pluginManagement>
5483
<plugins>
@@ -137,6 +166,25 @@
137166
</execution>
138167
</executions>
139168
</plugin>
169+
170+
<plugin>
171+
<groupId>org.codehaus.mojo</groupId>
172+
<artifactId>build-helper-maven-plugin</artifactId>
173+
<version>3.6.1</version>
174+
<executions>
175+
<execution>
176+
<phase>generate-sources</phase>
177+
<goals>
178+
<goal>add-source</goal>
179+
</goals>
180+
<configuration>
181+
<sources>
182+
<source>${generatedDirRelative}</source>
183+
</sources>
184+
</configuration>
185+
</execution>
186+
</executions>
187+
</plugin>
140188
</plugins>
141189
</build>
142190
<profiles>
@@ -203,6 +251,165 @@
203251
</plugins>
204252
</build>
205253
</profile>
254+
<profile>
255+
<id>openapi-generator</id>
256+
<properties>
257+
<componentName>INSERT_NAME_HERE</componentName>
258+
259+
<generatedDir>${project.basedir}/${generatedDirRelative}</generatedDir>
260+
<openApiRelativeGeneratorDir>src/gen</openApiRelativeGeneratorDir>
261+
<openApiGeneratorDir>
262+
${project.basedir}/target/generated-sources/openapi/${openApiRelativeGeneratorDir}
263+
</openApiGeneratorDir>
264+
</properties>
265+
<build>
266+
<plugins>
267+
<plugin>
268+
<groupId>org.apache.maven.plugins</groupId>
269+
<artifactId>maven-clean-plugin</artifactId>
270+
<version>3.5.0</version>
271+
<executions>
272+
<execution>
273+
<id>pre-generation-clean</id>
274+
<phase>initialize</phase>
275+
<goals>
276+
<goal>clean</goal>
277+
</goals>
278+
<configuration>
279+
<excludeDefaultDirectories>true</excludeDefaultDirectories>
280+
<filesets>
281+
<fileset>
282+
<directory>${generatedDir}</directory>
283+
</fileset>
284+
</filesets>
285+
</configuration>
286+
</execution>
287+
<execution>
288+
<id>post-generation-clean</id>
289+
<phase>process-resources</phase>
290+
<goals>
291+
<goal>clean</goal>
292+
</goals>
293+
</execution>
294+
</executions>
295+
</plugin>
296+
<plugin>
297+
<groupId>org.openapitools</groupId>
298+
<artifactId>openapi-generator-maven-plugin</artifactId>
299+
<version>7.24.0</version>
300+
<executions>
301+
<execution>
302+
<goals>
303+
<goal>generate</goal>
304+
</goals>
305+
<configuration>
306+
<inputSpec>${project.basedir}/../openapi/openapi.yml</inputSpec>
307+
<generatorName>java</generatorName>
308+
<configOptions>
309+
<sourceFolder>${openApiRelativeGeneratorDir}</sourceFolder>
310+
<library>apache-httpclient</library>
311+
<apiPackage>software.xdev.${componentName}.api</apiPackage>
312+
<modelPackage>software.xdev.${componentName}.model</modelPackage>
313+
<invokerPackage>software.xdev.${componentName}.client</invokerPackage>
314+
<!-- Otherwise throw and catch everywhere -->
315+
<useRuntimeException>true</useRuntimeException>
316+
<!-- Some fields of API have been ignored because they are unused -->
317+
<disallowAdditionalPropertiesIfNotPresent>false
318+
</disallowAdditionalPropertiesIfNotPresent>
319+
<!-- Use newer Jakarta EE instead of Javax -->
320+
<useJakartaEe>true</useJakartaEe>
321+
<hideGenerationTimestamp>true</hideGenerationTimestamp>
322+
<useJackson3>true</useJackson3>
323+
</configOptions>
324+
<!-- No tests and documentation because we don't use that -->
325+
<generateModelTests>false</generateModelTests>
326+
<generateApiTests>false</generateApiTests>
327+
<generateModelDocumentation>false</generateModelDocumentation>
328+
<generateApiDocumentation>false</generateApiDocumentation>
329+
</configuration>
330+
</execution>
331+
</executions>
332+
</plugin>
333+
<plugin>
334+
<groupId>org.apache.maven.plugins</groupId>
335+
<artifactId>maven-resources-plugin</artifactId>
336+
<version>3.5.0</version>
337+
<executions>
338+
<execution>
339+
<id>copy-generated-resources</id>
340+
<phase>process-sources</phase>
341+
<goals>
342+
<goal>copy-resources</goal>
343+
</goals>
344+
<configuration>
345+
<outputDirectory>${generatedDir}</outputDirectory>
346+
<resources>
347+
<resource>
348+
<directory>${openApiGeneratorDir}</directory>
349+
</resource>
350+
</resources>
351+
</configuration>
352+
</execution>
353+
</executions>
354+
</plugin>
355+
<plugin>
356+
<groupId>software.xdev</groupId>
357+
<artifactId>find-and-replace-maven-plugin</artifactId>
358+
<version>1.0.5</version>
359+
<executions>
360+
<execution>
361+
<!-- Remove so that we don't need additional dependency -->
362+
<id>remove-unused-import-com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider</id>
363+
<phase>process-sources</phase>
364+
<goals>
365+
<goal>file-contents</goal>
366+
</goals>
367+
<configuration>
368+
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/client/</baseDir>
369+
<fileMask>ApiClient.java</fileMask>
370+
<!-- @formatter:off DO NOT INTRODUCE LINE BREAK -->
371+
<findRegex>^import com\.fasterxml\.jackson\.jaxrs\.json\.JacksonJsonProvider;(\r?\n)</findRegex>
372+
<!-- @formatter:on -->
373+
<replaceLineBased>false</replaceLineBased>
374+
</configuration>
375+
</execution>
376+
<execution>
377+
<!-- Changes with each generator version -->
378+
<id>remove-generated-annotation</id>
379+
<phase>process-sources</phase>
380+
<goals>
381+
<goal>file-contents</goal>
382+
</goals>
383+
<configuration>
384+
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/</baseDir>
385+
<recursive>true</recursive>
386+
<fileMask>.java</fileMask>
387+
<findRegex>^@jakarta\.annotation\.Generated.*(\r?\n)</findRegex>
388+
<replaceAll>false</replaceAll>
389+
<replaceLineBased>false</replaceLineBased>
390+
</configuration>
391+
</execution>
392+
<execution>
393+
<!-- Requiring Java serialization indicates a serious misuse of the API -->
394+
<id>remove-serialVersionUID</id>
395+
<phase>process-sources</phase>
396+
<goals>
397+
<goal>file-contents</goal>
398+
</goals>
399+
<configuration>
400+
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/</baseDir>
401+
<recursive>true</recursive>
402+
<fileMask>.java</fileMask>
403+
<findRegex>^.*serialVersionUID.*(\r?\n)(\s*\r?\n)?</findRegex>
404+
<replaceAll>false</replaceAll>
405+
<replaceLineBased>false</replaceLineBased>
406+
</configuration>
407+
</execution>
408+
</executions>
409+
</plugin>
410+
</plugins>
411+
</build>
412+
</profile>
206413
<profile>
207414
<id>checkstyle</id>
208415
<build>
@@ -248,6 +455,10 @@
248455
<rulesets>
249456
<ruleset>../.config/pmd/java/ruleset.xml</ruleset>
250457
</rulesets>
458+
<!-- All code is auto-generated -->
459+
<excludes>
460+
<exclude>**/**</exclude>
461+
</excludes>
251462
</configuration>
252463
<dependencies>
253464
<dependency>

0 commit comments

Comments
 (0)