[k6] OpenAPI code generator for k6 API load-testing tool (ES5.1+)#5300
Merged
wing328 merged 3 commits intoOpenAPITools:masterfrom Feb 19, 2020
k6io:feature/k6
Merged
[k6] OpenAPI code generator for k6 API load-testing tool (ES5.1+)#5300wing328 merged 3 commits intoOpenAPITools:masterfrom k6io:feature/k6
wing328 merged 3 commits intoOpenAPITools:masterfrom
k6io:feature/k6
Conversation
Member
|
@mostafa Thanks for the PR. I notice some build errors. I'll try to update your branch directly to fix those issues. |
Member
|
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
|
Member
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. |
Member
|
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. |
MikailBag
pushed a commit
to MikailBag/openapi-generator
that referenced
this pull request
Mar 23, 2020
…enAPITools#5300) * Add generator for converting OpenAPI spec to k6 script * Fixed names and URL * Add @wing328's proposed changes to fix the builds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.mdand add ourselves asTemplate CreatorsandTechnical Committeefor 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.shif 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.