Skip to content

Commit

Permalink
ci: connect openapi generator to maven reactor
Browse files Browse the repository at this point in the history
  • Loading branch information
bbortt committed Jul 3, 2024
1 parent 04f4c2f commit d1b04d7
Show file tree
Hide file tree
Showing 37 changed files with 198 additions and 283 deletions.
16 changes: 9 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@
</ciManagement>

<modules>
<module>catalog</module>
<module>connectors</module>
<module>core</module>
<module>utils</module>
<module>runtime</module>
<module>validation</module>
<module>endpoints</module>
<module>connectors</module>
<module>runtime</module>
<module>test-api-generator</module>
<module>tools</module>
<module>catalog</module>
<module>utils</module>
<module>validation</module>
</modules>

<developers>
Expand Down Expand Up @@ -247,14 +248,15 @@
<mockftpserver.version>3.2.0</mockftpserver.version>
<netty.version>4.1.105.Final</netty.version>
<okhttp.version>4.12.0</okhttp.version>
<openapi-generator-maven-plugin>7.5.0</openapi-generator-maven-plugin>
<org.openapitools.version>7.5.0</org.openapitools.version>
<picoli-version>4.7.6</picoli-version>
<saaj.version>3.0.4</saaj.version>
<selenium.version>4.21.0</selenium.version>
<slf4j.version>2.0.11</slf4j.version>
<snappy.version>1.1.10.5</snappy.version>
<snakeyaml.version>2.2</snakeyaml.version>
<spring.version>6.1.8</spring.version>
<spring.boot.version>3.3.1</spring.boot.version>
<spring.ws.version>4.0.11</spring.ws.version>
<spring.integration.version>6.3.0</spring.integration.version>
<spring.restdocs.version>3.0.1</spring.restdocs.version>
Expand Down Expand Up @@ -516,7 +518,7 @@
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator</artifactId>
<version>${openapi-generator-maven-plugin}</version>
<version>${org.openapitools.version}</version>
<scope>provided</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
import org.citrusframework.message.DefaultMessageStore;
import org.citrusframework.message.MessageStore;
import org.testng.Assert;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

