Server returned HTTP response code: 406 for URL: .../api-docs/
I'm using Swagger 1.0 in my project and after switching to develop_2.0 branch in swagger-codegen I'm getting 406 not accepted message from my application, when I try to build a documentation
$ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i http://localhost:8080/MWA/api-docs/ -l html -o xxx reading from http://localhost:8080/MWA/api-docs/ java.io.IOException: Server returned HTTP response code: 406 for URL: http://localhost:8080/MWA/api-docs/
Master seems to send the following accept header:
Accept: text/html, image/gif, image/jpeg, ; q=.2, */; q=.2
And develop_2.0 sends:
Accept: application/json, application/yaml, .
@daivanov, perhaps your url is not correct, on develop_2.0 it should look like yourUrlPattern/swagger.json but not MWA/api-docs/ (e.g http://petstore.swagger.io/v2/swagger.json). Could you check this?
I'm using swagger 1.0 on server side and swagger-codegen should be using compatibility converter to access old URL, because new URL doesn't exist on my server.
@webron, Accepted media types are set in swagger-parser https://github.com/swagger-api/swagger-parser/blob/develop/modules/swagger-parser/src/main/java/io/swagger/parser/util/RemoteUrl.java#L84. And I'm not sure what . means. If all media types is implied it should be /. And I'm not sure all media types are suitable here. What's your opinion?
@lugaru1234 - I don't really follow your question..
@webron, As you can see from https://github.com/swagger-api/swagger-parser/blob/develop/modules/swagger-parser/src/main/java/io/swagger/parser/util/RemoteUrl.java#L84 we append '.' to the accept header according to tne RFC http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html '.' is not valid, so the server may send a 406:
If an Accept header field is present, and if the server cannot send a response which is acceptable according to the combined Accept field value, then the server SHOULD send a 406 (not acceptable) response.
Right, it looks like the intent was to send */*and not *.*.