Follow

Upload a Swagger Specification

Description

This API lets you upload a Swagger specification to API Test Maker and automatically create auto generated tests for each operation in your API. This API call includes parameters to identify the location of your Swagger specification and a configuration file. The configuration file includes authentication credentials, such as an API key, Basic Auth, or OAuth credentials.

URL

https://blazeapi.blazemeter.com/api/v1/testGenerator

Request Parameters

Parameter Description
name Name of the model.
spec The path to the Swagger specification.
configuration The path to the configuration file that defines authentication credentials, such as API key, Basic Auth, and OAuth. This is an optional file parameter.


cURL

curl -i -X POST -H "Content-Type: multipart/form-data" -F "name=<name>" -F "spec=@<path_to_file>/<spec_name>.yaml" -F "configuration=@<path_to_file>/<conf_file_name>.json" <http/https>://<host>/api/v1/testGenerator --user 'id:secret'

Example Response

{
"api_version": 4,
"error": null,
"result": {
"modelId": "59b04f20c802840001999bfc",
"modelName": "MyTest1",
"apiKeyDescription": "mysample",
  }
}

 

Example Configuration Files

Note: In the following examples, activeAuthorizationMode is an optional field. If you need to provide more than one authorization mode, you can pass the value for the key that drives the authorization selection for the model. You cannot provide more than one authorization mode without using activeAuthorizationMode.

Example Configuration File with API Key

{
   "location": "us-east-1",
"authorization": {
"activeAuthorizationMode": "apikey",
"apikey": {
"description": "amadeus_key",
"name": "apikey",
"value": "qvAG30cPhW42ZwLzuF0npgkY7fcbztPf",
"in": "query"
}
}
}

 

Example Configuration File with Basic Auth

{
   "location": "us-east-1",
"authorization": {
"activeAuthorizationMode": "basicauth",
"basicAuth": {
"description": "basicauthexample",
"username": "user",
"password": "passwordtextcouldbeasecretbyprovider"
}
}
}

 

Example Configuration File with OAuth

{
   "location": "us-east-1",
"authorization": {
"activeAuthorizationMode": "oauth",
"oAuth": {
"description": "myoauth",
"id": "admin",
"secret": "passwordsecret",
"url": "http://oauth.api.com"
}
}
}

 

Valid Configuration Files

You can define all available authorization types, and then use activeAuthorizationMode to determine which authorization is applied for your model.

{
"authorization": {
"activeAuthorizationMode": "oauth",
"apikey": {
"description": "amadeus_key",
"name": "apikey",
"value": "qvAG30cPhW42ZwLzuF0npgkY7fcbztPf",
"in": "query"
},
"basicAuth": {
"description": "basicauthexample",
"username": "user",
"password": "passwordtextcouldbeasecretbyprovider"
},
"oAuth": {
"description": "myoauth",
"id": "admin",
"secret": "passwordsecret",
"url": "http://oauth.api.com"
}
}
}

 

You can also set authorization to "null" if you do not need authorization for your model.

{
"authorization": null
}

Invalid Configuration Files

activeAuthorizationMode is an optional field, but it becomes a required field if one or more authorization types are defined (not null).

Request Response
{
"authorization": {
"oAuth": {
"description": "myoauth",
"id": "admin",
"secret": "passwordsecret",
"url": "http://oauth.api.com"
}
}
}
{
  "result" : null,
  "error" : {
    "code" : 406,
    "message" : "Active Authorization Mode must be provided",
    "moreInfo" : null
  },
  "api_version" : 4
}

The valid values for activeAuthorizationMode are:

  • apikey
  • basicauth
  • oauth
Request Response
{
"authorization": {
"activeAuthorizationMode": "test",
    "oAuth": {
"description": "myoauth",
"id": "admin",
"secret": "passwordsecret",
"url": "http://oauth.api.com"
}
}
}
{
  "result" : null,
  "error" : {
    "code" : 406,
    "message" : "Active Authorization Mode must be apikey/basicauth/oauth",
    "moreInfo" : null
  },
  "api_version" : 4
}

If you define a valid activeAuthorizationMode, but the corresponding authorization is not provided, you will see the following error.

Request Response
{
"authorization": {
"activeAuthorizationMode": "apikey",
    "oAuth": {
"description": "myoauth",
"id": "admin",
"secret": "passwordsecret",
"url": "http://oauth.api.com"
}
}
}
{
  "result" : null,
  "error" : {
    "code" : 406,
    "message" : "Exception during reading the configuration file: Active Authorization Mode is apikey but apikey configuration is not provided",
    "moreInfo" : null
  },
  "api_version" : 4
}

If you define a valid activeAuthorizationMode, but no authorization is not provided, you will see the following error.

Request Response
{
"authorization": {
"activeAuthorizationMode": "oauth",
"apikey": null,
"basicAuth": null,
"oAuth": null
}
}
{
  "result" : null,
  "error" : {
    "code" : 406,
    "message" : "Active Authorization Mode is provided but configuration is missing.",
    "moreInfo" : null
  },
  "api_version" : 4
} 

 

Request Response
{
"authorization": {
"activeAuthorizationMode": "oauth"
}
}
{
  "result" : null,
  "error" : {
    "code" : 406,
    "message" : "Active Authorization Mode is provided but configuration is missing.",
    "moreInfo" : null
  },
  "api_version" : 4
}
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.