Skip to content

Commit 8c3c7a5

Browse files
author
Thorsten Schlathoelter
committed
feat: implement OpenAPI TestAPI generator
1 parent 0978510 commit 8c3c7a5

File tree

132 files changed

+24967
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+24967
-11
lines changed

catalog/citrus-bom/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,16 @@
238238
<artifactId>citrus-openapi</artifactId>
239239
<version>4.7.0-SNAPSHOT</version>
240240
</dependency>
241+
<dependency>
242+
<groupId>org.citrusframework</groupId>
243+
<artifactId>citrus-test-api-core</artifactId>
244+
<version>4.7.0-SNAPSHOT</version>
245+
</dependency>
246+
<dependency>
247+
<groupId>org.citrusframework</groupId>
248+
<artifactId>citrus-test-api-generator-core</artifactId>
249+
<version>4.7.0-SNAPSHOT</version>
250+
</dependency>
241251
<dependency>
242252
<groupId>org.citrusframework</groupId>
243253
<artifactId>citrus-jms</artifactId>

pom.xml

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@
5050
</ciManagement>
5151

5252
<modules>
53-
<module>core</module>
54-
<module>utils</module>
55-
<module>runtime</module>
56-
<module>validation</module>
53+
<module>catalog</module>
5754
<module>connectors</module>
55+
<module>core</module>
5856
<module>endpoints</module>
57+
<module>runtime</module>
58+
<module>test-api-generator</module>
5959
<module>tools</module>
60-
<module>catalog</module>
60+
<module>utils</module>
61+
<module>validation</module>
6162
</modules>
6263

6364
<developers>
@@ -261,6 +262,7 @@
261262
<snappy.version>1.1.10.7</snappy.version>
262263
<snakeyaml.version>2.4</snakeyaml.version>
263264
<spring.version>6.2.8</spring.version>
265+
<spring.boot.version>3.4.1</spring.boot.version>
264266
<spring.ws.version>4.0.14</spring.ws.version>
265267
<spring.integration.version>6.4.4</spring.integration.version>
266268
<spring.restdocs.version>3.0.3</spring.restdocs.version>
@@ -418,6 +420,18 @@
418420
<version>${hamcrest.version}</version>
419421
</dependency>
420422

423+
<dependency>
424+
<groupId>org.openapitools</groupId>
425+
<artifactId>openapi-generator</artifactId>
426+
<version>${org.openapitools.version}</version>
427+
<scope>provided</scope>
428+
</dependency>
429+
<dependency>
430+
<groupId>org.openapitools</groupId>
431+
<artifactId>jackson-databind-nullable</artifactId>
432+
<version>${jackson-databind-nullable.version}</version>
433+
</dependency>
434+
421435
<!-- Spring Framework -->
422436
<dependency>
423437
<groupId>org.springframework</groupId>
@@ -509,24 +523,23 @@
509523
<artifactId>spring-integration-http</artifactId>
510524
<version>${spring.integration.version}</version>
511525
</dependency>
512-
513526
<dependency>
514527
<groupId>org.springframework.restdocs</groupId>
515528
<artifactId>spring-restdocs-core</artifactId>
516529
<version>${spring.restdocs.version}</version>
517530
</dependency>
531+
<dependency>
532+
<groupId>org.springframework</groupId>
533+
<artifactId>spring-test</artifactId>
534+
<version>${spring.version}</version>
535+
</dependency>
518536

519537
<dependency>
520538
<groupId>wsdl4j</groupId>
521539
<artifactId>wsdl4j</artifactId>
522540
<version>${wsdl4j.version}</version>
523541
</dependency>
524542

