Karate API template generation tool - NextensArelB/SwaggerGenerationTool GitHub Wiki
[[TOC]]
WIP (this page is under construction)
##Introduction We have developed a tool that can generate template API scripts that can be used as a starting point for your API end point testing. This tool does two main things:
- Creates for each end point of your API a Karate tempate script with basic template contents
- Creates a Excel sheet containing all calls that can be used as worksheet to see what you have done.
##The package You need to collect the NPM package from DevOps: Go the Devops and go to: NextensNL -> Nextens -> Artifacts -> KarateNPM feed Here you shoud find all Karate NPM packages. Look for the package: "swagger-to-karate". If you have a 64 bit machine (you probably have) you need to select: swagger-to-karate-x64. To find out if you have a 64 bit machine you can cick on the Winodws key in the windowsbar and type in the search field for "system information". There you can check for "System type":

##Installation Click on the required package swagger-to-karate or swagger-to-karate-x64. This package has a slightly different installation instructions then the other NPM packages. Copy paste the CLI instructions to install.
##How to run Navigate to the folder where have the tool installed. You need to execute: AutomatedKarateCreation.exe. In the next section we will go through the steps:
- The URL of Swagger JSON You will have to enter the URL for the Swagger Json, for example for Swagger version 2 you can use:
https://localhost:7182/swagger/v1/swagger.json
In newer versions of Swagger (V3 and higher) there is a link on the Swagger main page:
2. The authentication key
When your API requires a authentication key (like Bearer token) you can enter it here
3. The URL of the API
This will be the plain API URL
4. The name of the API
For example:
ClientApi
The tool will repond with the amount Karate templates it has created:
I am done generating the tests, please check the following folder: c:\repos\AutomatedTests\Karate-API-Template\tests\karate\WeatherForecastApi for the tests. I have generated 1 tests for all 1 endpoints.
The following are the number of tests generated for each method type:
GET: 22
POST: 3
PUT: 0
PATCH: 0
DELETE: 0
Press any key to exit...
##Generated files The tool generates files in the following folder: C:\repos\AutomatedTests\Karate-API-Template\tests\karate\[API naam] This folder also contains the generated Excel sheet with an overview of all calls and the Karate files one per end-point.
##Nextens meetup
If you want a more visual tutorial of how the tool is used, please check out the Nextens Meetup about the tool! https://reedelsevier-my.sharepoint.com/personal/eykelenf_b2b_regn_net/_layouts/15/stream.aspx?id=%2Fpersonal%2Feykelenf%5Fb2b%5Fregn%5Fnet%2FDocuments%2FRecordings%2FIntroducing%20Karate%20Jbang%20NPM%20packages%20and%20a%20tool%20to%20generate%20karate%20tests%20from%20swagger%20%20Nextens%20Meetup%2016%2D20240215%5F135720%2DMeeting%20Recording%2Emp4&nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJTdHJlYW1XZWJBcHAiLCJyZWZlcnJhbFZpZXciOiJTaGFyZURpYWxvZy1MaW5rIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXcifX0%3D&referrer=StreamWebApp%2EWeb&referrerScenario=AddressBarCopied%2Eview%2Ec9306375%2D65af%2D4135%2D9979%2D831e68a61e5e