79168083

Date: 2024-11-07 21:13:45
Score: 0.5
Natty:
Report link

@tatka I faced the similar issue. Please make sure that http://localhost:8080/v3/api-docs/swagger-config returns Json response similar to the following:

{"configUrl":"/v3/api-docs/swagger-config","oauth2RedirectUrl":"http://localhost:8080/swagger-ui/oauth2-redirect.html","url":"/v3/api-docs"}

In my case, the Json response was as follows:

{
  "Map" : {
    "configUrl" : "/v3/api-docs/swagger-config",
    "oauth2RedirectUrl" : "http://localhost:8080/swagger-ui/oauth2-redirect.html",
    "url" : "/v3/api-docs"
  }
}

I got the above Json response because in my SpringBoot app I was forcing all Json responses to be wrapped (to satisfy project requirements):

@Primary // Spring will use this @Primary objMapper while seriliazing & deserilizing the json reqs

@Bean("dfltRespObjMapper") // received and responses sent from this app
    public ObjectMapper dfltReqRespObjMapper() {

        return new Jackson2ObjectMapperBuilder().featuresToEnable(
                SerializationFeature.WRAP_ROOT_VALUE).build();

I removed featuresToEnable( SerializationFeature.WRAP_ROOT_VALUE) from the default objectMapper. After that the default scheme was set correctly in Swagger to the url /v3/api-docs/ by default. This in turn resolved the error "No API definition provided."

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @tatka
  • User mentioned (0): @Primary
  • User mentioned (0): @Primary
  • Low reputation (1):
Posted by: Pravin Jose