Skip to content
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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bin/configs/k6.yaml
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
Copy link
Member

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.

5 changes: 5 additions & 0 deletions modules/openapi-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@
<artifactId>commons-lang3</artifactId>
<version>${commons-lang.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>${commons-text.version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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;
}

Expand All @@ -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);
}

/**
Expand All @@ -85,7 +89,7 @@ public boolean getHasBodyParam() {
* @return true if query parameter exists, false otherwise
*/
public boolean getHasQueryParams() {
return nonempty(queryParams);
return nonEmpty(queryParams);
}

/**
Expand All @@ -103,7 +107,7 @@ public boolean getHasQueryParamsOrAuth() {
* @return true if header parameter exists, false otherwise
*/
public boolean getHasHeaderParams() {
return nonempty(headerParams);
return nonEmpty(headerParams);
}

/**
Expand All @@ -112,7 +116,7 @@ public boolean getHasHeaderParams() {
* @return true if path parameter exists, false otherwise
*/
public boolean getHasPathParams() {
return nonempty(pathParams);
return nonEmpty(pathParams);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -166,7 +170,7 @@ public boolean getHasRequiredParams() {
* @return true if header response exists, false otherwise
*/
public boolean getHasResponseHeaders() {
return nonempty(responseHeaders);
return nonEmpty(responseHeaders);
}

/**
Expand All @@ -175,7 +179,7 @@ public boolean getHasResponseHeaders() {
* @return true if examples parameter exists, false otherwise
*/
public boolean getHasExamples() {
return nonempty(examples);
return nonEmpty(examples);
}

/**
Expand All @@ -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
*
Expand Down
Loading