I am trying out swagger and have reached an impasse with a simple text service.
I have a Jersey 1.x service coded like this, which returns a simple string,
@Path("version")
@GET @Produces("text/plain")
public String getVersion() {
System.out.println("***** request to version");
ri = new RequestInfo(sw, uriInfo, request, requestHeaders);
return ri.appConfig.getVersion();
}
and a Swagger API object that look like this
{
"path": "/fdsnwsbeta/dataselect/1/version",
"operations": [
{
"method": "GET",
"summary": "Get handler version",
"notes": "<p>The <strong>version</strong> service provides the version number of the handler as described in the dataselect service cfg file ",
"produces": [
"text/plain"
],
"nickname": "getHandlerVersion",
"authorizations": {},
"parameters": [],
"responseMessages": [
{
"code": 500,
"message": "Internal Server Error"
}
]
}
]
}
when I run this, I get a 406,
when I viewed the headers in chrome, I see Accept:application/json on the request header
so then I changed a similar service to @GET @Produces({"text/plain","application/json"})
and output a simple JSON string from the service
... then may swagger sample code works okay.
I am assuming the "produces" object should control the Accept contents?
else maybe there is some other issue?