java - Swagger-UI doesn't recognize application/hal+json -
The Sokhst API I have spring boot application I when I was trying to add custom media-types, then I was trying to figure out a different problem.
After trying to do this, I found an exception to HTTP Media Type Not Accessible
while trying to view my code document. This exception appears only in the log (if I change the level to debug / />) On the browser I see
406 undefined
. Here's a screenshot:
the exception I get it from logs spring boot:
2014-11-04 10: 08: 26.189 debug 5496 --- [NIO-8080- executive -9] .wsmsDefaultHandlerExceptionResolver: exception Handler being resolved [public org.springframework.http.ResponseEntity & lt; Com.wordnik.swagger.model.ResourceListing & gt; com.mangofactory.swagger.controllers.DefaultSwaggerController.getResourceListing (java.lang.String)]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable represents
The root of the problem
application / * + json; Charset = UTF-8
. With my changes, the list includes only application / hal + json
and my custom media-type while http header: : So what happens is that spring is not a compatible media type exactly because swagger UI
application / json
has been accepted in its // local host: 8080 / api-docs < / Code> vends
application / hal + json
(I verified using Curl):
HTTP / 1.1 200 OK Server: Apache-Coyote / 1.1.1 X-content Re-type options: nosniff X-XSS- protection: 1; Mode = block Cache-Control: no-cache, no-store, max-age = 0, must-certified Pragma: no-cache expires: 0 X-Frame-Options: Danny X-application-context: application content-type: application / hal + json transfer-encoding: chunked Date: Tue, 04 Nvanbr 2014 16:56:57 GMT
My guess is that Swagger UI probably Application / Jason, App / Halo + Jason
Security may use a wildcard such as application / * + json
.
The current solution would be to update the swagger-client.js - he has made part where SwaggerClient, it There is a hard code with application / Jason as Mum type.
Existing code off code though it can clearly change in different versions (hence it can not be relevant in future when reading this answer). / P>
swagger-client.js is present in two places - under / lib / dir for / dl / lib dir for pre-built applications or directly for the build process. You should change the price depending on what you are using.
Comments
Post a Comment