Last active
January 13, 2019 03:46
-
-
Save kaveenr/df60ce333e78f54385f44b51880fbac7 to your computer and use it in GitHub Desktop.
Maven-codegen Impl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Swagger Petstore | |
* | |
* <p>A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification | |
* | |
*/ | |
public class DefaultApiServiceImpl implements DefaultApi { | |
static Map<Long,PetDTO> petMap = new HashMap<>(); | |
public Response addPet(NewPetDTO pet) { | |
long id = (long) (petMap.keySet().size() + 1); | |
PetDTO newPet = new PetDTO(); | |
newPet.setName(pet.getName()); | |
newPet.setTag(pet.getTag()); | |
newPet.setId(id); | |
petMap.put(id, newPet); | |
return Response.ok().build(); | |
} | |
public Response deletePet(Long id) { | |
petMap.remove(id); | |
return Response.status(Response.Status.NO_CONTENT).build(); | |
} | |
public Response findPetById(Long id) { | |
PetDTO pet = petMap.get(id); | |
return Response.ok().entity(pet).build(); | |
} | |
public Response findPets(List<String> tags, Integer limit) { | |
List<PetDTO> pets = new ArrayList<>(petMap.values()); | |
return Response.ok().entity(pets).build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment