Skip to content

Commit

Permalink
Merge branch 'master' into update-from-template-merged
Browse files Browse the repository at this point in the history
  • Loading branch information
xdev-gh-bot committed Jun 27, 2024
2 parents 034ee38 + 3c596bd commit 58a2182
Show file tree
Hide file tree
Showing 7 changed files with 269 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/update-from-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
env:
UPDATE_BRANCH: update-from-template
UPDATE_BRANCH_MERGED: update-from-template-merged
REMOTE_URL: https://github.com/xdev-software/standard-maven-template.git
REMOTE_URL: https://github.com/xdev-software/openapi-client-maven-template.git
REMOTE_BRANCH: master

permissions:
Expand Down
2 changes: 1 addition & 1 deletion .run/Run Demo.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
</component>
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/template-placeholder?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/template-placeholder)
[![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)
[![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)
[![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)

# template-placeholder

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

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

## Demo
A minimal demo is also available [here](./template-placeholder-demo/src/main/java/software/xdev/Application.java).

## Support
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).

Expand Down
8 changes: 8 additions & 0 deletions openapi/INFO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This ``openapi.yml`` was written manually as INSERT_NAME_HERE fails to provide an API schema or something similar.

The Java API Client can be generated using ``mvn clean compile -P openapi-generator`` inside [``template-placeholder``](../template-placeholder/).

Helpful links:
* https://jsonformatter.org/json-to-jsonschema
* https://swagger.io/specification/
* https://editor.swagger.io/
1 change: 1 addition & 0 deletions openapi/openapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

15 changes: 15 additions & 0 deletions template-placeholder-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<mainClass>software.xdev.Application</mainClass>

<log4j2-version>2.23.1</log4j2-version>
</properties>

<dependencies>
Expand All @@ -35,6 +37,19 @@
<artifactId>template-placeholder</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Logging -->
<!-- SLF4J comes from Apache Httpclient -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2-version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j2-version}</version>
</dependency>
</dependencies>

<build>
Expand Down
238 changes: 238 additions & 0 deletions template-placeholder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<generatedDirRelative>src/generated/java</generatedDirRelative>

<!-- Ignore generated code -->
<sonar.exclusions>
src/generated/**
</sonar.exclusions>
</properties>

<repositories>
Expand Down Expand Up @@ -84,6 +91,56 @@
</repository>
</distributionManagement>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>2.17.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- HTTP client: apache client -->
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.3.1</version>
</dependency>

<!-- JSON processing: jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.6</version>
</dependency>

<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
Expand Down Expand Up @@ -172,6 +229,25 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${generatedDirRelative}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
Expand Down Expand Up @@ -235,6 +311,164 @@
</plugins>
</build>
</profile>
<profile>
<id>openapi-generator</id>
<properties>
<componentName>INSERT_NAME_HERE</componentName>

<generatedDir>${project.basedir}/${generatedDirRelative}</generatedDir>
<openApiRelativeGeneratorDir>src/gen</openApiRelativeGeneratorDir>
<openApiGeneratorDir>
${project.basedir}/target/generated-sources/openapi/${openApiRelativeGeneratorDir}
</openApiGeneratorDir>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<id>pre-generation-clean</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>${generatedDir}</directory>
</fileset>
</filesets>
</configuration>
</execution>
<execution>
<id>post-generation-clean</id>
<phase>process-resources</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.6.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/../openapi/openapi.yml</inputSpec>
<generatorName>java</generatorName>
<configOptions>
<sourceFolder>${openApiRelativeGeneratorDir}</sourceFolder>
<library>apache-httpclient</library>
<apiPackage>software.xdev.${componentName}.api</apiPackage>
<modelPackage>software.xdev.${componentName}.model</modelPackage>
<invokerPackage>software.xdev.${componentName}.client</invokerPackage>
<!-- Otherwise throw and catch everywhere -->
<useRuntimeException>true</useRuntimeException>
<!-- Some fields of API have been ignored because they are unused -->
<disallowAdditionalPropertiesIfNotPresent>false
</disallowAdditionalPropertiesIfNotPresent>
<!-- Use newer Jakarta EE instead of Javax -->
<useJakartaEe>true</useJakartaEe>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
</configOptions>
<!-- No tests and documentation because we don't use that -->
<generateModelTests>false</generateModelTests>
<generateApiTests>false</generateApiTests>
<generateModelDocumentation>false</generateModelDocumentation>
<generateApiDocumentation>false</generateApiDocumentation>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>copy-generated-resources</id>
<phase>process-sources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${generatedDir}</outputDirectory>
<resources>
<resource>
<directory>${openApiGeneratorDir}</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>software.xdev</groupId>
<artifactId>find-and-replace-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<!-- Remove so that we don't need additional dependency -->
<id>remove-unused-import-com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider</id>
<phase>process-sources</phase>
<goals>
<goal>file-contents</goal>
</goals>
<configuration>
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/client/</baseDir>
<fileMask>ApiClient.java</fileMask>
<!-- @formatter:off DO NOT INTRODUCE LINE BREAK -->
<findRegex>^import com\.fasterxml\.jackson\.jaxrs\.json\.JacksonJsonProvider;(\r?\n)</findRegex>
<!-- @formatter:on -->
<replaceLineBased>false</replaceLineBased>
</configuration>
</execution>
<execution>
<!-- Changes with each generator version -->
<id>remove-generated-annotation</id>
<phase>process-sources</phase>
<goals>
<goal>file-contents</goal>
</goals>
<configuration>
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/</baseDir>
<recursive>true</recursive>
<fileMask>.java</fileMask>
<findRegex>^@jakarta\.annotation\.Generated.*(\r?\n)</findRegex>
<replaceAll>false</replaceAll>
<replaceLineBased>false</replaceLineBased>
</configuration>
</execution>
<execution>
<!-- Requiring Java serialization indicates a serious misuse of the API -->
<id>remove-serialVersionUID</id>
<phase>process-sources</phase>
<goals>
<goal>file-contents</goal>
</goals>
<configuration>
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/</baseDir>
<recursive>true</recursive>
<fileMask>.java</fileMask>
<findRegex>^.*serialVersionUID.*(\r?\n)(\s*\r?\n)?</findRegex>
<replaceAll>false</replaceAll>
<replaceLineBased>false</replaceLineBased>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>checkstyle</id>
<build>
Expand Down Expand Up @@ -279,6 +513,10 @@
<rulesets>
<ruleset>../.config/pmd/ruleset.xml</ruleset>
</rulesets>
<!-- All code is auto-generated -->
<excludes>
<exclude>**/**</exclude>
</excludes>
</configuration>
<dependencies>
<dependency>
Expand Down

0 comments on commit 58a2182

Please sign in to comment.