Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The value of Content-Type is prioritized to be obtained from the consumes field of the RequestMapping series of annotations. #443

Merged
merged 8 commits into from
Mar 3, 2023

Conversation

ZhReimu
Copy link
Contributor

@ZhReimu ZhReimu commented Mar 1, 2023

Fixed #424 and #369
For the following test cases:

@RestController
@RequestMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
public class TestController {

    @PostMapping(value = "/test", consumes = MediaType.TEXT_PLAIN_VALUE)
    public String test(@RequestBody String test) {
        return "asd";
    }

    @PostMapping("/test2")
    public String test2(@RequestBody String test) {
        return "asd";
    }

    @GetMapping("/test3")
    public String test3(String test) {
        return "asd";
    }

}

The following output can be obtained:

Version Update Time Status Author Description
v2023-03-01 12:33:20 2023-03-01 12:33:20 auto @xxx Created by smart-doc

URL: http://127.0.0.1:8899/test

Type: POST

Author: : xxx

Content-Type: text/plain

Description:

Body-parameters:

Parameter Type Required Description Since
test string false No comments found. -

Request-example:

curl -X POST -H 'Content-Type: text/plain' -i http://127.0.0.1:8899/test --data 'rrqt52'

Response-example:

string

URL: http://127.0.0.1:8899/test2

Type: POST

Author: : xxx

Content-Type: application/json

Description:

Body-parameters:

Parameter Type Required Description Since
test string false No comments found. -

Request-example:

curl -X POST -H 'Content-Type: application/json' -i http://127.0.0.1:8899/test2 --data 'jwy8ml'

Response-example:

string

URL: http://127.0.0.1:8899/test3

Type: GET

Author: : xxx

Content-Type: application/json

Description:

Query-parameters:

Parameter Type Required Description Since
test string false No comments found. -

Request-example:

curl -X GET -H 'Content-Type: application/json' -i http://127.0.0.1:8899/test3?test=avg4mb

Response-example:

string

ZhReimu added 2 commits March 1, 2023 09:17
Signed-off-by: 博麗靈夢 <1725338233@qq.com>
Signed-off-by: zhReimu <1725338233@qq.com>
Signed-off-by: zhReimu <1725338233@qq.com>
ZhReimu added 4 commits March 1, 2023 17:47
使用 MappingAnnotation#consumesProp 替代

Signed-off-by: 博麗靈夢 <1725338233@qq.com>
Signed-off-by: zhReimu <1725338233@qq.com>
Signed-off-by: zhReimu <1725338233@qq.com>
@shalousun
Copy link
Collaborator

shalousun commented Mar 3, 2023

Click "resolve" on the places that have been modified.

ZhReimu added 2 commits March 3, 2023 14:30
Signed-off-by: zhReimu <1725338233@qq.com>
Signed-off-by: zhReimu <1725338233@qq.com>
@shalousun shalousun added this to the 2.6.6 milestone Mar 3, 2023
@shalousun shalousun merged commit 00f53a8 into TongchengOpenSource:master Mar 3, 2023
@shalousun
Copy link
Collaborator

#424
#369

@shalousun shalousun changed the title Content-Type 的取值 优先从 RequestMapping 系列注解的 consumes 字段获取 The value of Content-Type is prioritized to be obtained from the consumes field of the RequestMapping series of annotations. Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SpringBoot Get Content-Type From RequestMapping.
2 participants