1

Migrating from springfox-swagger-ui to springdoc-openapi-ui causes the same issue described here: https://github.com/springfox/springfox/issues/2459

I faced the issue for springfox-swagger-ui too but I was able to make it work with a similar approach as described here: https://github.com/springfox/springfox/issues/2468

2 Answers2

3

I can see this question is already 2 years old but decided to post my answer here in case someone needs it.

Recently I was facing the same issue and able to make it works by adopting the solution mentioned in the link you posted.

I know the solution was supposed to be used with springfox but guess what, it works with springdoc too! You just need to instruct springdoc to use the ObjectMapper that has the ProtobufPropertiesModule registered rather than creating its own. This can be done by defining a ModelResolver bean.

You can also refer to my example here if you still don't know how to do it.

Please note that there still will be some minor issues with said solution.

For example, if you define a repeated enum field in your message, this field will show up as a list of integers in the Swagger UI. This is because this is indeed how it is represented in the generated Message class. This, in turn, can be resolved by customizing the Schema object.

EternalWind
  • 137
  • 9
  • Actually I got it from your blog post: https://eternalwind.github.io/tech/2022/05/20/Making-springdoc-openapi-works-with-protobuf.html – Dejan Pekter Jun 12 '22 at 19:29
  • 1
    @DejanPekter Glad it works for you. :) – EternalWind Jul 03 '22 at 16:05
  • @EternalWind: I am not able to find the following dependency to use the solution that you have provided. ` com.innogames springfox-protobuf ` Can you please let me know where can I find it? – Autumn May 05 '23 at 09:41
1

This is a limitation on the swagger-ui:

You can achieve the same result, by using OpenAPICustomiser, to adapt the objects in protobuf format:

  • Could you explain how to use `OpenAPICustomiser` to customize Protobuf object returned from certain endpoint? – osya Dec 26 '21 at 14:35