Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAXB definitions in dependent jar are not taken into account #36

Open
fcav1973 opened this issue Mar 22, 2017 · 6 comments
Open

JAXB definitions in dependent jar are not taken into account #36

fcav1973 opened this issue Mar 22, 2017 · 6 comments
Labels

Comments

@fcav1973
Copy link

fcav1973 commented Mar 22, 2017

In seems that when a GET method returns a JAXB annotated object, the generated swagger.json does not contains the correct description es:

... @GET @Path("/pap/{repoId}") @Produces({ APPLICATION_JSON, APPLICATION_XML }) public PolicyRepositoryInfo getPap(@PathParam("repoId") String repoId) throws SystemException, IllegalArgumentException; ...

where PolicyRepositoryInfo resides in a declared (compile) dependency jar

turns into:

... "/authorization/pap":{ "get":{ "consumes":[ ], "produces":[ "application/json", "application/xml" ], "parameters":[ ], "responses":{ "204":{ "description":"No Content", "headers":{ } } }, "tags":[ "authorization" ] }, }, ...
The same PolicyRepositoryInfo object is correctly referred when used for post requests

"post":{ "consumes":[ "application/json", "application/xml" ], "produces":[ "application/json", "application/xml" ], "parameters":[ { "name":"body", "in":"body", "required":true, "schema":{ "$ref":"#/definitions/PolicyRepositoryInfo" } } ], "responses":{ "204":{ "description":"No Content", "headers":{ } } }, "tags":[ "authorization" ] }

@fcav1973 fcav1973 changed the title JAXB definition in dependent jar are not taken into account JAXB definitions in dependent jar are not taken into account Mar 22, 2017
@sdaschner
Copy link
Owner

Normally the schema should be included in the responses object, but there is just a 204 No Content response. How does your getPap method look like? Does it actually return an object which is not null?

@fcav1973
Copy link
Author

fcav1973 commented Apr 3, 2017

Hi,
if it can help, the method is implemented in a separate jar, which his not included in the compiler class path (this because the plugin has been plugged in the API module, not the IMPL) so at generation time, non information, a part from declaration, is provided to plugin.
Anyway the implementation of the method can return null if the resource has not been found.

@sdaschner
Copy link
Owner

Ok, so if the implementation is not available to the Analyzer, then it won't get all needed information... That's probably why it falls back to the 204 response.

@fcav1973
Copy link
Author

fcav1973 commented Apr 3, 2017

Ok, thanks. The problem is that if I move the plugin execution on the implementation project, the API jar (which is a compile dependency and which has all methods and dto definitions) seems not to be taken into account, resulting in an empty output.

INFO] Generating resources at /home/fcavarretta/workspaces_new/a3server/a3server-parent-bnp-fix/a3server-rest/target/jaxrs-analyzer/swagger.json [INFO] Empty JAX-RS analysis result, omitting output
It seems like that only the current project is taken into account for generation and not the dependent jars.
Could it be a possible solution to add to plugin configuration the list of artifact (dependencies) to be included ?

@abstratt
Copy link

@sdaschner Any workarounds for people where DTOs and resources are defined in different Maven artifacts?

@fcav1973
Copy link
Author

fcav1973 commented Jun 9, 2017

After some investigations, I found that the problem is due to the fact that annotations have been put on an interface and not into the concrete class.
The following class can be used to reproduce the problem:

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();
}

The problem is due to jaxrs-analizer behavior and non strictly to the maven plugin. For this reason I filed this issue: sdaschner/jaxrs-analyzer#117

@sdaschner sdaschner added the bug label Jun 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants