Skip to content

πŸ› οΈ OpenAPI2SoapUI Release Swagger Java License: LGPL v3

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 :octocat: 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

Twitter Discord LinkedIn Facebook YouTube

πŸ™Œ Join the OpenAPI2SoapUI Adopters list

πŸ“’ 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

πŸ‘©πŸ½β€πŸ’» Contribute to ApiAddicts

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! πŸš€

"Buy Me A Coffee"

βš™οΈ Functionalities

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
    • Add new TestSuites to SoapUI Project for each Method
      • Add TestCases to TestSuite
        • Add Execution Test Step (REST Request)

Nomenclature used:

  • SoapUI Project: {apiName}_{apiVersion}
  • REST Service: {apiName}
  • Resource: {path}
  • Method: {httpMethodInUppercase}
  • Request: {defaultRequestName}
  • Test Suite: {path}_{apiName}_{apiVersion}-{httpMethodInUppercase}-Suite (run type SEQUENTIAL, abortOnError false)
  • Test Case: {httpMethodInUppercase}_Case{CaseDescription}
  • 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

Technology stack

Overview

Technology Description
Core Framework Spring Boot 3

Server - Backend

Technology Description
JDK 21 Java Development Kit
Spring Boot 3 Framework to ease the bootstrapping and development of new Spring Applications
Maven 3 Dependency Management
Tomcat 10.1+ Server deploy WAR (Jakarta EE / Servlet 6)

Libraries and Plugins

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.

πŸ“‘ Getting started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

External dependencies

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>
  
  ...

Running the application with IDE

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.

Example (Eclipse and its offshoots) :

  • 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

Running the application locally with Maven

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 -pl openapi2soapui-rest -am spring-boot:run

The HTTP service lives in the openapi2soapui-rest module, hence the -pl; -am also builds the openapi2soapui-core module it depends on.

Running the application in Docker

  • 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

Running the application deploying WAR on Tomcat

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

The war is produced at openapi2soapui-rest/target/openapi2soapui.war.

πŸ–₯️ Command line interface (CLI)

The same generation is available as a standalone command, with no server involved: an OpenAPI spec in JSON or YAML goes in, the SoapUI project XML comes out. It reuses the exact same engine, request model and validations as the HTTP service, so both produce identical projects.

Build

$ mvn clean package -DskipTests

The jar is produced at openapi2soapui-cli/target/openapi2soapui-cli.jar

Options

Option Default What it does
-f, --file <path> β€” OpenAPI spec, v2 or v3, JSON or YAML, as plain text
-c, --config <path> β€” JSON file with the same body as the REST API, openApiSpec base64 encoded. The only way to pass oAuth2Profiles, customAuthorizationsFile and examples. With -f, the spec comes from -f
-o, --output <path> ./out Folder, or a path ending in .xml for an exact file name
-n, --api-name <name> spec title, or spec file name apiName
-H, --header <key:value> none Request header, repeatable, appended to the config's
--server-pattern <text> first server in the spec Pick the spec server whose URL contains this text. Accepts the %text% form too
--test-case-names <a,b> none Extra test cases, comma separated
--number-of-scopes <n> 0 numberOfScopes, only relevant with --has-scopes
--read-only off Generate only GET and OPTIONS test cases
--minimal-endpoints off Collapse the CaseErrorRequired{Field} test cases into one
--microcks-headers off Add the X-Microcks-Response-Name header to every request
--generate-one-of-any-of off Resolve oneOf/anyOf using their first candidate
--schema-is-inline off Embed the response schema instead of using a project property
--is-inline off Embed body example values instead of project properties
--has-scopes off One extra test case per oAuth2Profiles entry
--application-token off Extra test case per CLIENT_CREDENTIALS profile
--no-validate-schema schema assertion on Do not add the schema assertion
--no-schema-pretty-print pretty print on Serialize the schema compactly
-h, --help β€” Show the help
-V, --version β€” Show the version

Every option also accepts the --option=value form.

Commands

Show the available options, and the build version.

$ java -jar openapi2soapui-cli.jar --help
$ java -jar openapi2soapui-cli.jar --version

Generate a project. Without -o it lands in ./out, named {apiName}_{apiVersion}-soapui-project.xml; an -o value ending in .xml is taken as the exact file.

$ java -jar openapi2soapui-cli.jar -f petstore.yaml
$ java -jar openapi2soapui-cli.jar -f petstore.yaml -n Orders -o ./projects
$ java -jar openapi2soapui-cli.jar -f petstore.yaml -n Orders -o ./orders.xml

Narrow down what gets generated: --read-only keeps only the GET and OPTIONS cases, --minimal-endpoints collapses the CaseErrorRequired ones, and --test-case-names adds a copy of the happy path under each name.

$ java -jar openapi2soapui-cli.jar -f petstore.yaml --read-only
$ java -jar openapi2soapui-cli.jar -f petstore.yaml --minimal-endpoints
$ java -jar openapi2soapui-cli.jar -f petstore.yaml --test-case-names Smoke,Regression

Send the same headers with every request. -H is repeatable; --microcks-headers adds the X-Microcks-Response-Name header a Microcks mock expects.

$ java -jar openapi2soapui-cli.jar -f petstore.yaml -H "Authorization:Bearer <token>" -H "X-Correlation-Id:qa-42"
$ java -jar openapi2soapui-cli.jar -f petstore.yaml --microcks-headers

Control the response schema assertion, which is added by default: drop it, embed the schema in the script instead of storing it as a project property, or serialize it compactly.

$ java -jar openapi2soapui-cli.jar -f petstore.yaml --no-validate-schema
$ java -jar openapi2soapui-cli.jar -f petstore.yaml --schema-is-inline
$ java -jar openapi2soapui-cli.jar -f petstore.yaml --no-schema-pretty-print

