Skip to content
This repository was archived by the owner on Feb 14, 2025. It is now read-only.

Commit f281c9d

Browse files
committed
Merge branch 'master' into update-from-template-merged
2 parents 37e12e8 + 29d30f5 commit f281c9d

File tree

8 files changed

+270
-2
lines changed

8 files changed

+270
-2
lines changed

.github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
open_collective: openapi_generator

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

+1-1
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

+1-1
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

+5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
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)
33
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_template-placeholder&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_template-placeholder)
4+
[![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)
45

56
# template-placeholder
67

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

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

13+
## Demo
14+
A minimal demo is also available [here](./template-placeholder-demo/src/main/java/software/xdev/Application.java).
15+
1116
## Support
1217
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).
1318

openapi/INFO.md

+8
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

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

template-placeholder-demo/pom.xml

+15
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.24.3</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

+238
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@
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

5259
<repositories>
@@ -84,6 +91,56 @@
8491
</repository>
8592
</distributionManagement>
8693

94+
<dependencyManagement>
95+
<dependencies>
96+
<dependency>
97+
<groupId>com.fasterxml.jackson</groupId>
98+
<artifactId>jackson-bom</artifactId>
99+
<version>2.18.2</version>
100+
<type>pom</type>
101+
<scope>import</scope>
102+
</dependency>
103+
</dependencies>
104+
</dependencyManagement>
105+
106+
<dependencies>
107+
<!-- HTTP client: apache client -->
108+
<dependency>
109+
<groupId>org.apache.httpcomponents.client5</groupId>
110+
<artifactId>httpclient5</artifactId>
111+
<version>5.4.1</version>
112+
</dependency>
113+
114+
<!-- JSON processing: jackson -->
115+
<dependency>
116+
<groupId>com.fasterxml.jackson.core</groupId>
117+
<artifactId>jackson-core</artifactId>
118+
</dependency>
119+
<dependency>
120+
<groupId>com.fasterxml.jackson.core</groupId>
121+
<artifactId>jackson-annotations</artifactId>
122+
</dependency>
123+
<dependency>
124+
<groupId>com.fasterxml.jackson.core</groupId>
125+
<artifactId>jackson-databind</artifactId>
126+
</dependency>
127+
<dependency>
128+
<groupId>com.fasterxml.jackson.datatype</groupId>
129+
<artifactId>jackson-datatype-jsr310</artifactId>
130+
</dependency>
131+
<dependency>
132+
<groupId>org.openapitools</groupId>
133+
<artifactId>jackson-databind-nullable</artifactId>
134+
<version>0.2.6</version>
135+
</dependency>
136+
137+
<dependency>
138+
<groupId>jakarta.annotation</groupId>
139+
<artifactId>jakarta.annotation-api</artifactId>
140+
<version>3.0.0</version>
141+
</dependency>
142+
</dependencies>
143+
87144
<build>
88145
<pluginManagement>
89146
<plugins>
@@ -172,6 +229,25 @@
172229
</execution>
173230
</executions>
174231
</plugin>
232+
233+
<plugin>
234+
<groupId>org.codehaus.mojo</groupId>
235+
<artifactId>build-helper-maven-plugin</artifactId>
236+
<version>3.6.0</version>
237+
<executions>
238+
<execution>
239+
<phase>generate-sources</phase>
240+
<goals>
241+
<goal>add-source</goal>
242+
</goals>
243+
<configuration>
244+
<sources>
245+
<source>${generatedDirRelative}</source>
246+
</sources>
247+
</configuration>
248+
</execution>
249+
</executions>
250+
</plugin>
175251
</plugins>
176252
</build>
177253
<profiles>
@@ -235,6 +311,164 @@
235311
</plugins>
236312
</build>
237313
</profile>
314+
<profile>
315+
<id>openapi-generator</id>
316+
<properties>
317+
<componentName>INSERT_NAME_HERE</componentName>
318+
319+
<generatedDir>${project.basedir}/${generatedDirRelative}</generatedDir>
320+
<openApiRelativeGeneratorDir>src/gen</openApiRelativeGeneratorDir>
321+
<openApiGeneratorDir>
322+
${project.basedir}/target/generated-sources/openapi/${openApiRelativeGeneratorDir}
323+
</openApiGeneratorDir>
324+
</properties>
325+
<build>
326+
<plugins>
327+
<plugin>
328+
<groupId>org.apache.maven.plugins</groupId>
329+
<artifactId>maven-clean-plugin</artifactId>
330+
<version>3.4.0</version>
331+
<executions>
332+
<execution>
333+
<id>pre-generation-clean</id>
334+
<phase>initialize</phase>
335+
<goals>
336+
<goal>clean</goal>
337+
</goals>
338+
<configuration>
339+
<excludeDefaultDirectories>true</excludeDefaultDirectories>
340+
<filesets>
341+
<fileset>
342+
<directory>${generatedDir}</directory>
343+
</fileset>
344+
</filesets>
345+
</configuration>
346+
</execution>
347+
<execution>
348+
<id>post-generation-clean</id>
349+
<phase>process-resources</phase>
350+
<goals>
351+
<goal>clean</goal>
352+
</goals>
353+
</execution>
354+
</executions>
355+
</plugin>
356+
<plugin>
357+
<groupId>org.openapitools</groupId>
358+
<artifactId>openapi-generator-maven-plugin</artifactId>
359+
<version>7.11.0</version>
360+
<executions>
361+
<execution>
362+
<goals>
363+
<goal>generate</goal>
364+
</goals>
365+
<configuration>
366+
<inputSpec>${project.basedir}/../openapi/openapi.yml</inputSpec>
367+
<generatorName>java</generatorName>
368+
<configOptions>
369+
<sourceFolder>${openApiRelativeGeneratorDir}</sourceFolder>
370+
<library>apache-httpclient</library>
371+
<apiPackage>software.xdev.${componentName}.api</apiPackage>
372+
<modelPackage>software.xdev.${componentName}.model</modelPackage>
373+
<invokerPackage>software.xdev.${componentName}.client</invokerPackage>
374+
<!-- Otherwise throw and catch everywhere -->
375+
<useRuntimeException>true</useRuntimeException>
376+
<!-- Some fields of API have been ignored because they are unused -->
377+
<disallowAdditionalPropertiesIfNotPresent>false
378+
</disallowAdditionalPropertiesIfNotPresent>
379+
<!-- Use newer Jakarta EE instead of Javax -->
380+
<useJakartaEe>true</useJakartaEe>
381+
<hideGenerationTimestamp>true</hideGenerationTimestamp>
382+
</configOptions>
383+
<!-- No tests and documentation because we don't use that -->
384+
<generateModelTests>false</generateModelTests>
385+
<generateApiTests>false</generateApiTests>
386+
<generateModelDocumentation>false</generateModelDocumentation>
387+
<generateApiDocumentation>false</generateApiDocumentation>
388+
</configuration>
389+
</execution>
390+
</executions>
391+
</plugin>
392+
<plugin>
393+
<groupId>org.apache.maven.plugins</groupId>
394+
<artifactId>maven-resources-plugin</artifactId>
395+
<version>3.3.1</version>
396+
<executions>
397+
<execution>
398+
<id>copy-generated-resources</id>
399+
<phase>process-sources</phase>
400+
<goals>
401+
<goal>copy-resources</goal>
402+
</goals>
403+
<configuration>
404+
<outputDirectory>${generatedDir}</outputDirectory>
405+
<resources>
406+
<resource>
407+
<directory>${openApiGeneratorDir}</directory>
408+
</resource>
409+
</resources>
410+
</configuration>
411+
</execution>
412+
</executions>
413+
</plugin>
414+
<plugin>
415+
<groupId>software.xdev</groupId>
416+
<artifactId>find-and-replace-maven-plugin</artifactId>
417+
<version>1.0.3</version>
418+
<executions>
419+
<execution>
420+
<!-- Remove so that we don't need additional dependency -->
421+
<id>remove-unused-import-com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider</id>
422+
<phase>process-sources</phase>
423+
<goals>
424+
<goal>file-contents</goal>
425+
</goals>
426+
<configuration>
427+
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/client/</baseDir>
428+
<fileMask>ApiClient.java</fileMask>
429+
<!-- @formatter:off DO NOT INTRODUCE LINE BREAK -->
430+
<findRegex>^import com\.fasterxml\.jackson\.jaxrs\.json\.JacksonJsonProvider;(\r?\n)</findRegex>
431+
<!-- @formatter:on -->
432+
<replaceLineBased>false</replaceLineBased>
433+
</configuration>
434+
</execution>
435+
<execution>
436+
<!-- Changes with each generator version -->
437+
<id>remove-generated-annotation</id>
438+
<phase>process-sources</phase>
439+
<goals>
440+
<goal>file-contents</goal>
441+
</goals>
442+
<configuration>
443+
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/</baseDir>
444+
<recursive>true</recursive>
445+
<fileMask>.java</fileMask>
446+
<findRegex>^@jakarta\.annotation\.Generated.*(\r?\n)</findRegex>
447+
<replaceAll>false</replaceAll>
448+
<replaceLineBased>false</replaceLineBased>
449+
</configuration>
450+
</execution>
451+
<execution>
452+
<!-- Requiring Java serialization indicates a serious misuse of the API -->
453+
<id>remove-serialVersionUID</id>
454+
<phase>process-sources</phase>
455+
<goals>
456+
<goal>file-contents</goal>
457+
</goals>
458+
<configuration>
459+
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/</baseDir>
460+
<recursive>true</recursive>
461+
<fileMask>.java</fileMask>
462+
<findRegex>^.*serialVersionUID.*(\r?\n)(\s*\r?\n)?</findRegex>
463+
<replaceAll>false</replaceAll>
464+
<replaceLineBased>false</replaceLineBased>
465+
</configuration>
466+
</execution>
467+
</executions>
468+
</plugin>
469+
</plugins>
470+
</build>
471+
</profile>
238472
<profile>
239473
<id>checkstyle</id>
240474
<build>
@@ -279,6 +513,10 @@
279513
<rulesets>
280514
<ruleset>../.config/pmd/ruleset.xml</ruleset>
281515
</rulesets>
516+
<!-- All code is auto-generated -->
517+
<excludes>
518+
<exclude>**/**</exclude>
519+
</excludes>
282520
</configuration>
283521
<dependencies>
284522
<dependency>

0 commit comments

Comments
 (0)