@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.
Files changed (124) hide show
  1. package/README.md +5 -1
  2. package/dist/constants.js +7 -3
  3. package/dist/generator/index.js +13 -6
  4. package/dist/generator/k6Client.js +8 -56
  5. package/dist/generator/k6ScriptBuilder.js +256 -0
  6. package/dist/helper.js +16 -0
  7. package/examples/basic_schema/schema.json +2 -1
  8. package/examples/basic_schema/single/k6-script.sample.ts +3 -2
  9. package/examples/basic_schema/single/simpleAPI.ts +4 -1
  10. package/examples/basic_schema/split/k6-script.sample.ts +3 -2
  11. package/examples/basic_schema/split/simpleAPI.schemas.ts +2 -1
  12. package/examples/basic_schema/split/simpleAPI.ts +3 -1
  13. package/examples/basic_schema/tags/default.ts +3 -1
  14. package/examples/basic_schema/tags/k6-script.sample.ts +4 -3
  15. package/examples/basic_schema/tags/simpleAPI.schemas.ts +2 -1
  16. package/examples/form_data_schema/schema.json +6 -3
  17. package/examples/form_data_schema/single/formDataAPI.ts +8 -6
  18. package/examples/form_data_schema/single/k6-script.sample.ts +10 -2
  19. package/examples/form_data_schema/split/formDataAPI.schemas.ts +5 -5
  20. package/examples/form_data_schema/split/formDataAPI.ts +4 -2
  21. package/examples/form_data_schema/split/k6-script.sample.ts +10 -2
  22. package/examples/form_data_schema/tags/default.ts +4 -2
  23. package/examples/form_data_schema/tags/formDataAPI.schemas.ts +5 -5
  24. package/examples/form_data_schema/tags/k6-script.sample.ts +11 -3
  25. package/examples/form_url_encoded_data_schema/schema.json +6 -3
  26. package/examples/form_url_encoded_data_schema/single/formURLEncodedAPI.ts +8 -6
  27. package/examples/form_url_encoded_data_schema/single/k6-script.sample.ts +11 -2
  28. package/examples/form_url_encoded_data_schema/split/formURLEncodedAPI.schemas.ts +5 -5
  29. package/examples/form_url_encoded_data_schema/split/formURLEncodedAPI.ts +4 -2
  30. package/examples/form_url_encoded_data_schema/split/k6-script.sample.ts +11 -2
  31. package/examples/form_url_encoded_data_schema/tags/default.ts +4 -2
  32. package/examples/form_url_encoded_data_schema/tags/formURLEncodedAPI.schemas.ts +5 -5
  33. package/examples/form_url_encoded_data_schema/tags/k6-script.sample.ts +12 -3
  34. package/examples/form_url_encoded_data_with_query_params_schema/schema.json +8 -4
  35. package/examples/form_url_encoded_data_with_query_params_schema/single/formURLEncodedAPIWithQueryParameters.ts +8 -6
  36. package/examples/form_url_encoded_data_with_query_params_schema/single/k6-script.sample.ts +19 -6
  37. package/examples/form_url_encoded_data_with_query_params_schema/split/formURLEncodedAPIWithQueryParameters.schemas.ts +5 -5
  38. package/examples/form_url_encoded_data_with_query_params_schema/split/formURLEncodedAPIWithQueryParameters.ts +4 -2
  39. package/examples/form_url_encoded_data_with_query_params_schema/split/k6-script.sample.ts +19 -6
  40. package/examples/form_url_encoded_data_with_query_params_schema/tags/default.ts +4 -2
  41. package/examples/form_url_encoded_data_with_query_params_schema/tags/formURLEncodedAPIWithQueryParameters.schemas.ts +5 -5
  42. package/examples/form_url_encoded_data_with_query_params_schema/tags/k6-script.sample.ts +14 -3
  43. package/examples/get_request_with_path_parameters_schema/schema.json +2 -1
  44. package/examples/get_request_with_path_parameters_schema/single/k6-script.sample.ts +6 -2
  45. package/examples/get_request_with_path_parameters_schema/single/simpleAPI.ts +4 -2
  46. package/examples/get_request_with_path_parameters_schema/split/k6-script.sample.ts +6 -2
  47. package/examples/get_request_with_path_parameters_schema/split/simpleAPI.schemas.ts +2 -2
  48. package/examples/get_request_with_path_parameters_schema/split/simpleAPI.ts +3 -1
  49. package/examples/get_request_with_path_parameters_schema/tags/default.ts +3 -1
  50. package/examples/get_request_with_path_parameters_schema/tags/k6-script.sample.ts +7 -3
  51. package/examples/get_request_with_path_parameters_schema/tags/simpleAPI.schemas.ts +2 -2
  52. package/examples/headers_schema/schema.json +2 -1
  53. package/examples/headers_schema/single/headerDemoAPI.ts +5 -3
  54. package/examples/headers_schema/single/k6-script.sample.ts +15 -4
  55. package/examples/headers_schema/split/headerDemoAPI.schemas.ts +1 -1
  56. package/examples/headers_schema/split/headerDemoAPI.ts +5 -3
  57. package/examples/headers_schema/split/k6-script.sample.ts +15 -4
  58. package/examples/headers_schema/tags/default.ts +5 -3
  59. package/examples/headers_schema/tags/headerDemoAPI.schemas.ts +1 -1
  60. package/examples/headers_schema/tags/k6-script.sample.ts +16 -5
  61. package/examples/no_title_schema/single/k6-script.sample.ts +3 -2
  62. package/examples/no_title_schema/single/k6Client.ts +3 -1
  63. package/examples/no_title_schema/split/k6-script.sample.ts +3 -2
  64. package/examples/no_title_schema/split/k6Client.schemas.ts +1 -1
  65. package/examples/no_title_schema/split/k6Client.ts +3 -1
  66. package/examples/no_title_schema/tags/default.ts +3 -1
  67. package/examples/no_title_schema/tags/k6-script.sample.ts +4 -3
  68. package/examples/no_title_schema/tags/k6Client.schemas.ts +1 -1
  69. package/examples/post_request_with_query_params/schema.json +14 -7
  70. package/examples/post_request_with_query_params/single/exampleAPI.ts +8 -6
  71. package/examples/post_request_with_query_params/single/k6-script.sample.ts +11 -2
  72. package/examples/post_request_with_query_params/split/exampleAPI.schemas.ts +5 -5
  73. package/examples/post_request_with_query_params/split/exampleAPI.ts +4 -2
  74. package/examples/post_request_with_query_params/split/k6-script.sample.ts +11 -2
  75. package/examples/post_request_with_query_params/tags/default.ts +4 -2
  76. package/examples/post_request_with_query_params/tags/exampleAPI.schemas.ts +5 -5
  77. package/examples/post_request_with_query_params/tags/k6-script.sample.ts +12 -3
  78. package/examples/query_params_schema/schema.json +20 -10
  79. package/examples/query_params_schema/single/exampleAPI.ts +5 -3
  80. package/examples/query_params_schema/single/k6-script.sample.ts +8 -2
  81. package/examples/query_params_schema/split/exampleAPI.schemas.ts +3 -3
  82. package/examples/query_params_schema/split/exampleAPI.ts +3 -1
  83. package/examples/query_params_schema/split/k6-script.sample.ts +8 -2
  84. package/examples/query_params_schema/tags/default.ts +3 -1
  85. package/examples/query_params_schema/tags/exampleAPI.schemas.ts +3 -3
  86. package/examples/query_params_schema/tags/k6-script.sample.ts +9 -3
  87. package/examples/simple_post_request_schema/schema.json +30 -15
  88. package/examples/simple_post_request_schema/single/exampleAPI.ts +14 -12
  89. package/examples/simple_post_request_schema/single/k6-script.sample.ts +16 -2
  90. package/examples/simple_post_request_schema/split/exampleAPI.schemas.ts +11 -11
  91. package/examples/simple_post_request_schema/split/exampleAPI.ts +4 -2
  92. package/examples/simple_post_request_schema/split/k6-script.sample.ts +16 -2
  93. package/examples/simple_post_request_schema/tags/default.ts +4 -2
  94. package/examples/simple_post_request_schema/tags/exampleAPI.schemas.ts +11 -11
  95. package/examples/simple_post_request_schema/tags/k6-script.sample.ts +17 -3
  96. package/package.json +5 -2
  97. package/src/constants.ts +7 -3
  98. package/src/generator/index.ts +20 -7
  99. package/src/generator/k6Client.ts +6 -73
  100. package/src/generator/k6ScriptBuilder.ts +328 -0
  101. package/src/helper.ts +17 -0
  102. package/tests/e2e/schema.json +135 -18
  103. package/tests/e2e/single/k6Script.ts +54 -1
  104. package/tests/functional-tests/helper.ts +16 -0
  105. package/tests/functional-tests/test-generator/fixtures/basic_parameter_in_ref.json +59 -0
  106. package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/form_data_schema.json +1 -1
  107. package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/form_url_encoded_data_schema.json +1 -1
  108. package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/headers_schema.json +2 -2
  109. package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/simple_post_request_schema.json +1 -1
  110. package/tests/functional-tests/test-generator/generator.test.ts +154 -0
  111. package/tests/functional-tests/test-sample-k6-scripts/fixtures/schema_using_ref_models.json +394 -0
  112. package/tests/functional-tests/test-sample-k6-scripts/fixtures/schema_with_examples.json +416 -0
  113. package/tests/functional-tests/test-sample-k6-scripts/fixtures/schema_with_no_variables.json +32 -0
  114. package/tests/functional-tests/test-sample-k6-scripts/sampleK6Scripts.test.ts +248 -0
  115. package/tests/functional-tests/test-tags-filtering/tagsFiltering.test.ts +166 -0
  116. package/{vite.config.js → vite.config.mjs} +4 -0
  117. package/tests/functional-tests/generator.test.ts +0 -319
  118. /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/basic_schema.json +0 -0
  119. /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/form_url_encoded_data_with_query_params_schema.json +0 -0
  120. /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/get_request_with_path_parameters_schema.json +0 -0
  121. /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/no_title_schema.json +0 -0
  122. /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/post_request_with_query_params.json +0 -0
  123. /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/query_params_schema.json +0 -0
  124. /package/tests/functional-tests/{fixtures → test-tags-filtering/fixtures}/tags_filtering.json +0 -0
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Automatically generated by @grafana/openapi-to-k6: 0.2.6
2
+ * Automatically generated by @grafana/openapi-to-k6: 0.3.1
3
3
  * Do not edit manually.
