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

Commit 4629ce9

Browse files
committed
Stores refModule in request bodies
Adds request_bodies generation in java Response body files generated Moves imports for request body and form params into the model instance fromParameter update Consolidates fromParameter imports Fixes parameter imports Samples updated Sample regen _request_body changed to suffix
1 parent 9d59527 commit 4629ce9

File tree

287 files changed

+384
-941
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

287 files changed

+384
-941
lines changed

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenConfig.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import io.swagger.v3.oas.models.OpenAPI;
2222
import io.swagger.v3.oas.models.Operation;
2323
import io.swagger.v3.oas.models.media.Schema;
24+
import io.swagger.v3.oas.models.parameters.RequestBody;
2425
import io.swagger.v3.oas.models.security.SecurityScheme;
2526
import io.swagger.v3.oas.models.servers.Server;
2627
import io.swagger.v3.oas.models.servers.ServerVariable;
@@ -81,6 +82,12 @@ public interface CodegenConfig {
8182

8283
String modelPackage();
8384

85+
String packageName();
86+
87+
String requestBodyFileFolder();
88+
89+
String requestBodyFilename(String componentName);
90+
8491
String toApiName(String name);
8592

8693
String toApiVarName(String name);
@@ -151,6 +158,8 @@ public interface CodegenConfig {
151158

152159
Map<String, String> modelTemplateFiles();
153160

161+
Map<String, String> requestBodyTemplateFiles();
162+
154163
Map<String, String> apiTestTemplateFiles();
155164

156165
Map<String, String> modelTestTemplateFiles();
@@ -177,6 +186,8 @@ public interface CodegenConfig {
177186

178187
String toModelFilename(String name);
179188

189+
String toModuleFilename(String name);
190+
180191
String toApiTestFilename(String name);
181192

182193
String toModelTestFilename(String name);
@@ -332,4 +343,8 @@ public interface CodegenConfig {
332343
boolean getAddSuffixToDuplicateOperationNicknames();
333344

334345
String toRefClass(String ref, String sourceJsonPath);
346+
347+
CodegenParameter fromRequestBody(RequestBody body, String bodyParameterName, String sourceJsonPath);
348+
349+
String getBodyParameterName(CodegenOperation co);
335350
}

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public class CodegenConstants {
2525
// NOTE: We may want to move these to a separate class to avoid confusion or modification.
2626
public static final String APIS = "apis";
2727
public static final String MODELS = "models";
28+
29+
public static final String REQUEST_BODIES = "requestBodies";
2830
public static final String SUPPORTING_FILES = "supportingFiles";
2931
public static final String MODEL_TESTS = "modelTests";
3032
public static final String MODEL_DOCS = "modelDocs";

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public class CodegenParameter {
4848
private String ref;
4949
private String refModule;
5050

51+
public Set<String> imports = new HashSet<String>();
52+
5153
public CodegenParameter copy() {
5254
CodegenParameter output = new CodegenParameter();
5355
output.baseName = this.baseName;
@@ -79,6 +81,9 @@ public CodegenParameter copy() {
7981
if (this.refModule != null) {
8082
output.setRefModule(this.refModule);
8183
}
84+
if (this.imports != null) {
85+
output.imports = imports;
86+
}
8287
output.isDeprecated = this.isDeprecated;
8388
output.isExplode = this.isExplode;
8489
output.style = this.style;
@@ -90,7 +95,7 @@ public CodegenParameter copy() {
9095

9196
@Override
9297
public int hashCode() {
93-
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);
98+
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);
9499
}
95100

96101
@Override
@@ -108,6 +113,7 @@ public boolean equals(Object o) {
108113
isDeprecated == that.isDeprecated &&
109114
required == that.required &&
110115
Objects.equals(ref, that.getRef()) &&
116+
Objects.equals(imports, that.imports) &&
111117
Objects.equals(refModule, that.getRefModule()) &&
112118
Objects.equals(content, that.getContent()) &&
113119
Objects.equals(schema, that.getSchema()) &&
@@ -150,6 +156,7 @@ public String toString() {
150156
sb.append(", content=").append(content);
151157
sb.append(", ref=").append(ref);
152158
sb.append(", refModule=").append(refModule);
159+
sb.append(", imports=").append(imports);
153160
sb.append('}');
154161
return sb.toString();
155162
}

0 commit comments

Comments
 (0)