Skip to content

Add ingredient API endpoints - #53

Merged
leslyVillanueva1020 merged 4 commits into
mainfrom
lesly/ingredients_API
Oct 20, 2026
Merged

leslyVillanueva1020 merged 4 commits into
mainfrom
lesly/ingredients_API

Conversation

@leslyVillanueva1020

Copy link
Copy Markdown
Collaborator

Closes #51

What changed

  • Added GET /api/v1/ingredients for paginated ingredient browsing.
  • Added POST /api/v1/ingredients for creating ingredients.
  • Added IngredientController, IngredientService, and IngredientRepository.
  • Added IngredientCreate and IngredientResponse records.
  • Added duplicate ingredient-name validation.
  • Added a unit test for listing ingredients and converting entities to response objects.

How I tested it

  • Ran ./gradlew test locally.
  • Verified that the ingredient service test passes.
  • Verified that pagination and ingredient response mapping work.
  • Verified that duplicate ingredient names are rejected.

…ry, request/response records

Created IngredientController
- handles HTTP requests from client
- GET /api/v1/ingredients
- POST /api/v1/ingredients

Created IngredientCreate
- represents data needed to create an ingredient

Created Ingredient Response
- represents the data sent back to the client
- converts an Ingredient database entity into safe API output

Created IngredientService.java
- handles pagination
- checks duplicate names
- creates/saves ingredients
- converts entities into reponse objects
Solian21
Solian21 previously approved these changes Oct 18, 2026

@Solian21 Solian21 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is really well done. It’s clearly structured and uses DTOs effectively. I specifically like how the responsibilities are separated cleanly across the controller, service, repository, and test layers.

@annabelleb20 annabelleb20 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I think this code looks pretty good, though if you want to meet the test coverage requirements you could use tests for IngredientController and IngredientService that you haven't covered yet.

Running the tests using coverage can help, but I believe list and create in service are missing tests, as well as listingredients and createingredients in controller. Running ./gradlew check can also help. You probably don't have to make tests for all of those methods, but I think some quick controller tests could be useful and full coverage is good.

Also when you have the chance, you'll need to add javadoc comments

- ingredient updated so it stores the original name and a normalized lowercase
- changed IngredientService to use saveAndFlush() and the exception returns a 409
…e requiring authentication to create ingredients

@annabelleb20 annabelleb20 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is overall great work!

@Yooze0x4c8 Yooze0x4c8 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@leslyVillanueva1020
leslyVillanueva1020 merged commit e45c456 into main Oct 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

As a developer, I want to set up ingredient API so that users can browse and add ingredients

4 participants