4
4
  * Form Data API
5
5
  * Service version: 1.0.0
@@ -9,20 +9,20 @@ 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 PostUpload400 = {
12
- error?: string
13
12
  success?: boolean
13
+ error?: string
14
14
  }
15
15
 
16
16
  export type PostUpload200 = {
17
- message?: string
18
17
  success?: boolean
18
+ message?: string
19
19
  }
20
20
 
21
21
  export type PostUploadBody = {
22
- /** Description of the file */
23
- description?: string
24
22
  /** File to upload */
25
23
  file: Blob
24
+ /** Description of the file */
25
+ description?: string
26
26
  /** User ID associated with the upload */
27
27
  userId: string
28
28
  }
@@ -39,6 +39,8 @@ export class FormDataAPIClient {
39
39
  commonRequestParameters?: Params
40
40
  }) {
41
41
  this.cleanBaseUrl = clientOptions.baseUrl.replace(/\/+$/, '')
42
+
43
+ this.commonRequestParameters = clientOptions.commonRequestParameters || {}
42
44
  }
43
45
 
44
46
  /**
@@ -67,8 +69,8 @@ export class FormDataAPIClient {
67
69
  const response = http.request('POST', url.toString(), formData.body(), {
68
70
  ...mergedRequestParameters,
69
71
  headers: {
70
- 'Content-Type': 'multipart/form-data; boundary=' + formData.boundary,
71
72
  ...mergedRequestParameters?.headers,
73
+ 'Content-Type': 'multipart/form-data; boundary=' + formData.boundary,
72
74
  },
73
75
  })
74
76
  let data
@@ -1,11 +1,19 @@
1
1
  import { FormDataAPIClient } from './formDataAPI.ts'
2
2
 
3
3
  const baseUrl = '<BASE_URL>'
4
- const client = new FormDataAPIClient({ baseUrl })
4
+ const formDataAPIClient = new FormDataAPIClient({ baseUrl })
5
5
 
6
6
  export default function () {
7
+ let postUploadBody
8
+
7
9
  /**
8
10
  * Upload files and data
9
11
  */
