You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by gr...@apache.org on 2020/08/31 18:03:04 UTC
[ofbiz-plugins] branch trunk updated: Fixed: Issue with service out
schema for nested attributes (OFBIZ-11328)
This is an automated email from the ASF dual-hosted git repository.
grv pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git
The following commit(s) were added to refs/heads/trunk by this push:
new fb8cae5 Fixed: Issue with service out schema for nested attributes (OFBIZ-11328)
fb8cae5 is described below
commit fb8cae5df45ae7598558034eaab68676e92f2472
Author: Girish Vasmatkar <gi...@hotwaxsystems.com>
AuthorDate: Mon Aug 31 23:32:40 2020 +0530
Fixed: Issue with service out schema for nested attributes (OFBIZ-11328)
---
.../org/apache/ofbiz/ws/rs/util/OpenApiUtil.java | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/ofbiz-rest-impl/src/main/java/org/apache/ofbiz/ws/rs/util/OpenApiUtil.java b/ofbiz-rest-impl/src/main/java/org/apache/ofbiz/ws/rs/util/OpenApiUtil.java
index c8d98f2..f48de44 100644
--- a/ofbiz-rest-impl/src/main/java/org/apache/ofbiz/ws/rs/util/OpenApiUtil.java
+++ b/ofbiz-rest-impl/src/main/java/org/apache/ofbiz/ws/rs/util/OpenApiUtil.java
@@ -38,7 +38,6 @@ import io.swagger.v3.oas.models.media.DateSchema;
import io.swagger.v3.oas.models.media.IntegerSchema;
import io.swagger.v3.oas.models.media.MapSchema;
import io.swagger.v3.oas.models.media.NumberSchema;
-import io.swagger.v3.oas.models.media.ObjectSchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema;
@@ -182,7 +181,7 @@ public final class OpenApiUtil {
List<ModelParam> children = param.getChildren();
Delegator delegator = WebAppUtil.getDelegator(ApiContextListener.getApplicationCntx());
if (schema instanceof ArraySchema) {
- ((ArraySchema) schema).setItems(getAttributeSchema(service, children.get(0)));
+ ((ArraySchema) schema).setItems(children.size() > 0 ? getAttributeSchema(service, children.get(0)) : new StringSchema());
} else if (schema instanceof MapSchema) {
if (isTypeGenericEntityOrGenericValue(param.getType())) {
if (UtilValidate.isEmpty(param.getEntityName())) {
@@ -218,24 +217,13 @@ public final class OpenApiUtil {
parentSchema.addProperties("statusCode", new IntegerSchema().description("HTTP Status Code"));
parentSchema.addProperties("statusDescription", new StringSchema().description("HTTP Status Code Description"));
parentSchema.addProperties("successMessage", new StringSchema().description("Success Message"));
- ObjectSchema dataSchema = new ObjectSchema();
+ Schema<Object> dataSchema = new Schema<Object>();
parentSchema.addProperties("data", dataSchema);
service.getOutParamNamesMap().forEach((name, type) -> {
- Schema<?> schema = null;
- Class<?> schemaClass = getOpenApiTypeForAttributeType(type);
- if (schemaClass == null) {
- return;
- }
- try {
- schema = (Schema<?>) schemaClass.newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
- e.printStackTrace();
- }
- if (schema instanceof ArraySchema) {
- ArraySchema arraySchema = (ArraySchema) schema;
- arraySchema.items(new StringSchema());
+ Schema<?> attrSchema = getAttributeSchema(service, service.getParam(name));
+ if (attrSchema != null) {
+ dataSchema.addProperties(name, getAttributeSchema(service, service.getParam(name)));
}
- dataSchema.addProperties(name, schema.description(name));
});
return parentSchema;
}