Skip to content

Commit 3c96f73

Browse files
Add openapi-to-k6 config options (#2068)
1 parent bc739b9 commit 3c96f73

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

docs/sources/k6/next/using-k6/test-authoring/create-test-script-using-openapi.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,37 @@ k6 run script.sample.ts
6464
```
6565

6666
Make sure to replace `script.sample.ts` with the name of your generated test script. Depending on the API you're testing and the OpenAPI schema that you're using, you may need to edit the TypeScript file to update any authentication parameters or headers to run the test script successfully.
67+
68+
## Options
69+
70+
You can use the following configuration options when running `openapi-to-k6` in the CLI.
71+
72+
### `--mode`
73+
74+
The `--mode` or `-m` option specifies the mode to be used when generating the client. The options are:
75+
76+
- `single`: This is the default mode. It generates the TypeScript client with all the types and implementation as a single file.
77+
- `split`: This mode splits the types and implementation into separate files.
78+
- `tags`: This modes splits your OpenAPI definition based on the tags and generates a separate client for each tag. If a route has no tag set, the client is included in the default.ts file.
79+
80+
### `--only-tags`
81+
82+
`--only-tags` filters the generated client to only include routes with specific tags from your OpenAPI definition. You can specify multiple tags to include routes matching any of those tags. Routes without tags are excluded. This is useful for generating focused clients that only contain the endpoints you need.
83+
84+
For example: `openapi-to-k6 <path-to-openapi-schema> <output path> --only-tags ItemsHeader` generates a client with only the routes that have the `ItemsHeader` tag. You can specify multiple tags by using multiple `--only-tags` flags or by separating them with spaces: `--only-tags tag1 --only-tags tag2`.
85+
86+
### `--disable-analytics`
87+
88+
`--disable-analytics` disables anonymous usage analytics reporting. You can also use the `DISABLE_ANALYTICS=true` environment variable to turn off this feature.
89+
90+
### `--include-sample-script`
91+
92+
`--include-sample-script` generates a sample k6 script. The generated sample script uses the examples defined in the OpenAPI definition requests to make the script usable out of the box. If the examples aren't defined, it uses Faker to generate random data.
93+
94+
### `--verbose`
95+
96+
`--verbose` or `-v` enables verbose logging to show a more detailed logging output.
97+
98+
### `--help`
99+
100+
`--help` or `-h` displays the openapi-to-k6 help message, including a list of all available configuration options.

0 commit comments

Comments
 (0)