Forum Discussion

soaraujo's avatar
soaraujo
New Contributor
3 years ago

How to force swagger.json file to be generated using UTF-8?

Hello guys. That's my first time here, so let's go direrecty to the point...

 

I'm trying to implement WSO2 for an API that will be publically opened, and one of its prerequisites is to use Swagger to documment it. For that point, we used annotations like @SwaggerDefinition,@Api, @ApiResponses, @ApiParam, etc.

 

The "swagger.json" file has been generated, BUT the encode is always ANSI and not UTF-8, as I expected and desired! Our native language is portuguese, so we use accents for many letters. I tried to change configurations, but failed... I tried to use "produces = { "application/json; charset=utf-8" }" on @SwaggerDefinition, but nothing changes. I tried to use Unicode characters in strings with accents, but it didn't work either (like this): 

 

@ApiResponse(code = 404, message = "Nenhum item financi\u00e1vel encontrado")

 

I thought about convert strings to utf-8, but it is not possible, due to syntax of annotation parameters... Example:

@ApiResponse(code = 404, message = convertToUtf8("Nenhum item financiável encontrado")

 

It is not possible to do that! I have to pass a constant string to message parameter... So... What can I do than? Some help?

 

 

2 Replies

  • Hi soaraujo 

     

    Could you confirm which libraries you are using for your annotations? SpringFox or Swagger-Core-Jaxrs?

    Sounds bad that it's coming out as ANSI instead of UTF-8, it might be a configuration issue on the library.

     

    Josh

     

    • soaraujo's avatar
      soaraujo
      New Contributor

      Hi Josh!

       

      I'm using Swagger-Core-JaxRS... Last version, 1.6.5