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

v2 generate component request body modules #89

Merged
merged 18 commits into from
Nov 25, 2022
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.oas.models.servers.ServerVariable;
Expand Down Expand Up @@ -79,8 +80,14 @@ public interface CodegenConfig {

String modelDocFileFolder();

String requestBodyDocFileFolder();

String modelPackage();

String packageName();

String requestBodyFileFolder();

String toApiName(String name);

String toApiVarName(String name);
Expand Down Expand Up @@ -151,6 +158,10 @@ public interface CodegenConfig {

Map<String, String> modelTemplateFiles();

Map<String, String> requestBodyTemplateFiles();

Map<String, String> requestBodyDocTemplateFiles();

Map<String, String> apiTestTemplateFiles();

Map<String, String> modelTestTemplateFiles();
Expand All @@ -177,6 +188,8 @@ public interface CodegenConfig {

String toModelFilename(String name);

String toModuleFilename(String name);

String toApiTestFilename(String name);

String toModelTestFilename(String name);
Expand All @@ -185,6 +198,10 @@ public interface CodegenConfig {

String toModelDocFilename(String name);

String toRequestBodyFilename(String componentName);

String toRequestBodyDocFilename(String componentName);

String toModelImport(String refClass);

Map<String, String> toModelImportMap(String name);
Expand Down Expand Up @@ -332,4 +349,8 @@ public interface CodegenConfig {
boolean getAddSuffixToDuplicateOperationNicknames();

String toRefClass(String ref, String sourceJsonPath);

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

String getBodyParameterName(CodegenOperation co);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class CodegenConstants {
// NOTE: We may want to move these to a separate class to avoid confusion or modification.
public static final String APIS = "apis";
public static final String MODELS = "models";

public static final String REQUEST_BODIES = "requestBodies";
public static final String REQUEST_BODY_DOCS = "requestBodyDocs";
public static final String SUPPORTING_FILES = "supportingFiles";
public static final String MODEL_TESTS = "modelTests";
public static final String MODEL_DOCS = "modelDocs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class CodegenParameter {
private String ref;
private String refModule;

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

public CodegenParameter copy() {
CodegenParameter output = new CodegenParameter();
output.baseName = this.baseName;
Expand Down Expand Up @@ -79,6 +81,9 @@ public CodegenParameter copy() {
if (this.refModule != null) {
output.setRefModule(this.refModule);
}
if (this.imports != null) {
output.imports = imports;
}
output.isDeprecated = this.isDeprecated;
output.isExplode = this.isExplode;
output.style = this.style;
Expand All @@ -90,7 +95,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);
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);
}

@Override
Expand All @@ -108,6 +113,7 @@ public boolean equals(Object o) {
isDeprecated == that.isDeprecated &&
required == that.required &&
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()) &&
Expand Down Expand Up @@ -150,6 +156,7 @@ public String toString() {
sb.append(", content=").append(content);
sb.append(", ref=").append(ref);
sb.append(", refModule=").append(refModule);
sb.append(", imports=").append(imports);
sb.append('}');
return sb.toString();
}
Expand Down
Loading