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

Commit 227fbda

Browse files
committed
v2 generate component request body modules (#89)
* 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 * Samples regenerated * Adds imports from request_bodies * Fixes request bodies and broken tests * Adds broken code to generate request body docs * Adds templates and code to generate request body docs * Fixes complexTypePrefix * Relative links updated in request_bodies * Updates request body title headers * Endpoint docs updated * Fixes links to request body doc * Fixes input signatures in java tests * Fixes some java tests * Fixes java test * Fixes test * Fixes java tests * FIxes 2 java tests * sample regen
1 parent d054064 commit 227fbda

File tree

329 files changed

+441
-10697
lines changed

Some content is hidden

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

329 files changed

+441
-10697
lines changed

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

Lines changed: 21 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;
@@ -79,8 +80,14 @@ public interface CodegenConfig {
7980

8081
String modelDocFileFolder();
8182

83+
String requestBodyDocFileFolder();
84+
8285
String modelPackage();
8386

87+
String packageName();
88+
89+
String requestBodyFileFolder();
90+
8491
String toApiName(String name);
8592

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

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

161+
Map<String, String> requestBodyTemplateFiles();
162+
163+
Map<String, String> requestBodyDocTemplateFiles();
164+
154165
Map<String, String> apiTestTemplateFiles();
155166

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

178189
String toModelFilename(String name);
179190

191+
String toModuleFilename(String name);
192+
180193
String toApiTestFilename(String name);
181194

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

186199
String toModelDocFilename(String name);
187200

201+
String toRequestBodyFilename(String componentName);
202+
203+
String toRequestBodyDocFilename(String componentName);
204+
188205
String toModelImport(String refClass);
189206

190207
Map<String, String> toModelImportMap(String name);
@@ -332,4 +349,8 @@ public interface CodegenConfig {
332349
boolean getAddSuffixToDuplicateOperationNicknames();
333350

334351
String toRefClass(String ref, String sourceJsonPath);
352+
353+
CodegenParameter fromRequestBody(RequestBody body, String bodyParameterName, String sourceJsonPath);
354+
355+
String getBodyParameterName(CodegenOperation co);
335356
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ 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";
30+
public static final String REQUEST_BODY_DOCS = "requestBodyDocs";
2831
public static final String SUPPORTING_FILES = "supportingFiles";
2932
public static final String MODEL_TESTS = "modelTests";
3033
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)