/**
* @author Christoph Deppisch
*/
@Ignore
public class WaitForTest extends AbstractGroovyActionDslTest {

private static final String DEFAULT_WAIT_TIME = "5000";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
import org.citrusframework.xml.XmlTestLoader;
import org.citrusframework.xml.actions.AbstractXmlActionTest;
import org.testng.Assert;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

/**
* @author Christoph Deppisch
*/
@Ignore
public class WaitForTest extends AbstractXmlActionTest {

private static final String DEFAULT_WAIT_TIME = "5000";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
import org.citrusframework.yaml.YamlTestLoader;
import org.citrusframework.yaml.actions.AbstractYamlActionTest;
import org.testng.Assert;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

/**
* @author Christoph Deppisch
*/
@Ignore
public class WaitForTest extends AbstractYamlActionTest {

private static final String DEFAULT_WAIT_TIME = "5000";
Expand Down
22 changes: 10 additions & 12 deletions src/manual/connector-openapi.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,11 @@ The generator provides the following features:
* generation of a Test API
** from OpenAPI Specification
** [TODO #1163] from WSDL via an intermediate step that generates a "light" OpenApi specification from a WSDL
* integration into Citrus XML test cases
* integration into <<run-xml-tests,Citrus XML test cases>>
** integration into XML editors via generated XSD
*** schema validation
*** auto completion
* integration into Citrus Java test cases via Java DSL [TODO #1161]
* integration into <<run-java,Citrus Java test cases>> via Java DSL [TODO #1161]

The following directory structure/table specifies the files, which are generated by the generator.
Note that the `Prefix` is a configuration parameter which should uniquely identify a generated API.
Expand Down Expand Up @@ -387,9 +387,9 @@ target/
==== Configuration of Test API generation

Code generation is typically performed during the build process.
For the Citrus Test API Generator, it is carried out by a Maven plugin.
For the Citrus Test API Generator, it is carried out by a Maven or Gradle plugin.
While the standard generator plugin, `org.openapitools:openapi-generator-maven-plugin`, can be employed for this purpose, configuring it can be cumbersome, especially when dealing with multiple APIs.
To address this challenge, Citrus offers its adaptation of this standard generator Maven plugin.
To address this challenge, Citrus offers its adaptation of this standard generator plugin.
This `Citrus OpenAPI Generator Plugin` simplifies the configuration of test API generation by providing predefined defaults and supporting the generation of multiple APIs.
Additionally, it enhances support for generating Spring integration files (`spring.handlers` and `spring.schemas`), thereby facilitating the integration of generated APIs into Spring-based applications.
Consequently, utilizing the Citrus Generator Plugin is recommended in most scenarios.
Expand Down Expand Up @@ -535,27 +535,26 @@ The following shows the configuration of test api generation for different scena
These are the primary elements you can configure in the `<configuration>` section:

|===
| Configuration element | Maven Property | Description | Default Value
| Configuration element | Maven Property | Description | Default Value

| `schemaFolder` | `citrus.test.api.generator.schema.folder` | Location for the generated XSD schemas | `schema/xsd/%VERSION%`
| `resourceFolder` | `citrus.test.api.generator.resource.folder` | Location to which resources are generated | `generated-resources`
| `sourceFolder` | `citrus.test.api.generator.source.folder` | Location to which sources are generated | `generated-sources`
| `metaInfFolder` | `citrus.test.api.generator.meta.inf.folder` | Location to which spring meta files are generated/updated | `target/generated-test-resources/META-INF`
| `generateSpringIntegrationFiles` | `citrus.test.api.generator.generate.spring.integration.files` | Specifies whether spring integration files should be generated | `true`
| Nested api element | | |
| Nested `<api />` element | | |
| `prefix` | `citrus.test.api.generator.prefix` | Specifies the prefix used for the test API, typically an acronym | (no default, required)
| `source` | `citrus.test.api.generator.source` | Specifies the source of the test API | (no default, required)
| `version` | `citrus.test.api.generator.version` | Specifies the version of the API, may be null | (none)
| `endpoint` | `citrus.test.api.generator.endpoint` | Specifies the endpoint of the test API | `applicationServiceClient`
| `type` | `citrus.test.api.generator.type` | Specifies the type of the test API | `REST`, other option is `SOAP`
| `useTags` | `citrus.test.api.generator.use.tags` | Specifies whether tags should be used by the generator | `true`
| `invokerPackage` | `citrus.test.api.generator.invoker.package` | Package for the test API classes | `org.citrusframework.automation.%PREFIX%.%VERSION%`
| `invokerPackage` | `citrus.test.api.generator.invoker.package` | Package for the test API classes | `org.citrusframework.automation.%PREFIX%.%VERSION%`
| `apiPackage` | `citrus.test.api.generator.api.package` | Package for the test API interface classes | `org.citrusframework.automation.%PREFIX%.%VERSION%.api`
| `modelPackage` | `citrus.test.api.generator.model.package` | Package for the test API model classes | `org.citrusframework.automation.%PREFIX%.%VERSION%.model`
| `targetXmlnsNamespace` | `citrus.test.api.generator.namespace` | XML namespace used by the API | `http://www.citrusframework.org/schema/%VERSION%/%PREFIX%-api`
| `targetXmlnsNamespace` | `citrus.test.api.generator.namespace` | XML namespace used by the API | `http://www.citrusframework.org/schema/%VERSION%/%PREFIX%-api`
|===


Note: `%PREFIX%` and `%VERSION%` are placeholders that will be replaced by their specific values as configured.
The plugin performs a conversion to lowercase for `PREFIX` used in package names and in `targetXmlnsNamespace`.

Expand All @@ -568,7 +567,6 @@ To run the generator, execute the following command in your project directory:
mvn citrus-test-api-generator-maven-plugin:create-test-api
----


This command will generate the classes and XSD files as configured for your APIs in the specified locations.

==== Spring meta file generation
Expand Down Expand Up @@ -683,8 +681,8 @@ Further examples can be found here `org.citrusframework.openapi.generator.Genera
----

To utilize the test API in Java, it's necessary to import the API configuration, that provides the respective request actions.
The request to test can then be autowired, configured and autowired, as illustrated in the sample below.
Further examples can be found here `org.citrusframework.openapi.generator.GetPetByIdTest`.
The request to test can then be configured and autowired, as illustrated in the sample below.
Further examples can be found here `org.citrusframework.openapi.generator.GetPetByIdIT`.

.Java DSL
[source,java,indent=0,role="secondary"]
Expand Down
15 changes: 8 additions & 7 deletions test-api-generator/citrus-test-api-generator-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<description>Generates a Citrus Test-API for OpenAPI and WSDL specifications.</description>

<dependencies>

<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-api</artifactId>
Expand Down Expand Up @@ -54,6 +53,7 @@
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator</artifactId>
<version>${org.openapitools.version}</version>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
Expand All @@ -67,18 +67,18 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<version>${spring.boot.test.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-validation-json</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<version>${spring.boot.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -121,6 +121,7 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${org.openapitools.version}</version>
<dependencies>
<dependency>
<groupId>org.citrusframework</groupId>
Expand Down
Loading

0 comments on commit d1b04d7

Please sign in to comment.