Write the request body example values literally, instead of referencing project properties.

$ java -jar openapi2soapui-cli.jar -f petstore.yaml --is-inline

Target one environment when the spec declares several servers. The value is matched as a substring, so %staging% works too.

$ java -jar openapi2soapui-cli.jar -f petstore.yaml --server-pattern staging

Resolve oneOf and anyOf bodies using their first candidate, instead of leaving a plain placeholder.

$ java -jar openapi2soapui-cli.jar -f petstore.yaml --generate-one-of-any-of

Pass the full configuration. -c takes the same JSON body the REST API accepts, and is the only way to provide oAuth2Profiles, customAuthorizationsFile and examples. Add -f to read the spec from a plain file instead of the base64 openApiSpec the config carries.

$ java -jar openapi2soapui-cli.jar -c request.json
$ java -jar openapi2soapui-cli.jar -c request.json -f petstore.yaml

Generate the OAuth2 scope variants once the profiles are in place.

$ java -jar openapi2soapui-cli.jar -c request.json -f petstore.yaml --has-scopes --number-of-scopes 2
$ java -jar openapi2soapui-cli.jar -c request.json -f petstore.yaml --has-scopes --application-token

Any supported input works the same way: OpenAPI 3 or Swagger 2.0, written in YAML or JSON.

$ java -jar openapi2soapui-cli.jar -f petstore-v2.yaml
$ java -jar openapi2soapui-cli.jar -f petstore.json

Installing it as a standalone command

The jar carries its own dependencies, so it runs on any machine with a Java 21 runtime: copy it over, no Maven and no checkout of this repository needed.

$ mvn clean package -DskipTests
$ cp openapi2soapui-cli/target/openapi2soapui-cli.jar /opt/openapi2soapui/

To call it by name instead of typing the full java -jar, put a wrapper on the PATH. On Linux and macOS, save this as /usr/local/bin/o2s and make it executable with chmod +x /usr/local/bin/o2s.

#!/bin/sh
exec java -jar /opt/openapi2soapui/openapi2soapui-cli.jar "$@"

On Windows, save this as o2s.cmd in any folder already on the PATH.

@echo off
java -jar C:\openapi2soapui\openapi2soapui-cli.jar %*

The generation is then one word, with the same options as above.

$ o2s -f petstore.yaml -o ./projects

Files and Directories Structure

The project directory has a particular directory structure. A representative project is shown below:

Project Structure

.
β”œβ”€β”€ pom.xml                                     parent: packaging pom, shared properties and profiles
β”œβ”€β”€ openapi2soapui-core                         the conversion engine, no Spring and no web
β”‚   └── src/main
β”‚       β”œβ”€β”€ java/org.apiaddicts.apitools.openapi2soapui
β”‚       β”‚   β”œβ”€β”€ .constants
β”‚       β”‚   β”œβ”€β”€ .error.exceptions
β”‚       β”‚   β”œβ”€β”€ .error.validators
β”‚       β”‚   β”œβ”€β”€ .model                          SoapUIProject, the engine itself
β”‚       β”‚   β”œβ”€β”€ .request                        request model shared by both front ends
β”‚       β”‚   └── .util
β”‚       └── resources
β”‚           └── messages.properties
β”œβ”€β”€ openapi2soapui-rest                         the HTTP service (war by default, jar with -Pjar)
β”‚   └── src/main
β”‚       β”œβ”€β”€ java/org.apiaddicts.apitools.openapi2soapui
β”‚       β”‚   β”œβ”€β”€ (Openapi2SoapUIApplication)
β”‚       β”‚   β”œβ”€β”€ .config
β”‚       β”‚   β”œβ”€β”€ .controller
β”‚       β”‚   β”œβ”€β”€ .error                          HTTP error payload and controller advice
β”‚       β”‚   β”œβ”€β”€ .service
β”‚       β”‚   └── .util
β”‚       └── resources
β”‚           β”œβ”€β”€ static/api.yaml
β”‚           β”œβ”€β”€ application.properties
β”‚           β”œβ”€β”€ banner.txt
β”‚           └── log4j.properties
β”œβ”€β”€ openapi2soapui-cli                          the standalone command line jar
β”‚   └── src/main
β”‚       β”œβ”€β”€ java/org.apiaddicts.apitools.openapi2soapui.cli
β”‚       └── resources
β”‚           β”œβ”€β”€ cli.properties                  version reported by the version flag
β”‚           β”œβ”€β”€ logback.xml
β”‚           └── soapui-cli-log4j.xml            keeps SoapUI from flooding stdout
β”œβ”€β”€ lombok.config
β”œβ”€β”€ mvnw
β”œβ”€β”€ mvnw.cmd
└── README.md

Modules

  • openapi2soapui-core - the conversion engine and the request model. Deliberately free of Spring and of any web dependency, so the CLI can embed it without booting an application context;
  • openapi2soapui-rest - the HTTP service. Produces openapi2soapui.war by default and openapi2soapui.jar with -Pjar;
  • openapi2soapui-cli - the command line front end. Produces openapi2soapui-cli.jar;

Packages

  • config - app configurations;
  • constants - app contants;
  • controller - listen to the client;
  • cli - command line front end;
  • error - manage errors;
  • exceptions - custom exception handling;
  • validators - custom validations;
  • model - entities;
  • request - body request model/entities;
  • service - business logic;
  • util - utility classes;

Resources

  • 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. It lives in the core module because both the HTTP service and the CLI report the same validation messages from it.
  • 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

Deploy

  • 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

Documentation

mvn javadoc:javadoc

πŸ’› Sponsors

cloudappi

About

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 applic…

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

11 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages