Ich will hier nicht zu sehr ins Detail gehen. Aber hier sind einige Details
[CODE lang="java" title="Api Interface"]import javax.ejb.Remote;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.info.License;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
@Remote
@OpenAPIDefinition(tags = { @Tag(name = "widget", description = "Widget operations."),
@Tag(name = "gasket", description = "Operations related to gaskets") }, info = @Info(title = "Example API", version = "1.0.1", contact = @Contact(name = "Example API Support", url = "http://exampleurl.com/contact", email = "techsupport@example.com"), license = @License(name = "Apache 2.0", url = "http://www.apache.org/licenses/LICENSE-2.0.html")))
public interface RestApiInterface
{
/**
* @param requestData requestData
* @return String
* @throws ControlException ControlException
*/
@Operation(summary = "Start", responses = {
@ApiResponse(description = "Start", content = @Content(mediaType = "application/json", schema = @Schema(implementation = RequestData.class))),
@ApiResponse(responseCode = "400", description = "Operation not found") })
public String start(String requestData) throws ControlException;
}[/CODE]
Und dann die Implementation
[CODE lang="java" title="Implementation"]import javax.ejb.Stateless;
import javax.enterprise.inject.Default;
import javax.inject.Inject;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
@Stateless(name = "RestImpl")
@ApplicationPath("beispiel/restImpl")
@Default
public class RestImpl extends Application implements RestApi
{
/** handlerCollection */
@Inject
protected HandlerCollection handlerCollection;
@Path("start")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Override
public String start(@PathParam("requestData") String requestData) throws ControlException
{
return <some method>;
}
}[/CODE]