OpenAPITools / OpenAPITools/openapi-generator

[REQ] How to Support with spring boot ResponseBodyAdvice

Open
#19,338 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

@RestController("/hello")
public class HelloController {

@GetMapping
public String sayHello() {
return "hello";
}

}

And we used 'ResponseVO' generic class as unified response body like the following

public class ResponseVO {
private int status;
private String errorMessage;
private Object data;
}

After send GET HTTP request, it returns the following response
{
"status": 200,
"data": "hello"
}

But when use openapi-generator generate rest client api, it will generate
String sayHello();

When request with generated client api, it will complain can NOT parse String from json object.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the HelloController, ResponseVO shape, and generated String sayHello() entry point described in the issue. Compare the declared response model with the JSON returned by the server, then inspect the generator path responsible for response types. Done means the generated client and the documented response shape agree and the returned object can be parsed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring-boot
Domain
api, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.