|
16 | 16 | import io.swagger.codegen.v3.CodegenProperty;
|
17 | 17 | import io.swagger.codegen.v3.CodegenResponse;
|
18 | 18 | import io.swagger.codegen.v3.CodegenSecurity;
|
| 19 | +import io.swagger.codegen.v3.ISchemaHandler; |
19 | 20 | import io.swagger.codegen.v3.SupportingFile;
|
20 | 21 | import io.swagger.codegen.v3.generators.examples.ExampleGenerator;
|
21 | 22 | import io.swagger.codegen.v3.generators.handlebars.BaseItemsHelper;
|
@@ -160,7 +161,6 @@ public abstract class DefaultCodegenConfig implements CodegenConfig {
|
160 | 161 | protected String httpUserAgent;
|
161 | 162 | protected Boolean hideGenerationTimestamp = true;
|
162 | 163 | protected TemplateEngine templateEngine = new HandlebarTemplateEngine(this);
|
163 |
| - protected SchemaHandler schemaHandler = new SchemaHandler(this); |
164 | 164 | // How to encode special characters like $
|
165 | 165 | // They are translated to words like "Dollar" and prefixed with '
|
166 | 166 | // Then translated back during JSON encoding and decoding
|
@@ -267,28 +267,6 @@ public Map<String, Object> postProcessAllModels(Map<String, Object> processedMod
|
267 | 267 | if (supportsInheritance) {
|
268 | 268 | processCodegenModels(allModels);
|
269 | 269 | }
|
270 |
| - for (String modelName : allModels.keySet()) { |
271 |
| - final CodegenModel codegenModel = allModels.get(modelName); |
272 |
| - if (!codegenModel.vendorExtensions.containsKey("x-is-composed-model")) { |
273 |
| - continue; |
274 |
| - } |
275 |
| - List<String> modelNames = (List<String>) codegenModel.vendorExtensions.get("x-model-names"); |
276 |
| - if (modelNames == null || modelNames.isEmpty()) { |
277 |
| - continue; |
278 |
| - } |
279 |
| - for (String name : modelNames) { |
280 |
| - final CodegenModel model = allModels.get(name); |
281 |
| - if (model == null) { |
282 |
| - continue; |
283 |
| - } |
284 |
| - if (model.interfaceModels == null) { |
285 |
| - model.interfaceModels = new ArrayList<>(); |
286 |
| - } |
287 |
| - if (!model.interfaceModels.stream().anyMatch(value -> value.name.equalsIgnoreCase(modelName))) { |
288 |
| - model.interfaceModels.add(codegenModel); |
289 |
| - } |
290 |
| - } |
291 |
| - } |
292 | 270 | return processedModels;
|
293 | 271 | }
|
294 | 272 |
|
@@ -1299,12 +1277,6 @@ public CodegenModel fromModel(String name, Schema schema, Map<String, Schema> al
|
1299 | 1277 | if (schema instanceof ArraySchema) {
|
1300 | 1278 | codegenModel.getVendorExtensions().put(IS_ARRAY_MODEL_EXT_NAME, Boolean.TRUE);
|
1301 | 1279 | codegenModel.getVendorExtensions().put(IS_CONTAINER_EXT_NAME, Boolean.TRUE);
|
1302 |
| - |
1303 |
| - final Schema items = ((ArraySchema) schema).getItems(); |
1304 |
| - if (items != null && items instanceof ComposedSchema) { |
1305 |
| - schemaHandler.configureComposedModelFromSchemaItems(codegenModel, ((ComposedSchema) items)); |
1306 |
| - } |
1307 |
| - |
1308 | 1280 | codegenModel.arrayModelType = fromProperty(name, schema).complexType;
|
1309 | 1281 | addParentContainer(codegenModel, name, schema);
|
1310 | 1282 | }
|
@@ -1357,11 +1329,7 @@ else if (schema instanceof ComposedSchema) {
|
1357 | 1329 | // parent model
|
1358 | 1330 | final String parentName = getParentName(composed);
|
1359 | 1331 | final Schema parent = StringUtils.isBlank(parentName) ? null : allDefinitions.get(parentName);
|
1360 |
| - |
1361 | 1332 | final List<Schema> allOf = composed.getAllOf();
|
1362 |
| - final List<Schema> oneOf = composed.getOneOf(); |
1363 |
| - final List<Schema> anyOf = composed.getAnyOf(); |
1364 |
| - |
1365 | 1333 | // interfaces (intermediate models)
|
1366 | 1334 | if (allOf != null && !allOf.isEmpty()) {
|
1367 | 1335 | for (int i = 0; i < allOf.size(); i++) {
|
@@ -1389,14 +1357,6 @@ else if (schema instanceof ComposedSchema) {
|
1389 | 1357 | }
|
1390 | 1358 | }
|
1391 | 1359 | }
|
1392 |
| - if (oneOf != null && !oneOf.isEmpty()) { |
1393 |
| - codegenModel.dataType = getSchemaType(composed); |
1394 |
| - this.schemaHandler.configureOneOfModel(codegenModel, oneOf); |
1395 |
| - } |
1396 |
| - if (anyOf != null && !anyOf.isEmpty()) { |
1397 |
| - codegenModel.dataType = getSchemaType(composed); |
1398 |
| - this.schemaHandler.configureAnyOfModel(codegenModel, anyOf); |
1399 |
| - } |
1400 | 1360 | if (parent != null) {
|
1401 | 1361 | codegenModel.parentSchema = parentName;
|
1402 | 1362 | codegenModel.parent = toModelName(parentName);
|
@@ -1704,9 +1664,6 @@ public CodegenProperty fromProperty(String name, Schema propertySchema) {
|
1704 | 1664 | // handle inner property
|
1705 | 1665 | CodegenProperty cp = fromProperty("inner", (Schema) propertySchema.getAdditionalProperties());
|
1706 | 1666 | updatePropertyForMap(codegenProperty, cp);
|
1707 |
| - } else if (propertySchema instanceof ComposedSchema) { |
1708 |
| - ComposedSchema composedProperty = (ComposedSchema) propertySchema; |
1709 |
| - this.schemaHandler.createCodegenModel(composedProperty, codegenProperty); |
1710 | 1667 | } else if (propertySchema instanceof MapSchema && hasTrueAdditionalProperties(propertySchema)) {
|
1711 | 1668 |
|
1712 | 1669 | codegenProperty.getVendorExtensions().put(CodegenConstants.IS_CONTAINER_EXT_NAME, Boolean.TRUE);
|
@@ -3084,14 +3041,6 @@ private void addVars(CodegenModel codegenModel, List<CodegenProperty> vars, Map<
|
3084 | 3041 | final CodegenProperty codegenProperty = fromProperty(key, propertySchema);
|
3085 | 3042 | codegenProperty.required = mandatory.contains(key);
|
3086 | 3043 |
|
3087 |
| - if (codegenProperty.vendorExtensions.containsKey("oneOf-model")) { |
3088 |
| - this.schemaHandler.configureOneOfModelFromProperty(codegenProperty, codegenModel); |
3089 |
| - } |
3090 |
| - |
3091 |
| - if (codegenProperty.vendorExtensions.containsKey("anyOf-model")) { |
3092 |
| - this.schemaHandler.configureAnyOfModelFromProperty(codegenProperty, codegenModel); |
3093 |
| - } |
3094 |
| - |
3095 | 3044 | if (propertySchema.get$ref() != null) {
|
3096 | 3045 | if (this.openAPI == null) {
|
3097 | 3046 | LOGGER.warn("open api utility object was not properly set.");
|
@@ -4284,4 +4233,8 @@ public void setIgnoreImportMapping(boolean ignoreImportMapping) {
|
4284 | 4233 | public boolean defaultIgnoreImportMappingOption() {
|
4285 | 4234 | return false;
|
4286 | 4235 | }
|
| 4236 | + |
| 4237 | + public ISchemaHandler getSchemaHandler() { |
| 4238 | + return new SchemaHandler(this); |
| 4239 | + } |
4287 | 4240 | }
|
0 commit comments