-
-
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 Generator] various enhancements (request body example data extraction, support for generating scenario tests and load tests out of the box, and much more) #11106
Merged
wing328
merged 16 commits into
OpenAPITools:master
from
grafana:k6-openapi-extract-examples-enhancements
Dec 17, 2021
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
67eac90
Further K6 OpenAPI generator enhancements
ideas-into-software 809dadd
Further K6 OpenAPI generator enhancements
ideas-into-software ed3f00c
Further K6 OpenAPI generator enhancements
ideas-into-software 66dc3ed
Fix suggested changes by linter
mostafa a79d0c7
Fix extra spaces in the template
mostafa 5082527
Merge branch 'master' into k6-openapi-extract-examples-enhancements
mostafa 5d28180
Log exception
mostafa d9e10b8
Rename function signature to camelCase
mostafa 6e106df
Address comments on Big-O
mostafa 4cb1819
Move declaration of variable near the usage
mostafa fd19b33
Add config file for generating k6 script
mostafa a42d924
Regenerate k6 script
mostafa 86ffce3
Merge branch 'OpenAPITools:master' into k6-openapi-extract-examples-e…
mostafa 070f730
Regenerate samples
mostafa 8788910
Fix predicate
mostafa e79063b
Fix missing import
mostafa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
generatorName: k6 | ||
outputDir: samples/client/petstore/k6 | ||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml | ||
templateDir: modules/openapi-generator/src/main/resources/k6 | ||
additionalProperties: | ||
appName: PetstoreClient | ||
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,11 @@ public class CodegenOperation { | |
* | ||
* @return true if parameter exists, false otherwise | ||
*/ | ||
private static boolean nonempty(List<?> params) { | ||
private static boolean nonEmpty(List<?> params) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @agilob This is unrelated to our code, but I changed it nevertheless. |
||
return params != null && params.size() > 0; | ||
} | ||
|
||
private static boolean nonEmpty(Map<?, ?> params) { | ||
return params != null && params.size() > 0; | ||
} | ||
|
||
|
@@ -76,7 +80,7 @@ private static boolean nonempty(List<?> params) { | |
* @return true if body parameter exists, false otherwise | ||
*/ | ||
public boolean getHasBodyParam() { | ||
return nonempty(bodyParams); | ||
return nonEmpty(bodyParams); | ||
} | ||
|
||
/** | ||
|
@@ -85,7 +89,7 @@ public boolean getHasBodyParam() { | |
* @return true if query parameter exists, false otherwise | ||
*/ | ||
public boolean getHasQueryParams() { | ||
return nonempty(queryParams); | ||
return nonEmpty(queryParams); | ||
} | ||
|
||
/** | ||
|
@@ -103,7 +107,7 @@ public boolean getHasQueryParamsOrAuth() { | |
* @return true if header parameter exists, false otherwise | ||
*/ | ||
public boolean getHasHeaderParams() { | ||
return nonempty(headerParams); | ||
return nonEmpty(headerParams); | ||
} | ||
|
||
/** | ||
|
@@ -112,7 +116,7 @@ public boolean getHasHeaderParams() { | |
* @return true if path parameter exists, false otherwise | ||
*/ | ||
public boolean getHasPathParams() { | ||
return nonempty(pathParams); | ||
return nonEmpty(pathParams); | ||
} | ||
|
||
/** | ||
|
@@ -121,7 +125,7 @@ public boolean getHasPathParams() { | |
* @return true if any form parameter exists, false otherwise | ||
*/ | ||
public boolean getHasFormParams() { | ||
return nonempty(formParams); | ||
return nonEmpty(formParams); | ||
} | ||
|
||
/** | ||
|
@@ -139,7 +143,7 @@ public boolean getHasBodyOrFormParams() { | |
* @return true if any cookie parameter exists, false otherwise | ||
*/ | ||
public boolean getHasCookieParams() { | ||
return nonempty(cookieParams); | ||
return nonEmpty(cookieParams); | ||
} | ||
|
||
/** | ||
|
@@ -148,7 +152,7 @@ public boolean getHasCookieParams() { | |
* @return true if any optional parameter exists, false otherwise | ||
*/ | ||
public boolean getHasOptionalParams() { | ||
return nonempty(optionalParams); | ||
return nonEmpty(optionalParams); | ||
} | ||
|
||
/** | ||
|
@@ -157,7 +161,7 @@ public boolean getHasOptionalParams() { | |
* @return true if any optional parameter exists, false otherwise | ||
*/ | ||
public boolean getHasRequiredParams() { | ||
return nonempty(requiredParams); | ||
return nonEmpty(requiredParams); | ||
} | ||
|
||
/** | ||
|
@@ -166,7 +170,7 @@ public boolean getHasRequiredParams() { | |
* @return true if header response exists, false otherwise | ||
*/ | ||
public boolean getHasResponseHeaders() { | ||
return nonempty(responseHeaders); | ||
return nonEmpty(responseHeaders); | ||
} | ||
|
||
/** | ||
|
@@ -175,7 +179,7 @@ public boolean getHasResponseHeaders() { | |
* @return true if examples parameter exists, false otherwise | ||
*/ | ||
public boolean getHasExamples() { | ||
return nonempty(examples); | ||
return nonEmpty(examples); | ||
} | ||
|
||
/** | ||
|
@@ -187,6 +191,15 @@ public boolean getHasDefaultResponse() { | |
return responses.stream().filter(response -> response.isDefault).findFirst().isPresent(); | ||
} | ||
|
||
/** | ||
* Check if there's at least one vendor extension | ||
* | ||
* @return true if vendor extensions exists, false otherwise | ||
*/ | ||
public boolean getHasVendorExtensions() { | ||
return nonEmpty(vendorExtensions); | ||
} | ||
|
||
/** | ||
* Check if act as Restful index method | ||
* | ||
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's already one in ./bin/configs/other/k6.yaml.
I'll remove it after merging this PR.