/, , , : . , jaxrs-spec, , , jaxrs-resteasy.
:
, . , , , . Codgen , API, .
jaxrs-resteasy, GET /{username} ( swagger, ):
@GET
@Path("/{username}")
@Produces({ "application/xml", "application/json" })
public Response getUserByName( @PathParam("username") String username,@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.getUserByName(username,securityContext);
}
factory, :
private final UserApiService delegate = UserApiServiceFactory.getUserApi();
, API, :
public abstract class UserApiService {
public abstract Response getUserByName(String username, SecurityContext securityContext) throws NotFoundException;
}
, , :
public class UserApiServiceImpl extends UserApiService {
@Override
public Response getUserByName(String username, SecurityContextsecurityContext) throws NotFoundException {
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
}
factory , , :
public class UserApiServiceFactory {
private final static UserApiService service = new UserApiServiceImpl();
public static UserApiService getUserApi() {
return service;
}
}
, , , UserApiService . , API .
, jaxrs-spec , swagger-codegen . .