jaxrs-analyzer icon indicating copy to clipboard operation
jaxrs-analyzer copied to clipboard

Return values not generated correctly on annotated interfaces

Open fcav1973 opened this issue 7 years ago • 2 comments

If JAX-RS annotations are put on an interface instead of a concrete class, response types are not generated correctly:

Es. the following interface:

package com.primeur.test.resources;

import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.APPLICATION_XML;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

@Path("/basepath")
public interface RestService {

	@GET
	@Path("/value")
	@Produces({ APPLICATION_JSON, APPLICATION_XML })
	public int getValue();

	@GET
	@Path("/strvalue")
	@Produces({ APPLICATION_JSON, APPLICATION_XML })
	public String getStrValue();

}

Leads to the following json output:

REST resources of project:
0.1-SNAPSHOT

GET rootpath/basepath/strvalue:
 Request:
  No body

 Response:
  Content-Type: application/json, application/xml
  Status Codes: 204


GET rootpath/basepath/value:
 Request:
  No body

 Response:
  Content-Type: application/json, application/xml
  Status Codes: 204

fcav1973 avatar Jun 09 '17 16:06 fcav1973

I'm hitting this as well. It seems like it might be limited to interfaces that are actually implement.

I have some annotated interfaces for requests where I'm the client, and so I'm letting the framework implement them for me, and those don't have this problem.

tringenbach avatar Jun 19 '17 15:06 tringenbach

Actually, I was mistaken, I don't have responses for the APIs I consume either. Just the 204.

tringenbach avatar Jun 19 '17 17:06 tringenbach