Add `@Consume(content-type)` to all REST services class or methods
@chickenchickenlove is already working on this.
Since Jul 18, 2024.
- Dominant language
- Java
- Stars
- 668
- Forks
- 135
- Avg merge
- 4d 19h
- Merged PRs (30d)
- 7
Description
All Central Dogma APIs use JSON (Patch) to exchange data. A Central Dogma server can't handle other types such as XML or YAML.
Currently, the request `content-type` is not specified in some API methods.
https://github.com/line/centraldogma/blob/24603eb149d3945fde2cc1ced71a9efdcbc231fe/server/src/main/java/com/linecorp/centraldogma/server/internal/api/ContentServiceV1.java#L187-L191
That results in generating a converter not found error message if `content-type` is missing.
For example, a commit is sent without `content-type`, `No suitable request converter` is returned from which users don't know what is wrong.
```sh
$ curl -XPOST "http://127.0.0.1:36462/api/v1/projects/foo/repos/bar/contents" \
-H "Authorization: Bearer appToken-***" \
-d '{
"commitMessage" : {
"summary": "hello",
"detail": "a",
"markup": "MARKDOWN"
},
"changes" : [
{
"path" : "/foo0.json",
"type" : "UPSERT_JSON",
"content" : {"a": "bar2"}
}
]
}'
{"exception":"java.lang.IllegalArgumentException","message":"No suitable request converter found for a @RequestObject 'CommitMessageDto'"}%
```
If `@ConsumeJson` is added to the method, `405 Method Not Allowed` is returned which would make it easier to identify the cause.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.