10
- const postUploadResponseData = client.postUpload(postUploadBody)
12
+ postUploadBody = {
13
+ file: 'example.pdf',
14
+ description: 'Monthly report document',
15
+ userId: 'user123',
16
+ }
17
+
18
+ const postUploadResponseData = formDataAPIClient.postUpload(postUploadBody)
11
19
  }
@@ -1,24 +1,24 @@
1
1
  /**
2
- * Automatically generated by @grafana/openapi-to-k6: 0.2.6
2
+ * Automatically generated by @grafana/openapi-to-k6: 0.3.1
3
3
  * Do not edit manually.
4
4
  * Form Data API
5
5
  * Service version: 1.0.0
6
6
  */
7
7
  export type PostUpload400 = {
8
- error?: string
9
8
  success?: boolean
9
+ error?: string
10
10
  }
11
11
 
12
12
  export type PostUpload200 = {
13
- message?: string
14
13
  success?: boolean
14
+ message?: string
15
15
  }
16
16
 
17
17
  export type PostUploadBody = {
18
- /** Description of the file */
19
- description?: string
20
18
  /** File to upload */
21
19
  file: Blob
20
+ /** Description of the file */
21
+ description?: string
22
22
  /** User ID associated with the upload */
23
23
  userId: string
24
24
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Automatically generated by @grafana/openapi-to-k6: 0.2.6
2
+ * Automatically generated by @grafana/openapi-to-k6: 0.3.1
3
3
  * Do not edit manually.
4
4
  * Form Data API
5
5
  * Service version: 1.0.0
@@ -22,6 +22,8 @@ export class FormDataAPIClient {
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
  /**
@@ -50,8 +52,8 @@ export class FormDataAPIClient {
50
52
  const response = http.request('POST', url.toString(), formData.body(), {
51
53
  ...mergedRequestParameters,
52
54
  headers: {
53
- 'Content-Type': 'multipart/form-data; boundary=' + formData.boundary,
54
55
  ...mergedRequestParameters?.headers,
56
+ 'Content-Type': 'multipart/form-data; boundary=' + formData.boundary,
55
57
  },
56
58
  })
57
59
  let data
@@ -1,11 +1,19 @@
1
1
  import { FormDataAPIClient } from './formDataAPI.ts'
2
2
 
3
3
  const baseUrl = '<BASE_URL>'
4
- const client = new FormDataAPIClient({ baseUrl })
4
+ const formDataAPIClient = new FormDataAPIClient({ baseUrl })
5
5
 
6
6
  export default function () {
7
+ let postUploadBody
8
+
7
9
  /**
8
10
  * Upload files and data
9
11
  */
10
- const postUploadResponseData = client.postUpload(postUploadBody)
12
+ postUploadBody = {
13
+ file: 'example.pdf',
14
+ description: 'Monthly report document',
15
+ userId: 'user123',
16
+ }
17
+
18
+ const postUploadResponseData = formDataAPIClient.postUpload(postUploadBody)
11
19
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Automatically generated by @grafana/openapi-to-k6: 0.2.6
2
+ * Automatically generated by @grafana/openapi-to-k6: 0.3.1
3
3
  * Do not edit manually.
4
4
  * Form Data API
5
5
  * Service version: 1.0.0
@@ -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
  /**
@@ -50,8 +52,8 @@ export class DefaultClient {
50
52
  const response = http.request('POST', url.toString(), formData.body(), {
51
53
  ...mergedRequestParameters,
52
54
  headers: {
53
- 'Content-Type': 'multipart/form-data; boundary=' + formData.boundary,
54
55
  ...mergedRequestParameters?.headers,
56
+ 'Content-Type': 'multipart/form-data; boundary=' + formData.boundary,
55
57
  },
56
58
  })
57
59
  let data
@@ -1,24 +1,24 @@
1
1
  /**
2
- * Automatically generated by @grafana/openapi-to-k6: 0.2.6
2
+ * Automatically generated by @grafana/openapi-to-k6: 0.3.1
3
3
  * Do not edit manually.
4
4
  * Form Data API
5
5
  * Service version: 1.0.0
6
6
  */
7
7
  export type PostUpload400 = {
8
- error?: string
9
8
  success?: boolean
9
+ error?: string
10
10
  }
11
11
 
12
12
  export type PostUpload200 = {
13
- message?: string
14
13
  success?: boolean
14
+ message?: string
15
15
  }
16
16
 
17
17
  export type PostUploadBody = {
18
- /** Description of the file */
19
- description?: string
20
18
  /** File to upload */
21
19
  file: Blob
20
+ /** Description of the file */
21
+ description?: string
22
22
  /** User ID associated with the upload */
23
23
  userId: string
24
24
  }
@@ -1,11 +1,19 @@
1
- import { FormDataAPIClient } from './formDataAPI.ts'
1
+ import { DefaultClient } from './default.ts'
2
2
 
3
3
  const baseUrl = '<BASE_URL>'
4
- const client = new FormDataAPIClient({ baseUrl })
4
+ const defaultClient = new DefaultClient({ baseUrl })
5
5
 
6
6
  export default function () {
7
+ let postUploadBody
8
+
7
9
  /**
8
10
  * Upload files and data
9
11
  */
10
- const postUploadResponseData = client.postUpload(postUploadBody)
12
+ postUploadBody = {
13
+ file: 'example.pdf',
14
+ description: 'Monthly report document',
15
+ userId: 'user123',
16
+ }
17
+
18
+ const postUploadResponseData = defaultClient.postUpload(postUploadBody)
11
19
  }
@@ -18,16 +18,19 @@
18
18
  "properties": {
19
19
  "name": {
20
20
  "type": "string",
21
- "description": "Name of the user"
21
+ "description": "Name of the user",
22
+ "example": "John Doe"
22
23
  },
23
24
  "age": {
24
25
  "type": "integer",
25
- "description": "Age of the user"
26
+ "description": "Age of the user",
27
+ "example": 25
26
28
  },
27
29
  "email": {
28
30
  "type": "string",
29
31
  "format": "email",
30
- "description": "Email address of the user"
32
+ "description": "Email address of the user",
33
+ "example": "john.doe@example.com"
31
34
  }
32
35
  },
33
36
  "required": [
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Automatically generated by @grafana/openapi-to-k6: 0.2.6
2
+ * Automatically generated by @grafana/openapi-to-k6: 0.3.1
3
3
  * Do not edit manually.
4
4
  * Form URL Encoded API
5
5
  * Service version: 1.0.0
@@ -8,22 +8,22 @@ import { URL } from 'https://jslib.k6.io/url/1.0.0/index.js'
8
8
  import http from 'k6/http'
9
9
  import type { Params, Response } from 'k6/http'
10
10
  export type PostSubmitForm400 = {
11
- error?: string
12
11
  success?: boolean
12
+ error?: string
13
13
  }
14
14
 
15
15
  export type PostSubmitForm200 = {
16
- message?: string
17
16
  success?: boolean
17
+ message?: string
18
18
  }
19
19
 
20
20
  export type PostSubmitFormBody = {
21
+ /** Name of the user */
22
+ name: string
21
23
  /** Age of the user */
22
24
  age?: number
23
25
  /** Email address of the user */
24
26
  email: string
25
- /** Name of the user */
26
- name: string
27
27
  }
28
28
 
29
29
  /**
@@ -38,6 +38,8 @@ export class FormURLEncodedAPIClient {
38
38
  commonRequestParameters?: Params
39
39
  }) {
40
40
  this.cleanBaseUrl = clientOptions.baseUrl.replace(/\/+$/, '')
41
+
42
+ this.commonRequestParameters = clientOptions.commonRequestParameters || {}
41
43
  }
42
44
 
43
45
  /**
@@ -63,8 +65,8 @@ export class FormURLEncodedAPIClient {
63
65
  {
64
66
  ...mergedRequestParameters,
65
67
  headers: {
66
- 'Content-Type': 'application/x-www-form-urlencoded',
67
68
  ...mergedRequestParameters?.headers,
69
+ 'Content-Type': 'application/x-www-form-urlencoded',
68
70
  },
69
71
  }
70
72
  )
@@ -1,11 +1,20 @@
1
1
  import { FormURLEncodedAPIClient } from './formURLEncodedAPI.ts'
2
2
 
3
3
  const baseUrl = '<BASE_URL>'
4
- const client = new FormURLEncodedAPIClient({ baseUrl })
4
+ const formURLEncodedAPIClient = new FormURLEncodedAPIClient({ baseUrl })
5
5
 
6
6
  export default function () {
7
+ let postSubmitFormBody
8
+
7
9
  /**
8
10
  * Submit form data
9
11
  */
10
- const postSubmitFormResponseData = client.postSubmitForm(postSubmitFormBody)
12
+ postSubmitFormBody = {
13
+ name: 'John Doe',
14
+ age: '25',
15
+ email: 'john.doe@example.com',
16
+ }
17
+
18
+ const postSubmitFormResponseData =
19
+ formURLEncodedAPIClient.postSubmitForm(postSubmitFormBody)
11
20
  }
@@ -1,24 +1,24 @@
1
1
  /**
2
- * Automatically generated by @grafana/openapi-to-k6: 0.2.6
2
+ * Automatically generated by @grafana/openapi-to-k6: 0.3.1
3
3
  * Do not edit manually.
4
4
  * Form URL Encoded API
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
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Automatically generated by @grafana/openapi-to-k6: 0.2.6
2
+ * Automatically generated by @grafana/openapi-to-k6: 0.3.1
3
3
  * Do not edit manually.
4
4
  * Form URL Encoded API
5
5
  * Service version: 1.0.0
@@ -24,6 +24,8 @@ export class FormURLEncodedAPIClient {
24
24
  commonRequestParameters?: Params
25
25
  }) {
26
26
  this.cleanBaseUrl = clientOptions.baseUrl.replace(/\/+$/, '')
27
+
28
+ this.commonRequestParameters = clientOptions.commonRequestParameters || {}
27
29
  }
28
30
 
29
31
  /**
@@ -49,8 +51,8 @@ export class FormURLEncodedAPIClient {
49
51
  {
50
52
  ...mergedRequestParameters,
51
53
  headers: {
52
- 'Content-Type': 'application/x-www-form-urlencoded',
53
54
  ...mergedRequestParameters?.headers,
55
+ 'Content-Type': 'application/x-www-form-urlencoded',
54
56
  },
55
57
  }
56
58
  )
@@ -1,11 +1,20 @@
1
1
  import { FormURLEncodedAPIClient } from './formURLEncodedAPI.ts'
2
2
 
3
3
  const baseUrl = '<BASE_URL>'
4
- const client = new FormURLEncodedAPIClient({ baseUrl })
4
+ const formURLEncodedAPIClient = new FormURLEncodedAPIClient({ baseUrl })
5
5
 
6
6
  export default function () {
7
+ let postSubmitFormBody
8
+
7
9
  /**
8
10
  * Submit form data
9
11
  */
10
- const postSubmitFormResponseData = client.postSubmitForm(postSubmitFormBody)
12
+ postSubmitFormBody = {
13
+ name: 'John Doe',
14
+ age: '25',
15
+ email: 'john.doe@example.com',
16
+ }
17
+
18
+ const postSubmitFormResponseData =
19
+ formURLEncodedAPIClient.postSubmitForm(postSubmitFormBody)
11
20
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Automatically generated by @grafana/openapi-to-k6: 0.2.6
2
+ * Automatically generated by @grafana/openapi-to-k6: 0.3.1
3
3
  * Do not edit manually.
4
4
  * Form URL Encoded API
5
5
  * Service version: 1.0.0
@@ -24,6 +24,8 @@ export class DefaultClient {
24
24
  commonRequestParameters?: Params
25
25
  }) {
26
26
  this.cleanBaseUrl = clientOptions.baseUrl.replace(/\/+$/, '')
27
+
28
+ this.commonRequestParameters = clientOptions.commonRequestParameters || {}
27
29
  }
28
30
 
29
31
  /**
@@ -49,8 +51,8 @@ export class DefaultClient {
49
51
  {
50
52
  ...mergedRequestParameters,
51
53
  headers: {
52
- 'Content-Type': 'application/x-www-form-urlencoded',
53
54
  ...mergedRequestParameters?.headers,
55
+ 'Content-Type': 'application/x-www-form-urlencoded',
54
56
  },
55
57
  }
56
58
  )
@@ -1,24 +1,24 @@
1
1
  /**
2
- * Automatically generated by @grafana/openapi-to-k6: 0.2.6
2
+ * Automatically generated by @grafana/openapi-to-k6: 0.3.1
3
3
  * Do not edit manually.
4
4
  * Form URL Encoded API
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
  }
@@ -1,11 +1,20 @@
1
- import { FormURLEncodedAPIClient } from './formURLEncodedAPI.ts'
1
+ import { DefaultClient } from './default.ts'
2
2
 
3
3
  const baseUrl = '<BASE_URL>'
4
- const client = new FormURLEncodedAPIClient({ baseUrl })
4
+ const defaultClient = new DefaultClient({ baseUrl })
5
5
 
6
6
  export default function () {
7
+ let postSubmitFormBody
8
+
7
9
  /**
8
10
  * Submit form data
9
11
  */
10
- const postSubmitFormResponseData = client.postSubmitForm(postSubmitFormBody)
12
+ postSubmitFormBody = {
13
+ name: 'John Doe',
14
+ age: '25',
15
+ email: 'john.doe@example.com',
16
+ }
17
+
18
+ const postSubmitFormResponseData =
19
+ defaultClient.postSubmitForm(postSubmitFormBody)
11
20
  }
