@grafana/openapi-to-k6 0.2.6 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/constants.js +7 -3
- package/dist/generator/index.js +13 -6
- package/dist/generator/k6Client.js +8 -56
- package/dist/generator/k6ScriptBuilder.js +256 -0
- package/dist/helper.js +16 -0
- package/examples/basic_schema/schema.json +2 -1
- package/examples/basic_schema/single/k6-script.sample.ts +3 -2
- package/examples/basic_schema/single/simpleAPI.ts +4 -1
- package/examples/basic_schema/split/k6-script.sample.ts +3 -2
- package/examples/basic_schema/split/simpleAPI.schemas.ts +2 -1
- package/examples/basic_schema/split/simpleAPI.ts +3 -1
- package/examples/basic_schema/tags/default.ts +3 -1
- package/examples/basic_schema/tags/k6-script.sample.ts +4 -3
- package/examples/basic_schema/tags/simpleAPI.schemas.ts +2 -1
- package/examples/form_data_schema/schema.json +6 -3
- package/examples/form_data_schema/single/formDataAPI.ts +8 -6
- package/examples/form_data_schema/single/k6-script.sample.ts +10 -2
- package/examples/form_data_schema/split/formDataAPI.schemas.ts +5 -5
- package/examples/form_data_schema/split/formDataAPI.ts +4 -2
- package/examples/form_data_schema/split/k6-script.sample.ts +10 -2
- package/examples/form_data_schema/tags/default.ts +4 -2
- package/examples/form_data_schema/tags/formDataAPI.schemas.ts +5 -5
- package/examples/form_data_schema/tags/k6-script.sample.ts +11 -3
- package/examples/form_url_encoded_data_schema/schema.json +6 -3
- package/examples/form_url_encoded_data_schema/single/formURLEncodedAPI.ts +8 -6
- package/examples/form_url_encoded_data_schema/single/k6-script.sample.ts +11 -2
- package/examples/form_url_encoded_data_schema/split/formURLEncodedAPI.schemas.ts +5 -5
- package/examples/form_url_encoded_data_schema/split/formURLEncodedAPI.ts +4 -2
- package/examples/form_url_encoded_data_schema/split/k6-script.sample.ts +11 -2
- package/examples/form_url_encoded_data_schema/tags/default.ts +4 -2
- package/examples/form_url_encoded_data_schema/tags/formURLEncodedAPI.schemas.ts +5 -5
- package/examples/form_url_encoded_data_schema/tags/k6-script.sample.ts +12 -3
- package/examples/form_url_encoded_data_with_query_params_schema/schema.json +8 -4
- package/examples/form_url_encoded_data_with_query_params_schema/single/formURLEncodedAPIWithQueryParameters.ts +8 -6
- package/examples/form_url_encoded_data_with_query_params_schema/single/k6-script.sample.ts +19 -6
- package/examples/form_url_encoded_data_with_query_params_schema/split/formURLEncodedAPIWithQueryParameters.schemas.ts +5 -5
- package/examples/form_url_encoded_data_with_query_params_schema/split/formURLEncodedAPIWithQueryParameters.ts +4 -2
- package/examples/form_url_encoded_data_with_query_params_schema/split/k6-script.sample.ts +19 -6
- package/examples/form_url_encoded_data_with_query_params_schema/tags/default.ts +4 -2
- package/examples/form_url_encoded_data_with_query_params_schema/tags/formURLEncodedAPIWithQueryParameters.schemas.ts +5 -5
- package/examples/form_url_encoded_data_with_query_params_schema/tags/k6-script.sample.ts +14 -3
- package/examples/get_request_with_path_parameters_schema/schema.json +2 -1
- package/examples/get_request_with_path_parameters_schema/single/k6-script.sample.ts +6 -2
- package/examples/get_request_with_path_parameters_schema/single/simpleAPI.ts +4 -2
- package/examples/get_request_with_path_parameters_schema/split/k6-script.sample.ts +6 -2
- package/examples/get_request_with_path_parameters_schema/split/simpleAPI.schemas.ts +2 -2
- package/examples/get_request_with_path_parameters_schema/split/simpleAPI.ts +3 -1
- package/examples/get_request_with_path_parameters_schema/tags/default.ts +3 -1
- package/examples/get_request_with_path_parameters_schema/tags/k6-script.sample.ts +7 -3
- package/examples/get_request_with_path_parameters_schema/tags/simpleAPI.schemas.ts +2 -2
- package/examples/headers_schema/schema.json +2 -1
- package/examples/headers_schema/single/headerDemoAPI.ts +5 -3
- package/examples/headers_schema/single/k6-script.sample.ts +15 -4
- package/examples/headers_schema/split/headerDemoAPI.schemas.ts +1 -1
- package/examples/headers_schema/split/headerDemoAPI.ts +5 -3
- package/examples/headers_schema/split/k6-script.sample.ts +15 -4
- package/examples/headers_schema/tags/default.ts +5 -3
- package/examples/headers_schema/tags/headerDemoAPI.schemas.ts +1 -1
- package/examples/headers_schema/tags/k6-script.sample.ts +16 -5
- package/examples/no_title_schema/single/k6-script.sample.ts +3 -2
- package/examples/no_title_schema/single/k6Client.ts +3 -1
- package/examples/no_title_schema/split/k6-script.sample.ts +3 -2
- package/examples/no_title_schema/split/k6Client.schemas.ts +1 -1
- package/examples/no_title_schema/split/k6Client.ts +3 -1
- package/examples/no_title_schema/tags/default.ts +3 -1
- package/examples/no_title_schema/tags/k6-script.sample.ts +4 -3
- package/examples/no_title_schema/tags/k6Client.schemas.ts +1 -1
- package/examples/post_request_with_query_params/schema.json +14 -7
- package/examples/post_request_with_query_params/single/exampleAPI.ts +8 -6
- package/examples/post_request_with_query_params/single/k6-script.sample.ts +11 -2
- package/examples/post_request_with_query_params/split/exampleAPI.schemas.ts +5 -5
- package/examples/post_request_with_query_params/split/exampleAPI.ts +4 -2
- package/examples/post_request_with_query_params/split/k6-script.sample.ts +11 -2
- package/examples/post_request_with_query_params/tags/default.ts +4 -2
- package/examples/post_request_with_query_params/tags/exampleAPI.schemas.ts +5 -5
- package/examples/post_request_with_query_params/tags/k6-script.sample.ts +12 -3
- package/examples/query_params_schema/schema.json +20 -10
- package/examples/query_params_schema/single/exampleAPI.ts +5 -3
- package/examples/query_params_schema/single/k6-script.sample.ts +8 -2
- package/examples/query_params_schema/split/exampleAPI.schemas.ts +3 -3
- package/examples/query_params_schema/split/exampleAPI.ts +3 -1
- package/examples/query_params_schema/split/k6-script.sample.ts +8 -2
- package/examples/query_params_schema/tags/default.ts +3 -1
- package/examples/query_params_schema/tags/exampleAPI.schemas.ts +3 -3
- package/examples/query_params_schema/tags/k6-script.sample.ts +9 -3
- package/examples/simple_post_request_schema/schema.json +30 -15
- package/examples/simple_post_request_schema/single/exampleAPI.ts +14 -12
- package/examples/simple_post_request_schema/single/k6-script.sample.ts +16 -2
- package/examples/simple_post_request_schema/split/exampleAPI.schemas.ts +11 -11
- package/examples/simple_post_request_schema/split/exampleAPI.ts +4 -2
- package/examples/simple_post_request_schema/split/k6-script.sample.ts +16 -2
- package/examples/simple_post_request_schema/tags/default.ts +4 -2
- package/examples/simple_post_request_schema/tags/exampleAPI.schemas.ts +11 -11
- package/examples/simple_post_request_schema/tags/k6-script.sample.ts +17 -3
- package/package.json +5 -2
- package/src/constants.ts +7 -3
- package/src/generator/index.ts +20 -7
- package/src/generator/k6Client.ts +6 -73
- package/src/generator/k6ScriptBuilder.ts +328 -0
- package/src/helper.ts +17 -0
- package/tests/e2e/schema.json +135 -18
- package/tests/e2e/single/k6Script.ts +54 -1
- package/tests/functional-tests/helper.ts +16 -0
- package/tests/functional-tests/test-generator/fixtures/basic_parameter_in_ref.json +59 -0
- package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/form_data_schema.json +1 -1
- package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/form_url_encoded_data_schema.json +1 -1
- package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/headers_schema.json +2 -2
- package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/simple_post_request_schema.json +1 -1
- package/tests/functional-tests/test-generator/generator.test.ts +154 -0
- package/tests/functional-tests/test-sample-k6-scripts/fixtures/schema_using_ref_models.json +394 -0
- package/tests/functional-tests/test-sample-k6-scripts/fixtures/schema_with_examples.json +416 -0
- package/tests/functional-tests/test-sample-k6-scripts/fixtures/schema_with_no_variables.json +32 -0
- package/tests/functional-tests/test-sample-k6-scripts/sampleK6Scripts.test.ts +248 -0
- package/tests/functional-tests/test-tags-filtering/tagsFiltering.test.ts +166 -0
- package/{vite.config.js → vite.config.mjs} +4 -0
- package/tests/functional-tests/generator.test.ts +0 -319
- /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/basic_schema.json +0 -0
- /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/form_url_encoded_data_with_query_params_schema.json +0 -0
- /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/get_request_with_path_parameters_schema.json +0 -0
- /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/no_title_schema.json +0 -0
- /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/post_request_with_query_params.json +0 -0
- /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/query_params_schema.json +0 -0
- /package/tests/functional-tests/{fixtures → test-tags-filtering/fixtures}/tags_filtering.json +0 -0
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FormURLEncodedAPIWithQueryParametersClient } from './formURLEncodedAPIWithQueryParameters.ts'
|
|
2
2
|
|
|
3
3
|
const baseUrl = '<BASE_URL>'
|
|
4
|
-
const
|
|
4
|
+
const formURLEncodedAPIWithQueryParametersClient =
|
|
5
|
+
new FormURLEncodedAPIWithQueryParametersClient({ baseUrl })
|
|
5
6
|
|
|
6
7
|
export default function () {
|
|
8
|
+
let postSubmitFormBody, params
|
|
9
|
+
|
|
7
10
|
/**
|
|
8
11
|
* Submit form data with query parameters
|
|
9
12
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
postSubmitFormBody = {
|
|
14
|
+
name: 'John Doe',
|
|
15
|
+
age: '25',
|
|
16
|
+
email: 'john.doe@example.com',
|
|
17
|
+
}
|
|
18
|
+
params = {
|
|
19
|
+
token: 'Bearer abcdef12345',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const postSubmitFormResponseData =
|
|
23
|
+
formURLEncodedAPIWithQueryParametersClient.postSubmitForm(
|
|
24
|
+
postSubmitFormBody,
|
|
25
|
+
params
|
|
26
|
+
)
|
|
14
27
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.1
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Form URL Encoded API with Query Parameters
|
|
5
5
|
* Service version: 1.0.0
|
|
@@ -25,6 +25,8 @@ export class DefaultClient {
|
|
|
25
25
|
commonRequestParameters?: Params
|
|
26
26
|
}) {
|
|
27
27
|
this.cleanBaseUrl = clientOptions.baseUrl.replace(/\/+$/, '')
|
|
28
|
+
|
|
29
|
+
this.commonRequestParameters = clientOptions.commonRequestParameters || {}
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
/**
|
|
@@ -55,8 +57,8 @@ export class DefaultClient {
|
|
|
55
57
|
{
|
|
56
58
|
...mergedRequestParameters,
|
|
57
59
|
headers: {
|
|
58
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
59
60
|
...mergedRequestParameters?.headers,
|
|
61
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
60
62
|
},
|
|
61
63
|
}
|
|
62
64
|
)
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.1
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Form URL Encoded API with Query Parameters
|
|
5
5
|
* Service version: 1.0.0
|
|
6
6
|
*/
|
|
7
7
|
export type PostSubmitForm400 = {
|
|
8
|
-
error?: string
|
|
9
8
|
success?: boolean
|
|
9
|
+
error?: string
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export type PostSubmitForm200 = {
|
|
13
|
-
message?: string
|
|
14
13
|
success?: boolean
|
|
14
|
+
message?: string
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export type PostSubmitFormBody = {
|
|
18
|
+
/** Name of the user */
|
|
19
|
+
name: string
|
|
18
20
|
/** Age of the user */
|
|
19
21
|
age?: number
|
|
20
22
|
/** Email address of the user */
|
|
21
23
|
email: string
|
|
22
|
-
/** Name of the user */
|
|
23
|
-
name: string
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export type PostSubmitFormParams = {
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DefaultClient } from './default.ts'
|
|
2
2
|
|
|
3
3
|
const baseUrl = '<BASE_URL>'
|
|
4
|
-
const
|
|
4
|
+
const defaultClient = new DefaultClient({ baseUrl })
|
|
5
5
|
|
|
6
6
|
export default function () {
|
|
7
|
+
let postSubmitFormBody, params
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* Submit form data with query parameters
|
|
9
11
|
*/
|
|
10
|
-
|
|
12
|
+
postSubmitFormBody = {
|
|
13
|
+
name: 'John Doe',
|
|
14
|
+
age: '25',
|
|
15
|
+
email: 'john.doe@example.com',
|
|
16
|
+
}
|
|
17
|
+
params = {
|
|
18
|
+
token: 'Bearer abcdef12345',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const postSubmitFormResponseData = defaultClient.postSubmitForm(
|
|
11
22
|
postSubmitFormBody,
|
|
12
23
|
params
|
|
13
24
|
)
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { SimpleAPIClient } from './simpleAPI.ts'
|
|
2
2
|
|
|
3
3
|
const baseUrl = '<BASE_URL>'
|
|
4
|
-
const
|
|
4
|
+
const simpleAPIClient = new SimpleAPIClient({ baseUrl })
|
|
5
5
|
|
|
6
6
|
export default function () {
|
|
7
|
+
let id
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* Get an item by its ID
|
|
9
11
|
*/
|
|
10
|
-
|
|
12
|
+
id = '12345'
|
|
13
|
+
|
|
14
|
+
const getItemByIdResponseData = simpleAPIClient.getItemById(id)
|
|
11
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.1
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Simple API
|
|
5
5
|
* An API with a single GET request that takes a path parameter
|
|
@@ -9,9 +9,9 @@ import { URL } from 'https://jslib.k6.io/url/1.0.0/index.js'
|
|
|
9
9
|
import http from 'k6/http'
|
|
10
10
|
import type { Params, Response } from 'k6/http'
|
|
11
11
|
export type GetItemById200 = {
|
|
12
|
-
description?: string
|
|
13
12
|
id?: string
|
|
14
13
|
name?: string
|
|
14
|
+
description?: string
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -26,6 +26,8 @@ export class SimpleAPIClient {
|
|
|
26
26
|
commonRequestParameters?: Params
|
|
27
27
|
}) {
|
|
28
28
|
this.cleanBaseUrl = clientOptions.baseUrl.replace(/\/+$/, '')
|
|
29
|
+
|
|
30
|
+
this.commonRequestParameters = clientOptions.commonRequestParameters || {}
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
/**
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { SimpleAPIClient } from './simpleAPI.ts'
|
|
2
2
|
|
|
3
3
|
const baseUrl = '<BASE_URL>'
|
|
4
|
-
const
|
|
4
|
+
const simpleAPIClient = new SimpleAPIClient({ baseUrl })
|
|
5
5
|
|
|
6
6
|
export default function () {
|
|
7
|
+
let id
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* Get an item by its ID
|
|
9
11
|
*/
|
|
10
|
-
|
|
12
|
+
id = '12345'
|
|
13
|
+
|
|
14
|
+
const getItemByIdResponseData = simpleAPIClient.getItemById(id)
|
|
11
15
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.1
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Simple API
|
|
5
5
|
* An API with a single GET request that takes a path parameter
|
|
6
6
|
* Service version: 1.0.0
|
|
7
7
|
*/
|
|
8
8
|
export type GetItemById200 = {
|
|
9
|
-
description?: string
|
|
10
9
|
id?: string
|
|
11
10
|
name?: string
|
|
11
|
+
description?: string
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.1
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Simple API
|
|
5
5
|
* An API with a single GET request that takes a path parameter
|
|
@@ -22,6 +22,8 @@ export class SimpleAPIClient {
|
|
|
22
22
|
commonRequestParameters?: Params
|
|
23
23
|
}) {
|
|
24
24
|
this.cleanBaseUrl = clientOptions.baseUrl.replace(/\/+$/, '')
|
|
25
|
+
|
|
26
|
+
this.commonRequestParameters = clientOptions.commonRequestParameters || {}
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.1
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Simple API
|
|
5
5
|
* An API with a single GET request that takes a path parameter
|
|
@@ -22,6 +22,8 @@ export class DefaultClient {
|
|
|
22
22
|
commonRequestParameters?: Params
|
|
23
23
|
}) {
|
|
24
24
|
this.cleanBaseUrl = clientOptions.baseUrl.replace(/\/+$/, '')
|
|
25
|
+
|
|
26
|
+
this.commonRequestParameters = clientOptions.commonRequestParameters || {}
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/**
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DefaultClient } from './default.ts'
|
|
2
2
|
|
|
3
3
|
const baseUrl = '<BASE_URL>'
|
|
4
|
-
const
|
|
4
|
+
const defaultClient = new DefaultClient({ baseUrl })
|
|
5
5
|
|
|
6
6
|
export default function () {
|
|
7
|
+
let id
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* Get an item by its ID
|
|
9
11
|
*/
|
|
10
|
-
|
|
12
|
+
id = '12345'
|
|
13
|
+
|
|
14
|
+
const getItemByIdResponseData = defaultClient.getItemById(id)
|
|
11
15
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.1
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Simple API
|
|
5
5
|
* An API with a single GET request that takes a path parameter
|
|
6
6
|
* Service version: 1.0.0
|
|
7
7
|
*/
|
|
8
8
|
export type GetItemById200 = {
|
|
9
|
-
description?: string
|
|
10
9
|
id?: string
|
|
11
10
|
name?: string
|
|
11
|
+
description?: string
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.1
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Header Demo API
|
|
5
5
|
* An API demonstrating the use of headers in different ways
|
|
@@ -46,6 +46,8 @@ export class HeaderDemoAPIClient {
|
|
|
46
46
|
commonRequestParameters?: Params
|
|
47
47
|
}) {
|
|
48
48
|
this.cleanBaseUrl = clientOptions.baseUrl.replace(/\/+$/, '')
|
|
49
|
+
|
|
50
|
+
this.commonRequestParameters = clientOptions.commonRequestParameters || {}
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
/**
|
|
@@ -67,6 +69,7 @@ export class HeaderDemoAPIClient {
|
|
|
67
69
|
const response = http.request('GET', url.toString(), undefined, {
|
|
68
70
|
...mergedRequestParameters,
|
|
69
71
|
headers: {
|
|
72
|
+
...mergedRequestParameters?.headers,
|
|
70
73
|
// In the schema, headers can be of any type like number but k6 accepts only strings as headers, hence converting all headers to string
|
|
71
74
|
...Object.fromEntries(
|
|
72
75
|
Object.entries(headers || {}).map(([key, value]) => [
|
|
@@ -74,7 +77,6 @@ export class HeaderDemoAPIClient {
|
|
|
74
77
|
String(value),
|
|
75
78
|
])
|
|
76
79
|
),
|
|
77
|
-
...mergedRequestParameters?.headers,
|
|
78
80
|
},
|
|
79
81
|
})
|
|
80
82
|
let data
|
|
@@ -114,6 +116,7 @@ export class HeaderDemoAPIClient {
|
|
|
114
116
|
{
|
|
115
117
|
...mergedRequestParameters,
|
|
116
118
|
headers: {
|
|
119
|
+
...mergedRequestParameters?.headers,
|
|
117
120
|
'Content-Type': 'application/json',
|
|
118
121
|
// In the schema, headers can be of any type like number but k6 accepts only strings as headers, hence converting all headers to string
|
|
119
122
|
...Object.fromEntries(
|
|
@@ -122,7 +125,6 @@ export class HeaderDemoAPIClient {
|
|
|
122
125
|
String(value),
|
|
123
126
|
])
|
|
124
127
|
),
|
|
125
|
-
...mergedRequestParameters?.headers,
|
|
126
128
|
},
|
|
127
129
|
}
|
|
128
130
|
)
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import { HeaderDemoAPIClient } from './headerDemoAPI.ts'
|
|
2
2
|
|
|
3
3
|
const baseUrl = '<BASE_URL>'
|
|
4
|
-
const
|
|
4
|
+
const headerDemoAPIClient = new HeaderDemoAPIClient({ baseUrl })
|
|
5
5
|
|
|
6
6
|
export default function () {
|
|
7
|
+
let postExamplePostBody, headers
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* GET request with headers
|
|
9
11
|
*/
|
|
10
|
-
|
|
12
|
+
|
|
13
|
+
const getExampleGetResponseData = headerDemoAPIClient.getExampleGet()
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* POST request with security headers
|
|
14
17
|
*/
|
|
15
|
-
|
|
18
|
+
postExamplePostBody = {
|
|
19
|
+
data: 'redevelop',
|
|
20
|
+
}
|
|
21
|
+
headers = {
|
|
22
|
+
Authorization: 'Bearer <token>',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const postExamplePostResponseData = headerDemoAPIClient.postExamplePost(
|
|
16
26
|
postExamplePostBody,
|
|
17
27
|
headers
|
|
18
28
|
)
|
|
@@ -20,6 +30,7 @@ export default function () {
|
|
|
20
30
|
/**
|
|
21
31
|
* GET request with response headers only
|
|
22
32
|
*/
|
|
33
|
+
|
|
23
34
|
const getExampleResponseHeadersResponseData =
|
|
24
|
-
|
|
35
|
+
headerDemoAPIClient.getExampleResponseHeaders()
|
|
25
36
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.1
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Header Demo API
|
|
5
5
|
* An API demonstrating the use of headers in different ways
|
|
@@ -28,6 +28,8 @@ export class HeaderDemoAPIClient {
|
|
|
28
28
|
commonRequestParameters?: Params
|
|
29
29
|
}) {
|
|
30
30
|
this.cleanBaseUrl = clientOptions.baseUrl.replace(/\/+$/, '')
|
|
31
|
+
|
|
32
|
+
this.commonRequestParameters = clientOptions.commonRequestParameters || {}
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
/**
|
|
@@ -49,6 +51,7 @@ export class HeaderDemoAPIClient {
|
|
|
49
51
|
const response = http.request('GET', url.toString(), undefined, {
|
|
50
52
|
...mergedRequestParameters,
|
|
51
53
|
headers: {
|
|
54
|
+
...mergedRequestParameters?.headers,
|
|
52
55
|
// In the schema, headers can be of any type like number but k6 accepts only strings as headers, hence converting all headers to string
|
|
53
56
|
...Object.fromEntries(
|
|
54
57
|
Object.entries(headers || {}).map(([key, value]) => [
|
|
@@ -56,7 +59,6 @@ export class HeaderDemoAPIClient {
|
|
|
56
59
|
String(value),
|
|
57
60
|
])
|
|
58
61
|
),
|
|
59
|
-
...mergedRequestParameters?.headers,
|
|
60
62
|
},
|
|
61
63
|
})
|
|
62
64
|
let data
|
|
@@ -96,6 +98,7 @@ export class HeaderDemoAPIClient {
|
|
|
96
98
|
{
|
|
97
99
|
...mergedRequestParameters,
|
|
98
100
|
headers: {
|
|
101
|
+
...mergedRequestParameters?.headers,
|
|
99
102
|
'Content-Type': 'application/json',
|
|
100
103
|
// In the schema, headers can be of any type like number but k6 accepts only strings as headers, hence converting all headers to string
|
|
101
104
|
...Object.fromEntries(
|
|
@@ -104,7 +107,6 @@ export class HeaderDemoAPIClient {
|
|
|
104
107
|
String(value),
|
|
105
108
|
])
|
|
106
109
|
),
|
|
107
|
-
...mergedRequestParameters?.headers,
|
|
108
110
|
},
|
|
109
111
|
}
|
|
110
112
|
)
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import { HeaderDemoAPIClient } from './headerDemoAPI.ts'
|
|
2
2
|
|
|
3
3
|
const baseUrl = '<BASE_URL>'
|
|
4
|
-
const
|
|
4
|
+
const headerDemoAPIClient = new HeaderDemoAPIClient({ baseUrl })
|
|
5
5
|
|
|
6
6
|
export default function () {
|
|
7
|
+
let postExamplePostBody, headers
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* GET request with headers
|
|
9
11
|
*/
|
|
10
|
-
|
|
12
|
+
|
|
13
|
+
const getExampleGetResponseData = headerDemoAPIClient.getExampleGet()
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* POST request with security headers
|
|
14
17
|
*/
|
|
15
|
-
|
|
18
|
+
postExamplePostBody = {
|
|
19
|
+
data: 'redevelop',
|
|
20
|
+
}
|
|
21
|
+
headers = {
|
|
22
|
+
Authorization: 'Bearer <token>',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const postExamplePostResponseData = headerDemoAPIClient.postExamplePost(
|
|
16
26
|
postExamplePostBody,
|
|
17
27
|
headers
|
|
18
28
|
)
|
|
@@ -20,6 +30,7 @@ export default function () {
|
|
|
20
30
|
/**
|
|
21
31
|
* GET request with response headers only
|
|
22
32
|
*/
|
|
33
|
+
|
|
23
34
|
const getExampleResponseHeadersResponseData =
|
|
24
|
-
|
|
35
|
+
headerDemoAPIClient.getExampleResponseHeaders()
|
|
25
36
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.1
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Header Demo API
|
|
5
5
|
* An API demonstrating the use of headers in different ways
|
|
@@ -28,6 +28,8 @@ export class DefaultClient {
|
|
|
28
28
|
commonRequestParameters?: Params
|
|
29
29
|
}) {
|
|
30
30
|
this.cleanBaseUrl = clientOptions.baseUrl.replace(/\/+$/, '')
|
|
31
|
+
|
|
32
|
+
this.commonRequestParameters = clientOptions.commonRequestParameters || {}
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
/**
|
|
@@ -49,6 +51,7 @@ export class DefaultClient {
|
|
|
49
51
|
const response = http.request('GET', url.toString(), undefined, {
|
|
50
52
|
...mergedRequestParameters,
|
|
51
53
|
headers: {
|
|
54
|
+
...mergedRequestParameters?.headers,
|
|
52
55
|
// In the schema, headers can be of any type like number but k6 accepts only strings as headers, hence converting all headers to string
|
|
53
56
|
...Object.fromEntries(
|
|
54
57
|
Object.entries(headers || {}).map(([key, value]) => [
|
|
@@ -56,7 +59,6 @@ export class DefaultClient {
|
|
|
56
59
|
String(value),
|
|
57
60
|
])
|
|
58
61
|
),
|
|
59
|
-
...mergedRequestParameters?.headers,
|
|
60
62
|
},
|
|
61
63
|
})
|
|
62
64
|
let data
|
|
@@ -95,6 +97,7 @@ export class DefaultClient {
|
|
|
95
97
|
{
|
|
96
98
|
...mergedRequestParameters,
|
|
97
99
|
headers: {
|
|
100
|
+
...mergedRequestParameters?.headers,
|
|
98
101
|
'Content-Type': 'application/json',
|
|
99
102
|
// In the schema, headers can be of any type like number but k6 accepts only strings as headers, hence converting all headers to string
|
|
100
103
|
...Object.fromEntries(
|
|
@@ -103,7 +106,6 @@ export class DefaultClient {
|
|
|
103
106
|
String(value),
|
|
104
107
|
])
|
|
105
108
|
),
|
|
106
|
-
...mergedRequestParameters?.headers,
|
|
107
109
|
},
|
|
108
110
|
}
|
|
109
111
|
)
|
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DefaultClient } from './default.ts'
|
|
2
2
|
|
|
3
3
|
const baseUrl = '<BASE_URL>'
|
|
4
|
-
const
|
|
4
|
+
const defaultClient = new DefaultClient({ baseUrl })
|
|
5
5
|
|
|
6
6
|
export default function () {
|
|
7
|
+
let postExamplePostBody, headers
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* GET request with headers
|
|
9
11
|
*/
|
|
10
|
-
|
|
12
|
+
|
|
13
|
+
const getExampleGetResponseData = defaultClient.getExampleGet()
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* POST request with security headers
|
|
14
17
|
*/
|
|
15
|
-
|
|
18
|
+
postExamplePostBody = {
|
|
19
|
+
data: 'redevelop',
|
|
20
|
+
}
|
|
21
|
+
headers = {
|
|
22
|
+
Authorization: 'Bearer <token>',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const postExamplePostResponseData = defaultClient.postExamplePost(
|
|
16
26
|
postExamplePostBody,
|
|
17
27
|
headers
|
|
18
28
|
)
|
|
@@ -20,6 +30,7 @@ export default function () {
|
|
|
20
30
|
/**
|
|
21
31
|
* GET request with response headers only
|
|
22
32
|
*/
|
|
33
|
+
|
|
23
34
|
const getExampleResponseHeadersResponseData =
|
|
24
|
-
|
|
35
|
+
defaultClient.getExampleResponseHeaders()
|
|
25
36
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { K6ClientClient } from './k6Client.ts'
|
|
2
2
|
|
|
3
3
|
const baseUrl = '<BASE_URL>'
|
|
4
|
-
const
|
|
4
|
+
const k6ClientClient = new K6ClientClient({ baseUrl })
|
|
5
5
|
|
|
6
6
|
export default function () {
|
|
7
7
|
/**
|
|
8
8
|
* Retrieve example data
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
const getExampleResponseData = k6ClientClient.getExample()
|
|
11
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.1
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* K6Client
|
|
5
5
|
* Service version: 1.0.0
|
|
@@ -23,6 +23,8 @@ export class K6ClientClient {
|
|
|
23
23
|
commonRequestParameters?: Params
|
|
24
24
|
}) {
|
|
25
25
|
this.cleanBaseUrl = clientOptions.baseUrl.replace(/\/+$/, '')
|
|
26
|
+
|
|
27
|
+
this.commonRequestParameters = clientOptions.commonRequestParameters || {}
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
/**
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { K6ClientClient } from './k6Client.ts'
|
|
2
2
|
|
|
3
3
|
const baseUrl = '<BASE_URL>'
|
|
4
|
-
const
|
|
4
|
+
const k6ClientClient = new K6ClientClient({ baseUrl })
|
|
5
5
|
|
|
6
6
|
export default function () {
|
|
7
7
|
/**
|
|
8
8
|
* Retrieve example data
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
const getExampleResponseData = k6ClientClient.getExample()
|
|
11
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.1
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* K6Client
|
|
5
5
|
* Service version: 1.0.0
|
|
@@ -21,6 +21,8 @@ export class K6ClientClient {
|
|
|
21
21
|
commonRequestParameters?: Params
|
|
22
22
|
}) {
|
|
23
23
|
this.cleanBaseUrl = clientOptions.baseUrl.replace(/\/+$/, '')
|
|
24
|
+
|
|
25
|
+
this.commonRequestParameters = clientOptions.commonRequestParameters || {}
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.1
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* K6Client
|
|
5
5
|
* Service version: 1.0.0
|
|
@@ -21,6 +21,8 @@ export class DefaultClient {
|
|
|
21
21
|
commonRequestParameters?: Params
|
|
22
22
|
}) {
|
|
23
23
|
this.cleanBaseUrl = clientOptions.baseUrl.replace(/\/+$/, '')
|
|
24
|
+
|
|
25
|
+
this.commonRequestParameters = clientOptions.commonRequestParameters || {}
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
/**
|