[ofbiz-plugins] branch trunk updated: Improved: Return 400 when 'inParams' query parameter is missing Fixed: Corrected service request in schema location referrence in OpenAPI schema file(OFBIZ-11328).

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-plugins] branch trunk updated: Improved: Return 400 when 'inParams' query parameter is missing Fixed: Corrected service request in schema location referrence in OpenAPI schema file(OFBIZ-11328).

grv-2
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 72458a1  Improved: Return 400 when 'inParams' query parameter is missing Fixed: Corrected service request in schema location referrence in OpenAPI schema file(OFBIZ-11328).
72458a1 is described below

commit 72458a1ef2fd1e5b7c1694e76fece049aecfb0a4
Author: Girish Vasmatkar <[hidden email]>
AuthorDate: Mon Sep 7 16:13:00 2020 +0530

    Improved: Return 400 when 'inParams' query parameter is missing
    Fixed: Corrected service request in schema location referrence in OpenAPI schema file(OFBIZ-11328).
---
 .../main/java/org/apache/ofbiz/ws/rs/openapi/OFBizOpenApiReader.java  | 2 +-
 .../java/org/apache/ofbiz/ws/rs/resources/OFBizServiceResource.java   | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/ofbiz-rest-impl/src/main/java/org/apache/ofbiz/ws/rs/openapi/OFBizOpenApiReader.java b/ofbiz-rest-impl/src/main/java/org/apache/ofbiz/ws/rs/openapi/OFBizOpenApiReader.java
index c656e3b..47c3fed 100644
--- a/ofbiz-rest-impl/src/main/java/org/apache/ofbiz/ws/rs/openapi/OFBizOpenApiReader.java
+++ b/ofbiz-rest-impl/src/main/java/org/apache/ofbiz/ws/rs/openapi/OFBizOpenApiReader.java
@@ -131,7 +131,7 @@ public final class OFBizOpenApiReader extends Reader implements OpenApiReader {
                 } else if (service.getAction().equalsIgnoreCase(HttpMethod.POST)) {
                     RequestBody request = new RequestBody().description("Request Body for service " + service.getName())
                             .content(new Content().addMediaType(javax.ws.rs.core.MediaType.APPLICATION_JSON,
-                                    new MediaType().schema(new Schema<>().$ref(service.getName() + "Request"))));
+                                    new MediaType().schema(new Schema<>().$ref("#/components/schemas/" + "api.request." + service.getName()))));
                     operation.setRequestBody(request);
                 }
                 addServiceOutSchema(service);
diff --git a/ofbiz-rest-impl/src/main/java/org/apache/ofbiz/ws/rs/resources/OFBizServiceResource.java b/ofbiz-rest-impl/src/main/java/org/apache/ofbiz/ws/rs/resources/OFBizServiceResource.java
index c51887c..5a58610 100644
--- a/ofbiz-rest-impl/src/main/java/org/apache/ofbiz/ws/rs/resources/OFBizServiceResource.java
+++ b/ofbiz-rest-impl/src/main/java/org/apache/ofbiz/ws/rs/resources/OFBizServiceResource.java
@@ -27,6 +27,7 @@ import java.util.Map;
 import java.util.Set;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.BadRequestException;
 import javax.ws.rs.GET;
 import javax.ws.rs.HttpMethod;
 import javax.ws.rs.POST;
@@ -105,6 +106,9 @@ public class OFBizServiceResource extends OFBizResource {
     @Secured
     public Response invokeServiceByGet(@QueryParam(value = "inParams") ApiServiceRequest serviceRequest,
                                        @PathParam(value = "serviceName") String serviceName) throws IOException, GenericServiceException {
+        if (UtilValidate.isEmpty(serviceRequest) || UtilValidate.isEmpty(serviceRequest.getInParams())) {
+            throw new BadRequestException("Missing Parameter: 'inParams'");
+        }
         ServiceRequestProcessor processor = new ServiceRequestProcessor();
         return processor.process(
                 UtilMisc.toMap("serviceName", serviceName, "httpVerb", HttpMethod.GET, "requestMap", serviceRequest.getInParams(), "dispatcher",