@@ -16,7 +16,8 @@
16
16
  "required": true,
17
17
  "description": "Authentication token",
18
18
  "schema": {
19
- "type": "string"
19
+ "type": "string",
20
+ "example": "Bearer abcdef12345"
20
21
  }
21
22
  },
22
23
  {
@@ -39,16 +40,19 @@
39
40
  "properties": {
40
41
  "name": {
41
42
  "type": "string",
42
- "description": "Name of the user"
43
+ "description": "Name of the user",
44
+ "example": "John Doe"
43
45
  },
44
46
  "age": {
45
47
  "type": "integer",
46
- "description": "Age of the user"
48
+ "description": "Age of the user",
49
+ "example": 25
47
50
  },
48
51
  "email": {
49
52
  "type": "string",
50
53
  "format": "email",
51
- "description": "Email address of the user"
54
+ "description": "Email address of the user",
55
+ "example": "john.doe@example.com"
52
56
  }
53
57
  },
54
58
  "required": [
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Automatically generated by @grafana/openapi-to-k6: 0.2.6
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
@@ -8,22 +8,22 @@ import { URL, URLSearchParams } from 'https://jslib.k6.io/url/1.0.0/index.js'
8
8
  import http from 'k6/http'
9
9
  import type { Params, Response } from 'k6/http'
10
10
  export type PostSubmitForm400 = {
11
- error?: string
12
11
  success?: boolean
12
+ error?: string
13
13
  }
14
14
 
15
15
  export type PostSubmitForm200 = {
16
- message?: string
17
16
  success?: boolean
17
+ message?: string
18
18
  }
19
19
 
20
20
  export type PostSubmitFormBody = {
21
+ /** Name of the user */
22
+ name: string
21
23
  /** Age of the user */
22
24
  age?: number
23
25
  /** Email address of the user */
24
26
  email: string
25
- /** Name of the user */
26
- name: string
27
27
  }
28
28
 
29
29
  export type PostSubmitFormParams = {
@@ -49,6 +49,8 @@ export class FormURLEncodedAPIWithQueryParametersClient {
49
49
  commonRequestParameters?: Params
50
50
  }) {
51
51
  this.cleanBaseUrl = clientOptions.baseUrl.replace(/\/+$/, '')
52
+
53
+ this.commonRequestParameters = clientOptions.commonRequestParameters || {}
52
54
  }
53
55
 
54
56
  /**
@@ -79,8 +81,8 @@ export class FormURLEncodedAPIWithQueryParametersClient {
79
81
  {
80
82
  ...mergedRequestParameters,
81
83
  headers: {
82
- 'Content-Type': 'application/x-www-form-urlencoded',
83
84
  ...mergedRequestParameters?.headers,
85
+ 'Content-Type': 'application/x-www-form-urlencoded',
84
86
  },
85
87
  }
86
88
  )
@@ -1,14 +1,27 @@
1
- import { FormURLEncodedAPIwithQueryParametersClient } from './formURLEncodedAPIWithQueryParameters.ts'
1
+ import { FormURLEncodedAPIWithQueryParametersClient } from './formURLEncodedAPIWithQueryParameters.ts'
2
2
 
3
3
  const baseUrl = '<BASE_URL>'
4
- const client = new FormURLEncodedAPIwithQueryParametersClient({ baseUrl })
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
- const postSubmitFormResponseData = client.postSubmitForm(
11
- postSubmitFormBody,
12
- params
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,26 +1,26 @@
1
1
  /**
2
- * Automatically generated by @grafana/openapi-to-k6: 0.2.6
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,5 +1,5 @@
1
1
  /**
2
- * Automatically generated by @grafana/openapi-to-k6: 0.2.6
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 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
  )