API to generate a SoapUI project from an OpenAPI Specification (fka Swagger Specification)
Given an OpenAPI Specification, either v2 or v3, a SoapUI project is generated with the requests for each resource operation and a test suite. The response is the content of the SoapUI project in XML format to save as file and import into the SoapUI application.
This repository is intended for community use, it can be modified and adapted without commercial use. If you need a version, support or help for your enterprise or project, please contact us π§ devrel@apiaddicts.org
π’ If OpenAPI2SoapUI is part of your organization's toolkit, we kindly encourage you to include your company's name in our Adopters list. π This not only significantly boosts the project's visibility and reputation but also represents a small yet impactful way to give back to the project.
Organization | Description of Use / Referenc |
---|---|
CloudAppi | Apification and generation of microservices |
RSI | Generation of microservices |
We're an inclusive and open community, welcoming you to join our effort to enhance ApiAddicts, and we're excited to prioritize tasks based on community input, inviting you to review and collaborate through our GitHub issue tracker.
Feel free to drop by and greet us on our GitHub discussion or Discord chat. You can also show your support by giving us some GitHub stars βοΈ, or by following us on Twitter, LinkedIn, and subscribing to our YouTube channel! π
Here you can check the definition of the API Swagger to SoapUI
- Base64 Decoding of Open API Specification Content
- Parse Open API Specification Content into swagger-core representation as Java POJO
- Create SoapUI Project
- Add OAuth 2.0 Profiles to SoapUI Project
- Add new REST Service to SoapUI Project
- Add Endpoints to REST Service
- Set basePath to REST Service
- Add Resources (Paths) to REST Service
- Add Methods (Verbs / Operations) to each Resource
- Set REST Request to each Method
- Set Credentials (OAuth 2.0 Profile)
- Set Parameters examples to REST Request
- Set Request Body example to REST Request
- Set Custom Headers to REST Request
- Set REST Request to each Method
- Add Methods (Verbs / Operations) to each Resource
- Add new TestSuites to SoapUI Project for each Method
- Add TestCases to TestSuite
- Add Execution Test Step (REST Request)
- Add TestCases to TestSuite
Nomenclature used:
- SoapUI Project: {apiName}_{apiVersion}
- REST Service: {apiName}
- Resource: {path}
- Method: {httpMethodInUppercase}
- Request: {defaultRequestName}
- Test Suite: {path}_{httpMethodInUppercase}_TestSuite
- Test Case (Default): Success_TestCase
- Test Case: {testCaseName}_TestCase
- Test Step: Execution_{httpMethodInUppercase}_TestStep
The variables are obtained from:
- apiName: property apiName of request body
- apiVersion: version defined in the 'info' section of the OpenAPI Spec
- path: each path defined in the OpenAPI Spec
- httpMethodInUppercase: each HTTP methods of paths defined in OpenAPI Spec
- testCaseName: each test case name defined in the property testCaseNames of request body
Technology | Description |
---|---|
Core Framework | Spring Boot 2 |
Technology | Description |
---|---|
JDK 11 | Java Development Kit |
Spring Boot 2 | Framework to ease the bootstrapping and development of new Spring Applications |
Maven 3 | Dependency Management |
Tomcat 9 | Server deploy WAR |
Technology | Description |
---|---|
Lombok | Never write another getter or equals method again, with one annotation your class has a fully featured builder, Automate your logging variables, and much more. |
Hibernate Validator | Express validation rules in a standardized way using annotation-based constraints and benefit from transparent integration with a wide variety of frameworks. |
Springdoc OpenAPI UI | OpenAPI 3 Library for spring boot projects. Is based on swagger-ui, to display the OpenAPI description. |
SoapUI core module | SoapUI is the world's leading Functional Testing tool for SOAP and REST testing. |
Swagger Parser | Parses OpenAPI definitions in JSON or YAML format into swagger-core representation as Java POJO, returning any validation warnings/errors. |
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
The project use "SoapUI Core Module" dependency, which is not maven dependency, so you must have internet access to download the dependency from the external repository, below is the repository configuration inside the pom.xml file.
...
<repositories>
<repository>
<id>SmartBearPluginRepository</id>
<url>https://rapi.tools.ops.smartbear.io/nexus/content/groups/public/</url>
</repository>
</repositories>
...
There are several ways to run a Spring Boot application on your local machine. One way is to execute the main
method in the Openapi2SoapUIApplication
class from your IDE.
- Download the zip or clone the Git repository.
- Unzip the zip file (if you downloaded one)
- Open IDE
- File -> Import -> Existing Maven Project -> Navigate to the folder project
- Select the project
- Choose the Spring Boot Application file (search for @SpringBootApplication)
- Right Click on the file and Run as Java Application
- URL to access: http://localhost:8080/api-openapi-to-soapui/v1/soap-ui-projects
Alternatively you can use the Spring Boot Maven plugin like so:
- Download the zip or clone the Git repository.
- Unzip the zip file (if you downloaded one)
- Open Command Prompt and Change directory (cd) to folder containing pom.xml
- To build and start the server type
$ mvn spring-boot:run
- Download the zip or clone the Git repository.
- Unzip the zip file (if you downloaded one)
- Open Command Prompt and Change directory (cd) to folder containing pom.xml
- To build and start the docker container type
$ mvn clean package -Pjar
$ docker-compose up -d
The code can also be built into a war and then deployed on a Tomcat server.
- Download the zip or clone the Git repository.
- Unzip the zip file (if you downloaded one)
- Open Command Prompt and Change directory (cd) to folder containing pom.xml
- To build the war type
$ mvn clean package
- Once the war is built, copy the output WAR to Tomcat's webapps directory.
$CATALINA_HOME/webapps/openapi2soapui-<version>.war
- Restart Tomcat Server
- URL to access: http://localhost:8080/openapi2soapui/api-openapi-to-soapui/v1/soap-ui-projects
The project directory has a particular directory structure. A representative project is shown below:
.
βββ src
β βββ main
β βββ java
β βββ org.apiaddicts.apitools.openapi2soapui
β β
β βββ org.apiaddicts.apitools.openapi2soapui.config
β β
β βββ org.apiaddicts.apitools.openapi2soapui.constants
β β
β βββ org.apiaddicts.apitools.openapi2soapui.controller
β β
β βββ org.apiaddicts.apitools.openapi2soapui.error
β βββ org.apiaddicts.apitools.openapi2soapui.error.exceptions
β βββ org.apiaddicts.apitools.openapi2soapui.error.validators
β β
β βββ org.apiaddicts.apitools.openapi2soapui.model
β β
β βββ org.apiaddicts.apitools.openapi2soapui.request
β β
β βββ org.apiaddicts.apitools.openapi2soapui.service
β β
β βββ org.apiaddicts.apitools.openapi2soapui.util
βββ src
β βββ main
β βββ resources
β βββ static
β β βββ api.yaml
β β
β βββ application.properties
β βββ log4j.properties
β βββ messages.properties
βββ JRE System Library
βββ Maven Dependencies
βββ src
βββ target
β βββopenapi2soapui-1.0.2
βββ .gitlab-ci.yaml
βββ lombok.config
βββ mvnw
βββ mvnw.cmd
βββ pom.xml
βββ README.md
config
- app configurations;constants
- app contants;controller
- listen to the client;error
- manage errors;exceptions
- custom exception handling;validators
- custom validations;model
- entities;request
- body request model/entities;service
- business logic;util
- utility classes;
resources/
- contains all the static resources, templates and property files.resources/static
- contains static resources.resources/static/api.yaml
- contains Open API Specification.resources/application.properties
- contains application-wide properties. Spring reads the properties defined in this file to configure your application. You can define serverβs default port, serverβs context path, database URLs etc, in this file.resources/log4j.properties
- contains contains the entire runtime configuration used by log4j. This file will contain log4j appenders information, log level information and output file names for file appenders.resources/messages.properties
- contains the error messages used in the application.- mvnw / mvnw.cmd - This allows you to run the Maven project without having Maven installed and present in the path. Download the correct version of Maven if it can't be found (as far as I know by default in your user home directory). The mvnw file is for Linux (bash) and mvnw.cmd is for the Windows environment.
pom.xml
- contains all the project dependencies
- Build the war type
$ mvn clean package
- Once the war is built, copy the output WAR to Tomcat's webapps directory.
$CATALINA_HOME/webapps/openapi2soapui.war
- Restart Tomcat Server
- URL to access: <protocol>://<host>:<port>/openapi2soapui/api-openapi-to-soapui/v1/soap-ui-projects
- cURL Example
- Open API Specification
- Swagger UI -
http://localhost:8080/swagger-ui.html
- Find Java Doc in javadoc folder
- Java Doc is generated in ./target/site/apidocs` folder using the Maven command
mvn javadoc:javadoc