525-
<dependency>
526-
<groupId>org.springframework</groupId>
527-
<artifactId>spring-test</artifactId>
528-
<version>${spring.version}</version>
529-
</dependency>
530543
<dependency>
531544
<groupId>org.testng</groupId>
532545
<artifactId>testng</artifactId>
@@ -1028,6 +1041,11 @@
10281041
<artifactId>jackson-databind</artifactId>
10291042
<version>${jackson.version}</version>
10301043
</dependency>
1044+
<dependency>
1045+
<groupId>com.fasterxml.jackson.dataformat</groupId>
1046+
<artifactId>jackson-dataformat-yaml</artifactId>
1047+
<version>${jackson.version}</version>
1048+
</dependency>
10311049
<dependency>
10321050
<groupId>com.fasterxml.jackson.module</groupId>
10331051
<artifactId>jackson-module-jaxb-annotations</artifactId>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<artifactId>citrus-test-api-generator</artifactId>
9+
<groupId>org.citrusframework</groupId>
10+
<version>4.7.0-SNAPSHOT</version>
11+
<relativePath>../pom.xml</relativePath>
12+
</parent>
13+
14+
<artifactId>citrus-test-api-core</artifactId>
15+
<name>Citrus :: Test API Core</name>
16+
<description>Citrus Test API Core</description>
17+
<packaging>jar</packaging>
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.citrusframework</groupId>
22+
<artifactId>citrus-api</artifactId>
23+
<version>${project.version}</version>
24+
</dependency>
25+
<dependency>
26+
<groupId>org.citrusframework</groupId>
27+
<artifactId>citrus-http</artifactId>
28+
<version>${project.version}</version>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.citrusframework</groupId>
32+
<artifactId>citrus-openapi</artifactId>
33+
<version>${project.version}</version>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.citrusframework</groupId>
37+
<artifactId>citrus-spring</artifactId>
38+
<version>${project.version}</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.citrusframework</groupId>
42+
<artifactId>citrus-ws</artifactId>
43+
<version>${project.version}</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>com.fasterxml.jackson.dataformat</groupId>
47+
<artifactId>jackson-dataformat-yaml</artifactId>
48+
</dependency>
49+
<dependency>
50+
<groupId>org.openapitools</groupId>
51+
<artifactId>jackson-databind-nullable</artifactId>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.openapitools</groupId>
55+
<artifactId>openapi-generator</artifactId>
56+
<version>${org.openapitools.version}</version>
57+
</dependency>
58+
<dependency>
59+
<groupId>wsdl4j</groupId>
60+
<artifactId>wsdl4j</artifactId>
61+
</dependency>
62+
63+
<!-- Test scoped dependencies -->
64+
<dependency>
65+
<groupId>org.citrusframework</groupId>
66+
<artifactId>citrus-junit5</artifactId>
67+
<version>${project.version}</version>
68+
<scope>test</scope>
69+
</dependency>
70+
<dependency>
71+
<groupId>org.citrusframework</groupId>
72+
<artifactId>citrus-validation-json</artifactId>
73+
<version>${project.version}</version>
74+
<scope>test</scope>
75+
</dependency>
76+
<dependency>
77+
<groupId>commons-fileupload</groupId>
78+
<artifactId>commons-fileupload</artifactId>
79+
<version>1.5</version>
80+
<scope>test</scope>
81+
</dependency>
82+
</dependencies>
83+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.citrusframework.openapi.testapi;
18+
19+
import org.citrusframework.actions.ReceiveMessageAction.ReceiveMessageActionBuilder;
20+
import org.citrusframework.actions.SendMessageAction.SendMessageActionBuilder;
21+
22+
/**
23+
* Implementors of this interface are used to customize the SendMessageActionBuilder with application specific information. E.g. cookies
24+
* or transactionIds.
25+
*/
26+
public interface ApiActionBuilderCustomizer {
27+
28+
default <T extends SendMessageActionBuilder<?, ?, ?>> void customizeRequestBuilder(GeneratedApiOperationInfo generatedApiOperationInfo, T builder) {
29+
}
30+
31+
default <T extends ReceiveMessageActionBuilder<?, ?, ?>> void customizeResponseBuilder(GeneratedApiOperationInfo generatedApiOperationInfo, T builder) {
32+
}
33+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.citrusframework.openapi.testapi;
18+
19+
import java.util.List;
20+
import java.util.Map;
21+
22+
import org.citrusframework.endpoint.Endpoint;
23+
24+
/**
25+
* Interface representing a generated API from an OpenAPI specification.
26+
* Provides methods to retrieve metadata about the API such as title, version,
27+
* prefix, and information extensions.
28+
*/
29+
public interface GeneratedApi {
30+
31+
/**
32+
* Retrieves the title of the OpenAPI specification, as specified in the info section of the API.
33+
*
34+
* @return the title of the OpenAPI specification
35+
*/
36+
String getApiTitle();
37+
38+
/**
39+
* Retrieves the version of the OpenAPI specification, as specified in the info section of the API.
40+
*
41+
* @return the version of the OpenAPI specification
42+
*/
43+
String getApiVersion();
44+
45+
/**
46+
* Retrieves the prefix used for the API, as specified in the API generation configuration.
47+
*
48+
* @return the prefix used for the API
49+
*/
50+
String getApiPrefix();
51+
52+
/**
53+
* Retrieves the specification extensions of the OpenAPI defined in the "info" section.
54+
* <p>
55+
* Specification extensions, also known as vendor extensions, are custom key-value pairs used to describe extra
56+
* functionality not covered by the standard OpenAPI Specification. These properties start with "x-".
57+
* This method collects only the extensions defined in the "info" section of the API.
58+
*
59+
* @return a map containing the specification extensions defined in the "info" section of the API,
60+
* where keys are extension names and values are extension values
61+
*/
62+
Map<String, String> getApiInfoExtensions();
63+
64+
List<ApiActionBuilderCustomizer> getCustomizers();
65+
66+
/**
67+
* Returns the endpoint of the generated api.
68+
*/
69+
Endpoint getEndpoint();
70+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.citrusframework.openapi.testapi;
18+
19+
/**
20+
* Interface representing information about a generated API operation as defined in an OpenAPI
21+
* specification. It provides methods to access metadata related to the operation, including the
22+
* operation name, HTTP method, and request path.
23+
*/
24+
public interface GeneratedApiOperationInfo {
25+
26+
/**
27+
* Retrieves the {@link GeneratedApi} which owns this operation.
28+
* @return
29+
*/
30+
GeneratedApi getGeneratedApi();
31+
32+
/**
33+
* Retrieves the name of the OpenAPI operation.
34+
*
35+
* @return the name of the OpenAPI operation
36+
*/
37+
String getOperationName();
38+
39+
/**
40+
* Retrieves the HTTP method corresponding to the operation.
41+
*
42+
* @return the HTTP method specified in the OpenAPI operation
43+
*/
44+
String getMethod();
45+
46+
/**
47+
* Retrieves the path corresponding to the operation.
48+
*
49+
* @return the path of the OpenAPI operation
50+
*/
51+
String getPath();
52+
}

0 commit comments

Comments
 (0)