
This tool is an OpenAPI Generator designed specifically for Intersystems IRIS. It ingests an OpenAPI Specification 2.0 (Swagger) document and automatically produces robust, maintainable, and executable ObjectScript code to validate your IRIS REST APIs.
You can use it via VSCode Extension (recommended) or manually via terminal.
🚧 Note: Some data types aren’t still fully covered, like List and File. Those will be added in the next releases.
Key Features:
Target Audience: IRIS developers, QA engineers, and DevOps teams looking to integrate automated testing into their Intersystems IRIS ObjectScript projects.
This project was inspired by the idea Introduce generated unit tests for REST API calls generated by ^%REST vs Open API spec, originally proposed by Evgeny Shvarov.
The easiest way to use this tool is via the official VSCode Extension. It detects if you are editing an OpenAPI file and allows you to generate the IRIS test client with a single click.
You can install the IRIS OAS Upload & Gen extension directly from the Visual Studio Code Marketplace.
After installing, go to Settings > Extensions > IRIS OAS Test Generator and configure the connection to your IRIS instance:
http://localhost:52773/iris-oas-test-gen/api/generate-upload)._SYSTEM / SYS)./tmp)./tmp/output).$(cloud-upload) in the editor title bar (top right).
Before using the extension, you need the IRIS backend running with the generator code.
Make sure you have git and Docker desktop installed.
Clone/git pull the repo into any local directory
git clone https://github.com/musketeers-br/iris-oas-test-gen.git
cd iris-oas-test-gen
chmod -R o+w tests # allow container processes to write in the tests directory
Build and run InterSystems IRIS in container:
Note: Users running containers on a Linux CLI, should use “docker compose” instead of “docker-compose”
See Install the Compose plugin
docker-compose up -d
With the container built and running, let’s access the IRIS terminal
docker exec -it iris-oas-test-gen-iris-1 /bin/bash
iris session iris -U IRISAPP
If you prefer not to use the VSCode extension, you can generate tests manually via the IRIS Terminal.
Now, we can generate the tests classes. For this example, this toy REST API specification will be used.
Set openapiFile = "/home/irisowner/dev/assets/person-api.json"
Set outputDir = "/tmp/output"
Write ##class(dc.musketeers.irisOasTestGen.Main).Run(openapiFile, outputDir)
Halt
By default the output files are stored in /tmp/output/src. Let’s copy them to the mounted volume and allow edition.
cp -r /tmp/output/src /home/irisowner/dev/tests
chmod -R o+w /home/irisowner/dev/tests/src # allow edition in the host machine
exit
Now open VSCode on the project dir.
code .
You can check the generated files inside dir tests.


Now you have templates with client calls for each operation in the OpenAPI specification and the corresponding test method for your implementation. For instance:
/// Create a new Person record /// OperationId: createPerson Method CreatePerson( pPerson As model.Person) As %Net.HttpResponse { Set path = "/" Set queryParams = "" Set bodyStream = "" Set headers = ##class(%ListOfDataTypes).%New() Set formParams = ##class(%ListOfDataTypes).%New() Set multipartParams = ##class(%ListOfDataTypes).%New()// Handle body $$$ThrowOnError(pPerson.%JSONExportToStream(.bodyStream)) Set request = ##class(utils.HttpUtils).%New() Set request.BasePath = ..#BasePath Set request.HttpRequest.Https = 1 Set httpResponse = request.SendRequest("POST", path, queryParams, bodyStream, headers, formParams, multipartParams) Return httpResponse}
/// Unit test for createPerson
Method TestCreatePerson()
{
// TODO:
// Set pPerson = ""
// Set httpResponse = ..CreatePerson(
// pPerson
// )
}
Generating, implementing and running tests for a simple OpenAPI 2.0 specification
If you want to modify the extension or build it from source, follow these steps:
Navigate to the extension folder:
cd vscode-extension
Install dependencies:
npm install
Install vsce globally:
vsce is the official tool for packaging VSCode extensions.
npm install -g @vscode/vsce
Compile the extension:
This will transpile the TypeScript code into JavaScript.
npm run compile
Package the extension:
This command creates the .vsix file.
vsce package
After running the package command, a file named iris-oas-test-generator-0.0.1.vsix will be created. You can install this file directly into VSCode via the Extensions view (… > “Install from VSIX…”).
Iris OAS Test Gen is developed with ❤️ by the Musketeers Team
