@grafana/openapi-to-k6 0.3.1 → 0.4.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/.github/workflows/publish.yaml +39 -13
- package/.github/workflows/tests.yaml +23 -10
- package/.nvmrc +1 -1
- package/CODEOWNERS +2 -0
- package/README.md +34 -39
- package/catalog-info.yaml +13 -0
- package/dist/generator/k6Client.js +7 -4
- package/examples/basic_schema/single/simpleAPI.ts +5 -3
- package/examples/basic_schema/split/simpleAPI.schemas.ts +1 -1
- package/examples/basic_schema/split/simpleAPI.ts +5 -3
- package/examples/basic_schema/tags/default.ts +5 -3
- package/examples/basic_schema/tags/simpleAPI.schemas.ts +1 -1
- package/examples/form_data_schema/single/formDataAPI.ts +15 -13
- package/examples/form_data_schema/split/formDataAPI.schemas.ts +11 -11
- package/examples/form_data_schema/split/formDataAPI.ts +5 -3
- package/examples/form_data_schema/tags/default.ts +5 -3
- package/examples/form_data_schema/tags/formDataAPI.schemas.ts +11 -11
- package/examples/form_url_encoded_data_schema/single/formURLEncodedAPI.ts +15 -13
- package/examples/form_url_encoded_data_schema/split/formURLEncodedAPI.schemas.ts +11 -11
- package/examples/form_url_encoded_data_schema/split/formURLEncodedAPI.ts +5 -3
- package/examples/form_url_encoded_data_schema/tags/default.ts +5 -3
- package/examples/form_url_encoded_data_schema/tags/formURLEncodedAPI.schemas.ts +11 -11
- package/examples/form_url_encoded_data_with_query_params_schema/single/formURLEncodedAPIWithQueryParameters.ts +22 -20
- package/examples/form_url_encoded_data_with_query_params_schema/split/formURLEncodedAPIWithQueryParameters.schemas.ts +18 -18
- package/examples/form_url_encoded_data_with_query_params_schema/split/formURLEncodedAPIWithQueryParameters.ts +5 -3
- package/examples/form_url_encoded_data_with_query_params_schema/tags/default.ts +5 -3
- package/examples/form_url_encoded_data_with_query_params_schema/tags/formURLEncodedAPIWithQueryParameters.schemas.ts +18 -18
- package/examples/get_request_with_path_parameters_schema/single/simpleAPI.ts +5 -3
- package/examples/get_request_with_path_parameters_schema/split/simpleAPI.schemas.ts +1 -1
- package/examples/get_request_with_path_parameters_schema/split/simpleAPI.ts +5 -3
- package/examples/get_request_with_path_parameters_schema/tags/default.ts +5 -3
- package/examples/get_request_with_path_parameters_schema/tags/simpleAPI.schemas.ts +1 -1
- package/examples/headers_schema/single/headerDemoAPI.ts +24 -18
- package/examples/headers_schema/split/headerDemoAPI.schemas.ts +12 -12
- package/examples/headers_schema/split/headerDemoAPI.ts +13 -7
- package/examples/headers_schema/tags/default.ts +13 -7
- package/examples/headers_schema/tags/headerDemoAPI.schemas.ts +12 -12
- package/examples/no_title_schema/single/k6Client.ts +5 -3
- package/examples/no_title_schema/split/k6Client.schemas.ts +1 -1
- package/examples/no_title_schema/split/k6Client.ts +5 -3
- package/examples/no_title_schema/tags/default.ts +5 -3
- package/examples/no_title_schema/tags/k6Client.schemas.ts +1 -1
- package/examples/post_request_with_query_params/single/exampleAPI.ts +21 -19
- package/examples/post_request_with_query_params/split/exampleAPI.schemas.ts +17 -17
- package/examples/post_request_with_query_params/split/exampleAPI.ts +5 -3
- package/examples/post_request_with_query_params/tags/default.ts +5 -3
- package/examples/post_request_with_query_params/tags/exampleAPI.schemas.ts +17 -17
- package/examples/query_params_schema/single/exampleAPI.ts +13 -11
- package/examples/query_params_schema/split/exampleAPI.schemas.ts +9 -9
- package/examples/query_params_schema/split/exampleAPI.ts +5 -3
- package/examples/query_params_schema/tags/default.ts +5 -3
- package/examples/query_params_schema/tags/exampleAPI.schemas.ts +9 -9
- package/examples/simple_post_request_schema/single/exampleAPI.ts +21 -19
- package/examples/simple_post_request_schema/split/exampleAPI.schemas.ts +17 -17
- package/examples/simple_post_request_schema/split/exampleAPI.ts +5 -3
- package/examples/simple_post_request_schema/tags/default.ts +5 -3
- package/examples/simple_post_request_schema/tags/exampleAPI.schemas.ts +17 -17
- package/package.json +20 -20
- package/renovate.json +6 -0
- package/src/generator/k6Client.ts +9 -3
- package/tests/functional-tests/test-generator/fixtures/form_data_schema.json +2 -2
- package/tests/functional-tests/test-generator/fixtures/form_url_encoded_data_schema.json +2 -2
- package/tests/functional-tests/test-generator/fixtures/form_url_encoded_data_with_query_params_schema.json +1 -1
- package/tests/functional-tests/test-generator/fixtures/get_request_with_path_parameters_schema.json +1 -1
- package/tests/functional-tests/test-generator/fixtures/headers_schema.json +6 -6
- package/tests/functional-tests/test-generator/fixtures/simple_post_request_schema.json +1 -1
- package/tests/functional-tests/test-generator/generator.test.ts +9 -1
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"fileName": "exampleAPI.ts",
|
|
122
122
|
"expectedSubstrings": [
|
|
123
123
|
"export class ExampleAPIClient {",
|
|
124
|
-
"const
|
|
124
|
+
"const k6url = new URL(this.cleanBaseUrl + `/example`);",
|
|
125
125
|
"JSON.stringify(createExampleDataBody),",
|
|
126
126
|
"POST",
|
|
127
127
|
"export type CreateExampleData201 = { /** The unique ID of the created resource */ id?: string; name?: string; age?: number; isActive?: boolean; tags?: string[]; date?: string; meta?: CreateExampleData201Meta; };"
|
|
@@ -28,7 +28,10 @@ const commonSubstringsForAllSDK = [
|
|
|
28
28
|
'Service version',
|
|
29
29
|
'const mergedRequestParameters = this._mergeRequestParameters( requestParameters || {}, this.commonRequestParameters, );',
|
|
30
30
|
'try { data = response.json(); } catch { data = response.body; }',
|
|
31
|
-
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
const commonMatchesForAllSDK = [
|
|
34
|
+
/return { response, data, operationId: "[^"]*", };/,
|
|
32
35
|
]
|
|
33
36
|
|
|
34
37
|
const commonSubstringsForK6SampleScript = [`const baseUrl = "<BASE_URL>";`]
|
|
@@ -95,6 +98,11 @@ describe('generator', () => {
|
|
|
95
98
|
replaceSpacesAndNewLineToSingleSpace(generatedContent)
|
|
96
99
|
).toContain(expectedString)
|
|
97
100
|
}
|
|
101
|
+
for (const expectedToMatch of commonMatchesForAllSDK) {
|
|
102
|
+
expect(
|
|
103
|
+
replaceSpacesAndNewLineToSingleSpace(generatedContent)
|
|
104
|
+
).toMatch(expectedToMatch)
|
|
105
|
+
}
|
|
98
106
|
})
|
|
99
107
|
|
|
100
108
|
it('should generate a sample K6 script', async () => {
|