-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[k6] OpenAPI code generator for k6 API load-testing tool (ES5.1+) #5300
Conversation
@mostafa Thanks for the PR. I notice some build errors. I'll try to update your branch directly to fix those issues. |
I don't have right to push to your branch. Please apply the following fix when you've time: diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/k6Codegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/k6Codegen.java
index 72d9ac2edc..a220b67d32 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/k6Codegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/k6Codegen.java
@@ -334,7 +334,7 @@ public class k6Codegen extends DefaultCodegen implements CodegenConfig {
"http.file(open(\"/path/to/file.bin\", \"b\"), \"test.bin\")");
} else {
k6Parameter = new Parameter(parameter.paramName, !reference.isEmpty() ? reference
- : getDoubleQuotedString(parameter.dataType.toLowerCase()));
+ : getDoubleQuotedString(parameter.dataType.toLowerCase(Locale.ROOT)));
}
bodyOrFormParams.add(k6Parameter);
@@ -349,13 +349,13 @@ public class k6Codegen extends DefaultCodegen implements CodegenConfig {
switch (parameter.getIn()) {
case "header":
httpParams.add(new Parameter(parameter.getName(), getTemplateString(parameter.getName())));
- extraParameters.add(new Parameter(parameter.getName(), parameter.getName().toUpperCase()));
+ extraParameters.add(new Parameter(parameter.getName(), parameter.getName().toUpperCase(Locale.ROOT)));
break;
case "path":
case "query":
if (parameter.getIn().equals("query"))
queryParams.add(new Parameter(parameter.getName(), getVariable(parameter.getName())));
- variables.add(new Parameter(parameter.getName(), parameter.getName().toUpperCase()));
+ variables.add(new Parameter(parameter.getName(), parameter.getName().toUpperCase(Locale.ROOT)));
break;
default:
break;
@@ -407,7 +407,7 @@ public class k6Codegen extends DefaultCodegen implements CodegenConfig {
StringBuilder reference = new StringBuilder();
int modelEntrySetSize = model.getAllVars().size();
for (CodegenProperty property : model.getAllVars()) {
- reference.append(getDoubleQuotedString(property.name)).append(": ").append(getDoubleQuotedString(property.dataType.toLowerCase()));
+ reference.append(getDoubleQuotedString(property.name)).append(": ").append(getDoubleQuotedString(property.dataType.toLowerCase(Locale.ROOT)));
if (modelEntrySetSize > 1)
reference.append(", ");
}
@@ -430,7 +430,7 @@ public class k6Codegen extends DefaultCodegen implements CodegenConfig {
/**
* Concatenates an array of path segments into a path string.
- *
+ *
* @param segments The path segments to concatenate. A segment may contain
* either of the file separator characters '\' or '/'. A segment
* is ignored if it is <code>null</code>, empty or
|
I'll do that in a separate PR.
I think so. I'll consider it as a beta release so as to gather feedback from the community. |
The CircleCI failed due to outdated documentation. I'll push a fix (commit) after merging this PR. I'll also file a PR with various improvements to this new generator. |
…enAPITools#5300) * Add generator for converting OpenAPI spec to k6 script * Fixed names and URL * Add @wing328's proposed changes to fix the builds
k6 is an API load-testing tool created by Load Impact AB to help developers and DevOps people test the performance of their APIs. It is written in Go, and is scriptable in JavaScript, supporting ES5.1+. At Load Impact, we have converters/codegens for HAR files, Postman collections and JMeter to help users of k6 easily be onboard to our tool.
Since we focus on API load-testing, we thought it would be a good idea to create a Swagger/OpenAPI code generator, too. So, after much research, we found that this project is the officially developed and maintained one that we can reliably put our efforts on. Thus we created this code generator, to help generate k6 scripts from Swagger 2.0 specification documents.
This is our first PoC and we definitely would like to hear your feedback to improve it further. There are some questions for the official maintainers:
README.md
and add ourselves asTemplate Creators
andTechnical Committee
for k6?We really appreciate your feedback on this.
Note: On @wing328's suggestion I have ported the code from swagger-api/swagger-codegen#10013 to this project.
PR checklist
./bin/
(or Windows batch scripts under.\bin\windows
) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the code or mustache templates for a language ({LANG}
) (e.g. php, ruby, python, etc).master
,4.3.x
,5.0.x
. Default:master
.