@grafana/openapi-to-k6 0.3.0 → 0.3.2
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/dist/generator/index.js +13 -6
- package/dist/generator/k6Client.js +3 -1
- package/dist/helper.js +16 -0
- package/examples/basic_schema/schema.json +2 -1
- package/examples/basic_schema/single/simpleAPI.ts +4 -1
- 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/simpleAPI.schemas.ts +2 -1
- package/examples/form_data_schema/single/formDataAPI.ts +15 -13
- package/examples/form_data_schema/split/formDataAPI.schemas.ts +12 -12
- package/examples/form_data_schema/split/formDataAPI.ts +4 -2
- package/examples/form_data_schema/tags/default.ts +4 -2
- package/examples/form_data_schema/tags/formDataAPI.schemas.ts +12 -12
- package/examples/form_url_encoded_data_schema/single/formURLEncodedAPI.ts +15 -13
- package/examples/form_url_encoded_data_schema/split/formURLEncodedAPI.schemas.ts +12 -12
- package/examples/form_url_encoded_data_schema/split/formURLEncodedAPI.ts +4 -2
- package/examples/form_url_encoded_data_schema/tags/default.ts +4 -2
- package/examples/form_url_encoded_data_schema/tags/formURLEncodedAPI.schemas.ts +12 -12
- package/examples/form_url_encoded_data_with_query_params_schema/single/formURLEncodedAPIWithQueryParameters.ts +23 -21
- package/examples/form_url_encoded_data_with_query_params_schema/split/formURLEncodedAPIWithQueryParameters.schemas.ts +20 -20
- 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/tags/default.ts +4 -2
- package/examples/form_url_encoded_data_with_query_params_schema/tags/formURLEncodedAPIWithQueryParameters.schemas.ts +20 -20
- package/examples/get_request_with_path_parameters_schema/single/simpleAPI.ts +4 -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/simpleAPI.schemas.ts +2 -2
- package/examples/headers_schema/single/headerDemoAPI.ts +16 -14
- package/examples/headers_schema/split/headerDemoAPI.schemas.ts +12 -12
- package/examples/headers_schema/split/headerDemoAPI.ts +5 -3
- package/examples/headers_schema/tags/default.ts +5 -3
- package/examples/headers_schema/tags/headerDemoAPI.schemas.ts +12 -12
- package/examples/no_title_schema/single/k6Client.ts +3 -1
- 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/k6Client.schemas.ts +1 -1
- package/examples/post_request_with_query_params/single/exampleAPI.ts +20 -18
- package/examples/post_request_with_query_params/split/exampleAPI.schemas.ts +17 -17
- package/examples/post_request_with_query_params/split/exampleAPI.ts +4 -2
- package/examples/post_request_with_query_params/tags/default.ts +4 -2
- package/examples/post_request_with_query_params/tags/exampleAPI.schemas.ts +17 -17
- package/examples/query_params_schema/single/exampleAPI.ts +11 -9
- package/examples/query_params_schema/split/exampleAPI.schemas.ts +9 -9
- package/examples/query_params_schema/split/exampleAPI.ts +3 -1
- package/examples/query_params_schema/tags/default.ts +3 -1
- package/examples/query_params_schema/tags/exampleAPI.schemas.ts +9 -9
- package/examples/simple_post_request_schema/single/exampleAPI.ts +25 -23
- package/examples/simple_post_request_schema/split/exampleAPI.schemas.ts +22 -22
- package/examples/simple_post_request_schema/split/exampleAPI.ts +4 -2
- package/examples/simple_post_request_schema/tags/default.ts +4 -2
- package/examples/simple_post_request_schema/tags/exampleAPI.schemas.ts +22 -22
- package/package.json +3 -2
- package/src/generator/index.ts +20 -7
- package/src/generator/k6Client.ts +3 -1
- package/src/helper.ts +17 -0
- package/tests/e2e/single/k6Script.ts +54 -1
- package/tests/functional-tests/test-generator/fixtures/basic_parameter_in_ref.json +59 -0
- package/tests/functional-tests/test-generator/fixtures/form_data_schema.json +1 -1
- package/tests/functional-tests/test-generator/fixtures/form_url_encoded_data_schema.json +1 -1
- package/tests/functional-tests/test-generator/fixtures/headers_schema.json +2 -2
- package/tests/functional-tests/test-generator/fixtures/simple_post_request_schema.json +1 -1
- package/{vite.config.js → vite.config.mjs} +4 -0
|
@@ -1,28 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
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
|
-
export type PostSubmitForm400 = {
|
|
8
|
-
error?: string
|
|
9
|
-
success?: boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type PostSubmitForm200 = {
|
|
13
|
-
message?: string
|
|
14
|
-
success?: boolean
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type PostSubmitFormBody = {
|
|
18
|
-
/** Age of the user */
|
|
19
|
-
age?: number
|
|
20
|
-
/** Email address of the user */
|
|
21
|
-
email: string
|
|
22
|
-
/** Name of the user */
|
|
23
|
-
name: string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
7
|
export type PostSubmitFormParams = {
|
|
27
8
|
/**
|
|
28
9
|
* Authentication token
|
|
@@ -33,3 +14,22 @@ export type PostSubmitFormParams = {
|
|
|
33
14
|
*/
|
|
34
15
|
locale?: string
|
|
35
16
|
}
|
|
17
|
+
|
|
18
|
+
export type PostSubmitFormBody = {
|
|
19
|
+
/** Name of the user */
|
|
20
|
+
name: string
|
|
21
|
+
/** Age of the user */
|
|
22
|
+
age?: number
|
|
23
|
+
/** Email address of the user */
|
|
24
|
+
email: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type PostSubmitForm200 = {
|
|
28
|
+
success?: boolean
|
|
29
|
+
message?: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type PostSubmitForm400 = {
|
|
33
|
+
success?: boolean
|
|
34
|
+
error?: string
|
|
35
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
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 FormURLEncodedAPIWithQueryParametersClient {
|
|
|
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 FormURLEncodedAPIWithQueryParametersClient {
|
|
|
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,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
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,28 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
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
|
-
export type PostSubmitForm400 = {
|
|
8
|
-
error?: string
|
|
9
|
-
success?: boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type PostSubmitForm200 = {
|
|
13
|
-
message?: string
|
|
14
|
-
success?: boolean
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type PostSubmitFormBody = {
|
|
18
|
-
/** Age of the user */
|
|
19
|
-
age?: number
|
|
20
|
-
/** Email address of the user */
|
|
21
|
-
email: string
|
|
22
|
-
/** Name of the user */
|
|
23
|
-
name: string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
7
|
export type PostSubmitFormParams = {
|
|
27
8
|
/**
|
|
28
9
|
* Authentication token
|
|
@@ -33,3 +14,22 @@ export type PostSubmitFormParams = {
|
|
|
33
14
|
*/
|
|
34
15
|
locale?: string
|
|
35
16
|
}
|
|
17
|
+
|
|
18
|
+
export type PostSubmitFormBody = {
|
|
19
|
+
/** Name of the user */
|
|
20
|
+
name: string
|
|
21
|
+
/** Age of the user */
|
|
22
|
+
age?: number
|
|
23
|
+
/** Email address of the user */
|
|
24
|
+
email: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type PostSubmitForm200 = {
|
|
28
|
+
success?: boolean
|
|
29
|
+
message?: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type PostSubmitForm400 = {
|
|
33
|
+
success?: boolean
|
|
34
|
+
error?: string
|
|
35
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
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,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
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.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
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.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
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,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
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.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Header Demo API
|
|
5
5
|
* An API demonstrating the use of headers in different ways
|
|
@@ -8,12 +8,15 @@
|
|
|
8
8
|
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
|
-
export type
|
|
12
|
-
|
|
11
|
+
export type GetExampleGetHeaders = {
|
|
12
|
+
/**
|
|
13
|
+
* A custom header for this request
|
|
14
|
+
*/
|
|
15
|
+
'X-Custom-Header'?: string
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
export type
|
|
16
|
-
|
|
18
|
+
export type GetExampleGet200 = {
|
|
19
|
+
message?: string
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
export type PostExamplePostHeaders = {
|
|
@@ -23,15 +26,12 @@ export type PostExamplePostHeaders = {
|
|
|
23
26
|
Authorization: string
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
export type
|
|
27
|
-
|
|
29
|
+
export type PostExamplePostBody = {
|
|
30
|
+
data?: string
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
export type
|
|
31
|
-
|
|
32
|
-
* A custom header for this request
|
|
33
|
-
*/
|
|
34
|
-
'X-Custom-Header'?: string
|
|
33
|
+
export type GetExampleResponseHeaders200 = {
|
|
34
|
+
status?: string
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -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,16 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Header Demo API
|
|
5
5
|
* An API demonstrating the use of headers in different ways
|
|
6
6
|
* Service version: 1.0.0
|
|
7
7
|
*/
|
|
8
|
-
export type
|
|
9
|
-
|
|
8
|
+
export type GetExampleGetHeaders = {
|
|
9
|
+
/**
|
|
10
|
+
* A custom header for this request
|
|
11
|
+
*/
|
|
12
|
+
'X-Custom-Header'?: string
|
|
10
13
|
}
|
|
11
14
|
|
|
12
|
-
export type
|
|
13
|
-
|
|
15
|
+
export type GetExampleGet200 = {
|
|
16
|
+
message?: string
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
export type PostExamplePostHeaders = {
|
|
@@ -20,13 +23,10 @@ export type PostExamplePostHeaders = {
|
|
|
20
23
|
Authorization: string
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
export type
|
|
24
|
-
|
|
26
|
+
export type PostExamplePostBody = {
|
|
27
|
+
data?: string
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
export type
|
|
28
|
-
|
|
29
|
-
* A custom header for this request
|
|
30
|
-
*/
|
|
31
|
-
'X-Custom-Header'?: string
|
|
30
|
+
export type GetExampleResponseHeaders200 = {
|
|
31
|
+
status?: string
|
|
32
32
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
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,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
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,16 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Header Demo API
|
|
5
5
|
* An API demonstrating the use of headers in different ways
|
|
6
6
|
* Service version: 1.0.0
|
|
7
7
|
*/
|
|
8
|
-
export type
|
|
9
|
-
|
|
8
|
+
export type GetExampleGetHeaders = {
|
|
9
|
+
/**
|
|
10
|
+
* A custom header for this request
|
|
11
|
+
*/
|
|
12
|
+
'X-Custom-Header'?: string
|
|
10
13
|
}
|
|
11
14
|
|
|
12
|
-
export type
|
|
13
|
-
|
|
15
|
+
export type GetExampleGet200 = {
|
|
16
|
+
message?: string
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
export type PostExamplePostHeaders = {
|
|
@@ -20,13 +23,10 @@ export type PostExamplePostHeaders = {
|
|
|
20
23
|
Authorization: string
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
export type
|
|
24
|
-
|
|
26
|
+
export type PostExamplePostBody = {
|
|
27
|
+
data?: string
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
export type
|
|
28
|
-
|
|
29
|
-
* A custom header for this request
|
|
30
|
-
*/
|
|
31
|
-
'X-Custom-Header'?: string
|
|
30
|
+
export type GetExampleResponseHeaders200 = {
|
|
31
|
+
status?: string
|
|
32
32
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
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,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
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.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
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
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Automatically generated by @grafana/openapi-to-k6: 0.3.
|
|
2
|
+
* Automatically generated by @grafana/openapi-to-k6: 0.3.2
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Example API
|
|
5
5
|
* API with a POST request having an object as the body and query parameters
|
|
@@ -8,22 +8,6 @@
|
|
|
8
8
|
import { URL, URLSearchParams } 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
|
-
export type CreateExampleData201 = {
|
|
12
|
-
/** The data from the body */
|
|
13
|
-
data?: string
|
|
14
|
-
/** The active status from the query parameter */
|
|
15
|
-
isActive?: boolean
|
|
16
|
-
/** Response status */
|
|
17
|
-
status?: string
|
|
18
|
-
/** The user ID from the query parameter */
|
|
19
|
-
userId?: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type CreateExampleDataBody = {
|
|
23
|
-
/** A string field representing data */
|
|
24
|
-
data: string
|
|
25
|
-
}
|
|
26
|
-
|
|
27
11
|
export type CreateExampleDataParams = {
|
|
28
12
|
/**
|
|
29
13
|
* A string query parameter for user ID
|
|
@@ -35,6 +19,22 @@ export type CreateExampleDataParams = {
|
|
|
35
19
|
isActive?: boolean
|
|
36
20
|
}
|
|
37
21
|
|
|
22
|
+
export type CreateExampleDataBody = {
|
|
23
|
+
/** A string field representing data */
|
|
24
|
+
data: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type CreateExampleData201 = {
|
|
28
|
+
/** The user ID from the query parameter */
|
|
29
|
+
userId?: string
|
|
30
|
+
/** The active status from the query parameter */
|
|
31
|
+
isActive?: boolean
|
|
32
|
+
/** The data from the body */
|
|
33
|
+
data?: string
|
|
34
|
+
/** Response status */
|
|
35
|
+
status?: string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
38
|
/**
|
|
39
39
|
* This is the base client to use for interacting with the API.
|
|
40
40
|
*/
|
|
@@ -47,6 +47,8 @@ export class ExampleAPIClient {
|
|
|
47
47
|
commonRequestParameters?: Params
|
|
48
48
|
}) {
|
|
49
49
|
this.cleanBaseUrl = clientOptions.baseUrl.replace(/\/+$/, '')
|
|
50
|
+
|
|
51
|
+
this.commonRequestParameters = clientOptions.commonRequestParameters || {}
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
/**
|
|
@@ -77,8 +79,8 @@ export class ExampleAPIClient {
|
|
|
77
79
|
{
|
|
78
80
|
...mergedRequestParameters,
|
|
79
81
|
headers: {
|
|
80
|
-
'Content-Type': 'application/json',
|
|
81
82
|
...mergedRequestParameters?.headers,
|
|
83
|
+
'Content-Type': 'application/json',
|
|
82
84
|
},
|
|
83
85
|
}
|
|
84
86
|
)
|