Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

v2 use name for module name #109

Merged
merged 27 commits into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b40b8e5
Adds CodegenRequestBody
spacether Dec 25, 2022
2f8430b
Java updates where header extends requestbody
spacether Dec 26, 2022
b743a16
Java updates to use getters
spacether Dec 26, 2022
e01e9e8
Removes comment
spacether Dec 26, 2022
0c55b83
Updates fromRequestBody java code
spacether Dec 26, 2022
9ca648d
Regenerates petstore using fixed fromRequestBody
spacether Dec 27, 2022
d8f7c3e
Removes unused java helper methods for fromRequestBody
spacether Dec 27, 2022
d1aa710
Removes unused java code
spacether Dec 27, 2022
005fca9
Adds and uses toHeader, toRequestBody
spacether Dec 27, 2022
64ae277
Uses setRefAndComponentModuleInfo in fromHeader
spacether Dec 27, 2022
1d91484
Uses helper methods in fromParameter
spacether Dec 27, 2022
9036d57
Improves code readability, dedents java code
spacether Dec 27, 2022
b062486
Removes hasHeaders from CodegenResponse, adds getName to OpenapiCompo…
spacether Dec 27, 2022
0c298b6
Adds more methods to OpenapiComponent
spacether Dec 27, 2022
f9c5e55
Uses setLocationInfo, getKey updated to use component type
spacether Dec 27, 2022
f83015e
Stops using paramName in response headers
spacether Dec 27, 2022
87d2ef1
Stops using parameterName for headers
spacether Dec 27, 2022
6f5355c
Adds request body doc generation back in, it fell out
spacether Dec 28, 2022
86c1f86
Switches back to baseName
spacether Dec 28, 2022
484846b
Removes all paramName
spacether Dec 28, 2022
719625e
Removes paramName and uses name.getSnakeCaseName
spacether Dec 28, 2022
73587d9
Moves component types from soffuxes to module prefixes
spacether Dec 28, 2022
15f6eb0
Samples regenerated
spacether Dec 28, 2022
35f0450
Samples regenerated
spacether Dec 28, 2022
73d1c55
Fixes some java tests
spacether Dec 28, 2022
5f524ae
Fixes java test, sets schema example also
spacether Dec 28, 2022
8aac76c
Reverts version file
spacether Dec 28, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,7 @@ public interface CodegenConfig {

String toRefClass(String ref, String sourceJsonPath);

CodegenParameter fromRequestBody(RequestBody body, String bodyParameterName, String sourceJsonPath);

String getBodyParameterName(CodegenOperation co);
CodegenRequestBody fromRequestBody(RequestBody body, String sourceJsonPath);

CodegenResponse fromResponse(ApiResponse response, String sourceJsonPath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,24 @@
* A unique parameter is defined by a combination of a name and location.
* Parameters may be located in a path, query, header or cookie.
*/
public class CodegenHeader implements OpenapiComponent {
public class CodegenHeader extends CodegenRequestBody {
public boolean isExplode;
public String paramName,
description, unescapedDescription, style;
public String style;

public String nameInLowerCase; // property name in lower case
public String example; // example value (x-example)
public String jsonSchema;
public Map<String, Object> vendorExtensions = new HashMap<String, Object>();
public boolean isDeprecated;
protected CodegenSchema schema;
/**
* Determines whether this parameter is mandatory. If the parameter is in "path",
* this property is required and its value MUST be true. Otherwise, the property
* MAY be included and its default value is false.
*/
public boolean required;
protected boolean hasMultipleTypes = false;
protected LinkedHashMap<String, CodegenMediaType> content;
protected String ref;
protected String refModule;

public Set<String> imports = new HashSet<String>();

protected String componentModule;

public CodegenHeader copy() {
CodegenHeader output = new CodegenHeader();
output.paramName = this.paramName;
output.description = this.description;
output.unescapedDescription = this.unescapedDescription;
output.required = this.required;
output.jsonSchema = this.jsonSchema;
output.example = this.example;

if (this.name != null) {
output.setName(this.name);
}
if (this.content != null) {
output.setContent(this.content);
}
Expand Down Expand Up @@ -120,60 +103,29 @@ public String getSetSchemaJsonPath(String jsonPath) {
}
return null;
}
public String getComponentModule() {
return componentModule;
}

public void setComponentModule(String componentModule) {
this.componentModule = componentModule;
}

@Override
public int hashCode() {
return Objects.hash(isExplode, paramName, description, unescapedDescription, style, example, jsonSchema, vendorExtensions, isDeprecated, required, hasMultipleTypes, schema, content, ref, refModule, imports, componentModule);
return Objects.hash(name, isExplode, description, unescapedDescription, style, example, jsonSchema, vendorExtensions, isDeprecated, required, schema, content, ref, refModule, imports, componentModule);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof CodegenHeader)) return false;
if (! super.equals(o)) return false;
CodegenHeader that = (CodegenHeader) o;
return isExplode == that.isExplode &&
isDeprecated == that.isDeprecated &&
required == that.required &&
Objects.equals(componentModule, that.componentModule) &&
Objects.equals(ref, that.getRef()) &&
Objects.equals(imports, that.imports) &&
Objects.equals(refModule, that.getRefModule()) &&
Objects.equals(content, that.getContent()) &&
Objects.equals(schema, that.getSchema()) &&
Objects.equals(paramName, that.paramName) &&
Objects.equals(description, that.description) &&
Objects.equals(unescapedDescription, that.unescapedDescription) &&
Objects.equals(style, that.style) &&
Objects.equals(example, that.example) &&
Objects.equals(jsonSchema, that.jsonSchema) &&
Objects.equals(vendorExtensions, that.vendorExtensions);
Objects.equals(style, that.style);
}

protected void addInstanceInfo(StringBuilder sb) {
super.addInstanceInfo(sb);
sb.append(", isExplode=").append(isExplode);
sb.append(", paramName='").append(paramName).append('\'');
sb.append(", description='").append(description).append('\'');
sb.append(", unescapedDescription='").append(unescapedDescription).append('\'');
sb.append(", style='").append(style).append('\'');
sb.append(", example='").append(example).append('\'');
sb.append(", jsonSchema='").append(jsonSchema).append('\'');
sb.append(", vendorExtensions=").append(vendorExtensions);
sb.append(", isDeprecated=").append(isDeprecated);
sb.append(", required=").append(required);
sb.append(", hasMultipleTypes=").append(hasMultipleTypes);
sb.append(", schema=").append(schema);
sb.append(", content=").append(content);
sb.append(", ref=").append(ref);
sb.append(", refModule=").append(refModule);
sb.append(", imports=").append(imports);
sb.append(", componentModule=").append(componentModule);
}

@Override
Expand All @@ -191,22 +143,5 @@ public CodegenSchema getSchema() {
public void setSchema(CodegenSchema schema) {
this.schema = schema;
}

public LinkedHashMap<String, CodegenMediaType> getContent() {
return content;
}

public void setContent(LinkedHashMap<String, CodegenMediaType> content) {
this.content = content;
}


public String getRef() { return ref; }

public void setRef(String ref) { this.ref=ref; }

public String getRefModule() { return refModule; }

public void setRefModule(String refModule) { this.refModule=refModule; }
}

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.stream.Collectors;

public class CodegenOperation {
public boolean hasAuthMethods, hasConsumes, hasProduces, hasParams, hasOptionalParams, hasRequiredParams,
public boolean hasAuthMethods, hasConsumes, hasProduces, hasParams,
subresourceOperation, isMultipart,
isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy,
isRestful, isDeprecated, isCallbackRequest, uniqueItems, hasDefaultResponse = false,
Expand All @@ -32,16 +32,15 @@ public class CodegenOperation {
summary, unescapedNotes, notes, baseName;
public List<Map<String, String>> consumes, produces, prioritizedContentTypes;
public List<CodegenServer> servers = new ArrayList<CodegenServer>();
public CodegenParameter requestBody;
public CodegenRequestBody requestBody;
public List<CodegenParameter> allParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> bodyParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> pathParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> queryParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> headerParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> implicitHeadersParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> cookieParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> requiredParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> optionalParams = new ArrayList<CodegenParameter>();
public List<CodegenRequestBody> requiredParams = new ArrayList<CodegenRequestBody>();
public List<CodegenRequestBody> optionalParams = new ArrayList<CodegenRequestBody>();
public List<CodegenSecurity> authMethods;
public Map<String, CodegenTag> tags;
public TreeMap<String, CodegenResponse> responses = null;
Expand Down Expand Up @@ -75,15 +74,6 @@ private static boolean nonEmpty(Map<?, ?> params) {
return params != null && !params.isEmpty();
}

/**
* Check if there's at least one body parameter
*
* @return true if body parameter exists, false otherwise
*/
public boolean getHasBodyParam() {
return nonEmpty(bodyParams);
}

/**
* Check if there's at least one query parameter
*
Expand Down Expand Up @@ -120,15 +110,6 @@ public boolean getHasPathParams() {
return nonEmpty(pathParams);
}

/**
* Check if there's at least one body parameter or at least one form parameter
*
* @return true if body or form parameter exists, false otherwise
*/
public boolean getHasBodyOrFormParams() {
return getHasBodyParam();
}

/**
* Check if there's at least one form parameter
*
Expand Down Expand Up @@ -299,8 +280,6 @@ public String toString() {
sb.append(", hasConsumes=").append(hasConsumes);
sb.append(", hasProduces=").append(hasProduces);
sb.append(", hasParams=").append(hasParams);
sb.append(", hasOptionalParams=").append(hasOptionalParams);
sb.append(", hasRequiredParams=").append(hasRequiredParams);
sb.append(", subresourceOperation=").append(subresourceOperation);
sb.append(", isMultipart=").append(isMultipart);
sb.append(", hasDefaultResponse=").append(hasDefaultResponse);
Expand All @@ -327,7 +306,6 @@ public String toString() {
sb.append(", servers=").append(servers);
sb.append(", requestBody=").append(requestBody);
sb.append(", allParams=").append(allParams);
sb.append(", bodyParams=").append(bodyParams);
sb.append(", pathParams=").append(pathParams);
sb.append(", queryParams=").append(queryParams);
sb.append(", headerParams=").append(headerParams);
Expand Down Expand Up @@ -364,8 +342,6 @@ public boolean equals(Object o) {
hasConsumes == that.hasConsumes &&
hasProduces == that.hasProduces &&
hasParams == that.hasParams &&
hasOptionalParams == that.hasOptionalParams &&
hasRequiredParams == that.hasRequiredParams &&
subresourceOperation == that.subresourceOperation &&
isMultipart == that.isMultipart &&
hasDefaultResponse == that.hasDefaultResponse &&
Expand All @@ -392,7 +368,6 @@ public boolean equals(Object o) {
Objects.equals(servers, that.servers) &&
Objects.equals(requestBody, that.requestBody) &&
Objects.equals(allParams, that.allParams) &&
Objects.equals(bodyParams, that.bodyParams) &&
Objects.equals(pathParams, that.pathParams) &&
Objects.equals(queryParams, that.queryParams) &&
Objects.equals(headerParams, that.headerParams) &&
Expand Down Expand Up @@ -421,13 +396,13 @@ public boolean equals(Object o) {
@Override
public int hashCode() {

return Objects.hash(hasAuthMethods, hasConsumes, hasProduces, hasParams, hasOptionalParams,
hasRequiredParams, subresourceOperation,
return Objects.hash(hasAuthMethods, hasConsumes, hasProduces, hasParams,
subresourceOperation,
isMultipart,
hasDefaultResponse, isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy,
isRestful, isDeprecated, isCallbackRequest, uniqueItems, path, operationId, httpMethod,
summary, unescapedNotes, notes, baseName, defaultResponse,
consumes, produces, prioritizedContentTypes, servers, requestBody, allParams, bodyParams,
consumes, produces, prioritizedContentTypes, servers, requestBody, allParams,
pathParams, queryParams, headerParams, cookieParams, requiredParams, optionalParams,
authMethods, tags, responses, callbacks, imports, examples, requestBodyExamples, externalDocs,
vendorExtensions, nickname, operationIdOriginal, operationIdLowerCase, operationIdCamelCase,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
public class CodegenParameter extends CodegenHeader {
public boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
isCookieParam, isBodyParam, isAllowEmptyValue, isDeepObject;
// stores the openapi name property
public String baseName;

public CodegenParameter copy() {
CodegenParameter output = new CodegenParameter();
output.baseName = this.baseName;
output.paramName = this.paramName;
output.description = this.description;
output.unescapedDescription = this.unescapedDescription;
output.isFormParam = this.isFormParam;
Expand All @@ -45,6 +45,9 @@ public CodegenParameter copy() {
output.jsonSchema = this.jsonSchema;
output.example = this.example;

if (this.name != null) {
output.name = this.name;
}
if (this.content != null) {
output.setContent(this.content);
}
Expand Down Expand Up @@ -77,7 +80,7 @@ public CodegenParameter copy() {

@Override
public int hashCode() {
return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isExplode, baseName, paramName, description, unescapedDescription, style, isDeepObject, isAllowEmptyValue, example, jsonSchema, vendorExtensions, isDeprecated, required, hasMultipleTypes, schema, content, ref, refModule, imports, componentModule);
return Objects.hash(name, isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isExplode, baseName, description, unescapedDescription, style, isDeepObject, isAllowEmptyValue, example, jsonSchema, vendorExtensions, isDeprecated, required, schema, content, ref, refModule, imports, componentModule);
}

@Override
Expand Down
Loading