preface
Dev suddenly said Swagger wouldn’t open, and I went to check
To tell the truth, this mistake is really weak to ridicule, Swagger in addition to the problem of 80% are such pages
Problem Solving Ideas
1. Version problems?
Recently, in order to facilitate the management of maven version, the project removed the dependencies of other projects in the group to manage the version. However, to ensure the consistency of the version, some versions of the project depend on the version of other projects in the group.
By means of aggregation Because the project version used the version management of the group, the group used the 2.x version, but for some reasons, the 3.0 version was selected, SO I went to have a look, and I made version suppression (Inconsistent versions do have this problem), eliminate
2. Swagger configuration problem?
For example, if you want to configure the swagger in 3.0, you don’t need to configure @profile (“! Prod “), can pass springfox. Documentation. Enabled = false can control).
3. Add a comment @enableWebMVC solution
I really solved it, but I can’t do that. It’s a bug to solve a bug. How can I do that? Why can’t you just use @enableWebMVC?
@ @ Import EnableWebMvc head (DelegatingWebMvcConfiguration. Class), DelegatingWebMvcConfiguration parent WebMvcConfigurationSupport will be injected, WebMvcAutoConfiguration this class will not take effect
4. Why add @enableWebMVC as an annotation?
There is no problem with other projects without this annotation. Request postman to see it
The resource path is /v3/api-docs
In what case, the return is empty
Now that @enableWebMVC is mentioned above, we will debug swagger’s controller and search /v3/api-docs to find the static constant and find the reference
Start debug, find the value here, more strange
5. Go back to @enableWebMVC to find the difference again
What did see WebMvcAutoConfiguration inside, see the injected WebMvcAutoConfigurationAdapter this class
See messageConvertersProvider coding decoding with what
Trace fastjson for debug to find the write method
Find writeInternal ()How do I serialize writeJSONString ()
If you want to go to the last line and look at the result, it will be {}
Then I took a look at the other projects and found that the fastjson version was completely inconsistent (because of the new version management, some of the projects did not change to the new version management). I used 1.2.60 and switched to look at it, and sure enough, it worked out
6. Fastjson how to deal with Swagger compatibility
For swagger serialization, why do we have problems with swagger serialization