REST API works
This commit is contained in:
38
src/main/java/fr/istic/taa/jaxrs/rest/PetResource.java
Normal file
38
src/main/java/fr/istic/taa/jaxrs/rest/PetResource.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package fr.istic.taa.jaxrs.rest;
|
||||
|
||||
import fr.istic.taa.jaxrs.domain.Pet;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
@Path("pet")
|
||||
@Produces({"application/json", "application/xml"})
|
||||
public class PetResource {
|
||||
|
||||
@GET
|
||||
@Path("/{petId}")
|
||||
public Pet getPetById(@PathParam("petId") Long petId) {
|
||||
// return pet
|
||||
return new Pet();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/")
|
||||
public Pet getPet(Long petId) {
|
||||
return new Pet();
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
@Consumes("application/json")
|
||||
public Response addPet(
|
||||
@Parameter(description = "Pet object that needs to be added to the store", required = true) Pet pet) {
|
||||
// add pet
|
||||
return Response.ok().entity("SUCCESS").build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user