Skip to content

Commit 9866a02

Browse files
committed
Merge branch 'master' into update-from-template-merged
2 parents c89fbec + d356baa commit 9866a02

File tree

8 files changed

+270
-2
lines changed

8 files changed

+270
-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.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: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,65 @@
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>
52+
53+
<!-- Ignore generated code -->
54+
<sonar.exclusions>
55+
src/generated/**
56+
</sonar.exclusions>
5057
</properties>
5158

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

0 commit comments

Comments
 (0)