Skip to content

SmallRye OpenAPI outputs Chinese garbled characters in Json #44569

@MorganMaohong

Description

@MorganMaohong

Description

I downloaded a template project from the official website, added the SmallRey OpenAPI extension, added the @tag annotation to the Rest class, and used Chinese. When I accessed /q/openapi, the response was in garbled format. I guessed that the project was in UTF-8 format. Finally, I tried all the places where I could set the encoding format to UTF-8, but it still didn't match the Chinese display.
Implementation ideas
If you have any implementation ideas, they can go here, however please note that all design change proposals should be posted to the Quarkus developer mailing list (or the corresponding Google Group; see the decisions process document for more information. However, it is normal for the REST request response result to be displayed in Chinese.

@Path("/hello")
@Tag(name = "测试模块")
public class ExampleResource {
    private static final Logger log = LoggerFactory.getLogger(ExampleResource.class);
    @Inject
    EntityManager entityManager;

    @POST
    @Path("/1")
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        String s = new String("".getBytes(StandardCharsets.UTF_8));
        List<User> result = entityManager.createQuery("select e from User e", User.class).getResultList();
        log.info("{}", result);
        return "success哈哈哈哈";
    }
}

Implementation ideas

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions