Skip to content

Commit cfe157c

Browse files
committed
Merge branch 'master' into update-from-template-xdev-software/standard-maven-template-merged
2 parents 6f6dfdb + b76d555 commit cfe157c

File tree

8 files changed

+265
-2
lines changed

8 files changed

+265
-2
lines changed

.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

.github/workflows/update-from-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ on:
2121
env:
2222
UPDATE_BRANCH: update-from-template
2323
UPDATE_BRANCH_MERGED: update-from-template-merged
24-
REMOTE_URL: https://github.com/xdev-software/standard-maven-template.git
24+
REMOTE_URL: https://github.com/xdev-software/openapi-client-maven-template.git
2525
REMOTE_BRANCH: master
2626

2727
permissions:

.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/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.25.2</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: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,60 @@
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+
<dependencyManagement>
55+
<dependencies>
56+
<dependency>
57+
<groupId>com.fasterxml.jackson</groupId>
58+
<artifactId>jackson-bom</artifactId>
59+
<version>2.20.1</version>
60+
<type>pom</type>
61+
<scope>import</scope>
62+
</dependency>
63+
</dependencies>
64+
</dependencyManagement>
65+
66+
<dependencies>
67+
<!-- HTTP client: apache client -->
68+
<dependency>
69+
<groupId>org.apache.httpcomponents.client5</groupId>
70+
<artifactId>httpclient5</artifactId>
71+
<version>5.5.1</version>
72+
</dependency>
73+
74+
<!-- JSON processing: jackson -->
75+
<dependency>
76+
<groupId>com.fasterxml.jackson.core</groupId>
77+
<artifactId>jackson-core</artifactId>
78+
</dependency>
79+
<dependency>
80+
<groupId>com.fasterxml.jackson.core</groupId>
81+
<artifactId>jackson-annotations</artifactId>
82+
</dependency>
83+
<dependency>
84+
<groupId>com.fasterxml.jackson.core</groupId>
85+
<artifactId>jackson-databind</artifactId>
86+
</dependency>
87+
<dependency>
88+
<groupId>com.fasterxml.jackson.datatype</groupId>
89+
<artifactId>jackson-datatype-jsr310</artifactId>
90+
</dependency>
91+
<dependency>
92+
<groupId>org.openapitools</groupId>
93+
<artifactId>jackson-databind-nullable</artifactId>
94+
<version>0.2.8</version>
95+
</dependency>
96+
97+
<dependency>
98+
<groupId>jakarta.annotation</groupId>
99+
<artifactId>jakarta.annotation-api</artifactId>
100+
<version>3.0.0</version>
101+
</dependency>
102+
</dependencies>
103+
52104
<build>
53105
<pluginManagement>
54106
<plugins>
@@ -137,6 +189,25 @@
137189
</execution>
138190
</executions>
139191
</plugin>
192+
193+
<plugin>
194+
<groupId>org.codehaus.mojo</groupId>
195+
<artifactId>build-helper-maven-plugin</artifactId>
196+
<version>3.6.1</version>
197+
<executions>
198+
<execution>
199+
<phase>generate-sources</phase>
200+
<goals>
201+
<goal>add-source</goal>
202+
</goals>
203+
<configuration>
204+
<sources>
205+
<source>${generatedDirRelative}</source>
206+
</sources>
207+
</configuration>
208+
</execution>
209+
</executions>
210+
</plugin>
140211
</plugins>
141212
</build>
142213
<profiles>
@@ -203,6 +274,164 @@
203274
</plugins>
204275
</build>
205276
</profile>
277+
<profile>
278+
<id>openapi-generator</id>
279+
<properties>
280+
<componentName>INSERT_NAME_HERE</componentName>
281+
282+
<generatedDir>${project.basedir}/${generatedDirRelative}</generatedDir>
283+
<openApiRelativeGeneratorDir>src/gen</openApiRelativeGeneratorDir>
284+
<openApiGeneratorDir>
285+
${project.basedir}/target/generated-sources/openapi/${openApiRelativeGeneratorDir}
286+
</openApiGeneratorDir>
287+
</properties>
288+
<build>
289+
<plugins>
290+
<plugin>
291+
<groupId>org.apache.maven.plugins</groupId>
292+
<artifactId>maven-clean-plugin</artifactId>
293+
<version>3.5.0</version>
294+
<executions>
295+
<execution>
296+
<id>pre-generation-clean</id>
297+
<phase>initialize</phase>
298+
<goals>
299+
<goal>clean</goal>
300+
</goals>
301+
<configuration>
302+
<excludeDefaultDirectories>true</excludeDefaultDirectories>
303+
<filesets>
304+
<fileset>
305+
<directory>${generatedDir}</directory>
306+
</fileset>
307+
</filesets>
308+
</configuration>
309+
</execution>
310+
<execution>
311+
<id>post-generation-clean</id>
312+
<phase>process-resources</phase>
313+
<goals>
314+
<goal>clean</goal>
315+
</goals>
316+
</execution>
317+
</executions>
318+
</plugin>
319+
<plugin>
320+
<groupId>org.openapitools</groupId>
321+
<artifactId>openapi-generator-maven-plugin</artifactId>
322+
<version>7.17.0</version>
323+
<executions>
324+
<execution>
325+
<goals>
326+
<goal>generate</goal>
327+
</goals>
328+
<configuration>
329+
<inputSpec>${project.basedir}/../openapi/openapi.yml</inputSpec>
330+
<generatorName>java</generatorName>
331+
<configOptions>
332+
<sourceFolder>${openApiRelativeGeneratorDir}</sourceFolder>
333+
<library>apache-httpclient</library>
334+
<apiPackage>software.xdev.${componentName}.api</apiPackage>
335+
<modelPackage>software.xdev.${componentName}.model</modelPackage>
336+
<invokerPackage>software.xdev.${componentName}.client</invokerPackage>
337+
<!-- Otherwise throw and catch everywhere -->
338+
<useRuntimeException>true</useRuntimeException>
339+
<!-- Some fields of API have been ignored because they are unused -->
340+
<disallowAdditionalPropertiesIfNotPresent>false
341+
</disallowAdditionalPropertiesIfNotPresent>
342+
<!-- Use newer Jakarta EE instead of Javax -->
343+
<useJakartaEe>true</useJakartaEe>
344+
<hideGenerationTimestamp>true</hideGenerationTimestamp>
345+
</configOptions>
346+
<!-- No tests and documentation because we don't use that -->
347+
<generateModelTests>false</generateModelTests>
348+
<generateApiTests>false</generateApiTests>
349+
<generateModelDocumentation>false</generateModelDocumentation>
350+
<generateApiDocumentation>false</generateApiDocumentation>
351+
</configuration>
352+
</execution>
353+
</executions>
354+
</plugin>
355+
<plugin>
356+
<groupId>org.apache.maven.plugins</groupId>
357+
<artifactId>maven-resources-plugin</artifactId>
358+
<version>3.3.1</version>
359+
<executions>
360+
<execution>
361+
<id>copy-generated-resources</id>
362+
<phase>process-sources</phase>
363+
<goals>
364+
<goal>copy-resources</goal>
365+
</goals>
366+
<configuration>
367+
<outputDirectory>${generatedDir}</outputDirectory>
368+
<resources>
369+
<resource>
370+
<directory>${openApiGeneratorDir}</directory>
371+
</resource>
372+
</resources>
373+
</configuration>
374+
</execution>
375+
</executions>
376+
</plugin>
377+
<plugin>
378+
<groupId>software.xdev</groupId>
379+
<artifactId>find-and-replace-maven-plugin</artifactId>
380+
<version>1.0.4</version>
381+
<executions>
382+
<execution>
383+
<!-- Remove so that we don't need additional dependency -->
384+
<id>remove-unused-import-com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider</id>
385+
<phase>process-sources</phase>
386+
<goals>
387+
<goal>file-contents</goal>
388+
</goals>
389+
<configuration>
390+
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/client/</baseDir>
391+
<fileMask>ApiClient.java</fileMask>
392+
<!-- @formatter:off DO NOT INTRODUCE LINE BREAK -->
393+
<findRegex>^import com\.fasterxml\.jackson\.jaxrs\.json\.JacksonJsonProvider;(\r?\n)</findRegex>
394+
<!-- @formatter:on -->
395+
<replaceLineBased>false</replaceLineBased>
396+
</configuration>
397+
</execution>
398+
<execution>
399+
<!-- Changes with each generator version -->
400+
<id>remove-generated-annotation</id>
401+
<phase>process-sources</phase>
402+
<goals>
403+
<goal>file-contents</goal>
404+
</goals>
405+
<configuration>
406+
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/</baseDir>
407+
<recursive>true</recursive>
408+
<fileMask>.java</fileMask>
409+
<findRegex>^@jakarta\.annotation\.Generated.*(\r?\n)</findRegex>
410+
<replaceAll>false</replaceAll>
411+
<replaceLineBased>false</replaceLineBased>
412+
</configuration>
413+
</execution>
414+
<execution>
415+
<!-- Requiring Java serialization indicates a serious misuse of the API -->
416+
<id>remove-serialVersionUID</id>
417+
<phase>process-sources</phase>
418+
<goals>
419+
<goal>file-contents</goal>
420+
</goals>
421+
<configuration>
422+
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/</baseDir>
423+
<recursive>true</recursive>
424+
<fileMask>.java</fileMask>
425+
<findRegex>^.*serialVersionUID.*(\r?\n)(\s*\r?\n)?</findRegex>
426+
<replaceAll>false</replaceAll>
427+
<replaceLineBased>false</replaceLineBased>
428+
</configuration>
429+
</execution>
430+
</executions>
431+
</plugin>
432+
</plugins>
433+
</build>
434+
</profile>
206435
<profile>
207436
<id>checkstyle</id>
208437
<build>
@@ -248,6 +477,10 @@
248477
<rulesets>
249478
<ruleset>../.config/pmd/java/ruleset.xml</ruleset>
250479
</rulesets>
480+
<!-- All code is auto-generated -->
481+
<excludes>
482+
<exclude>**/**</exclude>
483+
</excludes>
251484
</configuration>
252485
<dependencies>
253486
<dependency>

0 commit comments

Comments
 (0)