From 50e284807df5cf2420c9c5b3212943bacca11b3c Mon Sep 17 00:00:00 2001 From: linwumingshi Date: Sat, 18 Oct 2025 19:51:02 +0800 Subject: [PATCH] fix: :bug: correct media type handling for `@DeleteMapping` with `@RequestBody` - CLOSE ISSUE #1133 - Remove redundant DELETE method check in bodyMediaType logic, which caused incorrect OpenAPI spec generation when `@DeleteMapping` is used with `@RequestBody` - Simplify query parameter handling by removing unnecessary DELETE-specific condition - Update copyright year from 2024 to 2025 in affected files --- src/main/java/com/ly/doc/template/IRestDocTemplate.java | 5 ++--- .../java/com/ly/doc/template/SpringBootDocBuildTemplate.java | 2 +- src/main/java/com/ly/doc/utils/ApiParamTreeUtil.java | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/ly/doc/template/IRestDocTemplate.java b/src/main/java/com/ly/doc/template/IRestDocTemplate.java index 881f0f4d5..d4c4b0c56 100644 --- a/src/main/java/com/ly/doc/template/IRestDocTemplate.java +++ b/src/main/java/com/ly/doc/template/IRestDocTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 smart-doc + * Copyright (C) 2018-2025 smart-doc * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -1110,8 +1110,7 @@ else if (frameworkAnnotations.getRequestPartAnnotation() required = Boolean.parseBoolean(strRequired); } // not get and delete method and has MediaType - boolean bodyMediaType = !(Methods.GET.getValue().equals(docJavaMethod.getMethodType()) - || Methods.DELETE.getValue().equals(docJavaMethod.getMethodType())) + boolean bodyMediaType = !Methods.GET.getValue().equals(docJavaMethod.getMethodType()) && StringUtil.isNotEmpty(methodMediaType) && (MediaType.APPLICATION_FORM_URLENCODED_VALUE.equals(methodMediaType) || MediaType.APPLICATION_JSON_VALUE.equals(methodMediaType) diff --git a/src/main/java/com/ly/doc/template/SpringBootDocBuildTemplate.java b/src/main/java/com/ly/doc/template/SpringBootDocBuildTemplate.java index 04cdd1f24..4a8dbb9f1 100644 --- a/src/main/java/com/ly/doc/template/SpringBootDocBuildTemplate.java +++ b/src/main/java/com/ly/doc/template/SpringBootDocBuildTemplate.java @@ -163,7 +163,7 @@ public FrameworkAnnotations registeredAnnotations() { annotations.setServerEndpointAnnotation(serverEndpointAnnotation); // add mapping annotations - Map mappingAnnotations = buildSpringMappingAnnotations(); + Map mappingAnnotations = this.buildSpringMappingAnnotations(); annotations.setMappingAnnotations(mappingAnnotations); // Exception advice annotations diff --git a/src/main/java/com/ly/doc/utils/ApiParamTreeUtil.java b/src/main/java/com/ly/doc/utils/ApiParamTreeUtil.java index 38b578ecc..fe769cca0 100644 --- a/src/main/java/com/ly/doc/utils/ApiParamTreeUtil.java +++ b/src/main/java/com/ly/doc/utils/ApiParamTreeUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 smart-doc + * Copyright (C) 2018-2025 smart-doc * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -129,8 +129,7 @@ public static ApiMethodReqParam buildMethodReqParam(List paramList, param.setId(pathParams.size() + 1); pathParams.add(param); } - else if (param.isQueryParam() || Methods.GET.getValue().equals(methodType) - || Methods.DELETE.getValue().equals(methodType)) { + else if (param.isQueryParam() || Methods.GET.getValue().equals(methodType)) { if (queryReqParamMap.containsKey(param.getField())) { param.setConfigParam(true).setValue(queryReqParamMap.get(param.getField()).getValue()); }