Skip to content

Add @Consume(content-type) to all REST services class or methods  #987

@ikhoon

Description

@ikhoon

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.

* <p>Pushes a commit.
*/
@Post("/projects/{projectName}/repos/{repoName}/contents")
@RequiresWritePermission
public CompletableFuture<PushResultDto> push(

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.

$ 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.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions