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/09/30 17:09:04 UTC
[ofbiz-plugins] branch trunk updated: Improved: Added Method Not
Allowed API response for service resource openapi(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 3b66ae1 Improved: Added Method Not Allowed API response for service resource openapi(OFBIZ-11328)
3b66ae1 is described below
commit 3b66ae1abe2ff7b94a21c6c3098757b45d9d44ec
Author: Girish Vasmatkar <gi...@hotwaxsystems.com>
AuthorDate: Wed Sep 30 22:38:44 2020 +0530
Improved: Added Method Not Allowed API response for service resource openapi(OFBIZ-11328)
---
.../main/java/org/apache/ofbiz/ws/rs/util/OpenApiUtil.java | 12 ++++++++++++
1 file changed, 12 insertions(+)
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 b0dd0e1..ebf50b0 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
@@ -167,6 +167,7 @@ public final class OpenApiUtil {
SCHEMAS.put("api.response.forbidden", genericErrorSchema);
SCHEMAS.put("api.response.service.badrequest", genericErrorSchema);
SCHEMAS.put("api.response.service.unprocessableentity", genericErrorSchema);
+ SCHEMAS.put("api.response.service.methodnotallowed", genericErrorSchema);
}
public static Map<String, ApiResponse> getStandardApiResponses() {
@@ -197,6 +198,9 @@ public final class OpenApiUtil {
"errorType", "GenericEntityException",
"errorMessage", "createProduct execution failed. The request contained invalid information and could not be processed.",
"errorDescription", "StandardException: A truncation error was encountered trying to shrink CHAR 'string' to length 1.");
+ Map<String, Object> methodNotAllowedExample = UtilMisc.toMap("statusCode", Response.Status.METHOD_NOT_ALLOWED.getStatusCode(),
+ "statusDescription", Response.Status.METHOD_NOT_ALLOWED.getReasonPhrase(),
+ "errorMessage", "HTTP POST is not allowed on service 'demoDoGetService'.");
final ApiResponse unauthorizedNoHeader = new ApiResponse().addHeaderObject(HttpHeaders.WWW_AUTHENTICATE, new Header()
.example(HttpHeaders.WWW_AUTHENTICATE + ": "
@@ -240,12 +244,20 @@ public final class OpenApiUtil {
.schema(new Schema<>()
.$ref("#/components/schemas/" + "api.response.service.unprocessableentity"))
.example(unprocessableEntExample)));
+ final ApiResponse methodNotAllowed = new ApiResponse()
+ .description("Method Not Allowed: Service called with HTTP method other than the declared one.")
+ .content(new Content()
+ .addMediaType(javax.ws.rs.core.MediaType.APPLICATION_JSON, new MediaType()
+ .schema(new Schema<>()
+ .$ref("#/components/schemas/" + "api.response.service.methodnotallowed"))
+ .example(methodNotAllowedExample)));
RESPONSES.put(String.valueOf(Response.Status.UNAUTHORIZED.getStatusCode()), unauthorizedNoHeader);
RESPONSES.put(String.valueOf(Response.Status.UNAUTHORIZED.getStatusCode()), unauthorizedInvalidToken);
RESPONSES.put(String.valueOf(Response.Status.FORBIDDEN.getStatusCode()), forbidden);
RESPONSES.put(String.valueOf(Response.Status.BAD_REQUEST.getStatusCode()), badRequest);
RESPONSES.put(String.valueOf(ResponseStatus.Custom.UNPROCESSABLE_ENTITY.getStatusCode()), unprocessableEntity);
+ RESPONSES.put(String.valueOf(Response.Status.METHOD_NOT_ALLOWED.getStatusCode()), methodNotAllowed);
}
public static Class<?> getOpenApiTypeForAttributeType(String attributeType) {