Skip to content
Merged

Dev #10

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
77f8b4c
users
Yolallop May 18, 2025
9d18fb8
add controllers
Yolallop May 18, 2025
ca8f981
update router
Yolallop May 18, 2025
9ff2d6a
refactor: cleanup comments
khalidbelk May 18, 2025
11c1950
feat: add providers
kike454 May 18, 2025
02b0dff
feat: add 409 status for createUser
khalidbelk May 19, 2025
00cb6b8
fix: require both name and email in updateUser validation
khalidbelk May 19, 2025
f4b5a92
fix(openapi): readapt error schema
khalidbelk May 19, 2025
0d2936c
fix(users): make the openAPI and the current responses/bodies consistent
khalidbelk May 19, 2025
777398b
fix(users): handle the case where the favorite is not found
khalidbelk May 19, 2025
cddb318
Merge pull request #6 from KhalidCEU/feat/users
khalidbelk May 19, 2025
8f18d51
Merge branch 'dev' into feat/providers
khalidbelk May 19, 2025
9cbcdf7
Added Providers JSON
pablogaraay May 19, 2025
2ee7adc
provider schema fixed
pablogaraay May 19, 2025
478ff04
provider schema email validation fixed
pablogaraay May 19, 2025
0a5b65d
providers metadata added
pablogaraay May 19, 2025
82b8b5a
errors fixed
pablogaraay May 19, 2025
0a006d3
feat: add first reviews endpoints and controllers
khalidbelk May 19, 2025
ab96bc2
feat: add reviews router and controllers
khalidbelk May 20, 2025
0500fd0
fix(sneakers): add missing try-catch block
khalidbelk May 20, 2025
3f3fa8c
refactor(stores): change response message for consistency
khalidbelk May 20, 2025
ac4135e
refactor(users): change deleteUser controller name, and response mess…
khalidbelk May 20, 2025
1112b4e
fix(openapi): remove false YAML schema errors in VSCode
khalidbelk May 20, 2025
13bb7db
docs: update roadmap
khalidbelk May 20, 2025
c274b1d
feat(providers): seed data on launch
khalidbelk May 20, 2025
f536173
fix(providers): remove _id from mongoose schema fields
khalidbelk May 20, 2025
31c1da9
feat(providers): add missing responsse on updateProviderById controller
khalidbelk May 20, 2025
a98f73b
Merge pull request #7 from KhalidCEU/feat/providers
khalidbelk May 20, 2025
737462e
fix(openapi): update openapi to match providers responses
khalidbelk May 20, 2025
838e053
Merge branch 'dev' into feat/reviews
khalidbelk May 20, 2025
f92d9c6
Merge pull request #8 from KhalidCEU/feat/reviews
khalidbelk May 20, 2025
0b9376b
Merge pull request #9 from KhalidCEU/feat/providers
khalidbelk May 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 110 additions & 33 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
openapi: 3.0.0
# yaml-language-server: $schema=https://json-schema.org/draft/2020-12/schema
openapi: 3.0.3
info:
title: Snapi (Sneakers API)
version: 1.0.0
description: API for managing sneakers, reviews, users, providers and stores
servers:
- url: http://localhost:8080/api
description: V1
- url: http://localhost:8080/api/
description: Production server

tags:
- name: sneakers
Expand Down Expand Up @@ -216,7 +217,17 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Review'
$ref: '#/components/schemas/ReviewsResponse'
'400':
description: Invalid input data
content:
application/json:
schema: { $ref: '#/components/schemas/Error' }
'409':
description: User has already reviewed this sneaker
content:
application/json:
schema: { $ref: '#/components/schemas/Error' }
'404':
description: Sneaker not found
content:
Expand All @@ -240,7 +251,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Review'
$ref: '#/components/schemas/ReviewsResponse'
'404':
description: Review not found
content:
Expand Down Expand Up @@ -269,12 +280,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Review'
'403':
description: Not authorized to update this review
content:
application/json:
schema: { $ref: '#/components/schemas/Error' }
$ref: '#/components/schemas/ReviewsResponse'
'404':
description: Review not found
content:
Expand All @@ -294,11 +300,6 @@ paths:
responses:
'204':
description: Review deleted
'403':
description: Not authorized to delete this review
content:
application/json:
schema: { $ref: '#/components/schemas/Error' }
'404':
description: Review not found
content:
Expand Down Expand Up @@ -331,6 +332,12 @@ paths:
content:
application/json:
schema: { $ref: '#/components/schemas/Error' }
'409':
description: Email already exists
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

/users/{id}:
get:
Expand All @@ -349,7 +356,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/User'
$ref: '#/components/schemas/UserResponse'
'404':
description: User not found
content:
Expand All @@ -371,14 +378,14 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/User'
$ref: '#/components/schemas/UserInput'
responses:
'200':
description: User updated
content:
application/json:
schema:
$ref: '#/components/schemas/User'
$ref: '#/components/schemas/UserResponse'
'400':
description: Invalid input data
content:
Expand Down Expand Up @@ -460,9 +467,7 @@ paths:
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Sneaker'
$ref: '#/components/schemas/FavoritesResponse'
'404':
description: User or sneaker not found
content:
Expand Down Expand Up @@ -507,9 +512,7 @@ paths:
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Provider'
$ref: '#/components/schemas/Provider'
'404':
description: No providers found
content:
Expand All @@ -532,7 +535,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Provider'
$ref: '#/components/schemas/ProvidersResponse'
'400':
description: Invalid input data
content:
Expand All @@ -556,7 +559,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Provider'
$ref: '#/components/schemas/ProvidersResponse'
'404':
description: Provider not found
content:
Expand Down Expand Up @@ -585,7 +588,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Provider'
$ref: '#/components/schemas/ProvidersResponse'
'400':
description: Invalid input data
content:
Expand Down Expand Up @@ -788,15 +791,31 @@ components:
_id:
type: string
readOnly: true
sneakerId:
type: string
readOnly: true # The saved sneakerId is the one in the param
userId:
type: string
rating:
type: integer
minimum: 1
maximum: 5
comment:
type: string
userId:
date:
type: string
required: [rating]
format: date-time
required: [sneakerId, rating, userId]

UserInput:
type: object
properties:
name:
type: string
email:
type: string
format: email
required: [name, email]

User:
type: object
Expand All @@ -809,8 +828,51 @@ components:
email:
type: string
format: email
favorites:
type: array
items:
type: string
required: [name, email]

UserResponse:
type: object
properties:
items:
$ref: '#/components/schemas/User'
message:
type: string
status:
type: string
enum: [success]
required: [items, message, status]

FavoritesResponse:
type: object
properties:
items:
type: array
items:
type: string
message:
type: string
status:
type: string
enum: [success]
required: [items, message, status]

ReviewsResponse:
type: object
properties:
items:
$ref: '#/components/schemas/Review'
message:
type: string
status:
type: string
enum: [success]
required: [items, message, status]


Provider:
type: object
properties:
Expand All @@ -824,6 +886,18 @@ components:
format: email
required: [name, contact_email]

ProvidersResponse:
type: object
properties:
items:
$ref: '#/components/schemas/Provider'
message:
type: string
status:
type: string
enum: [success]
required: [items, message, status]

Store:
type: object
properties:
Expand All @@ -840,6 +914,9 @@ components:
Error:
type: object
properties:
code: { type: string }
message: { type: string }
required: [error]
message:
type: string
status:
type: string
enum: [failure]
required: [message, status]
6 changes: 3 additions & 3 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
- [x] The API offers a REST interface and allows CRUD operations on the DB
- [x] The database is a MongoDB database.
- [x] The database is **automatically seeded** on launch if it's empty.
- [ ] At least one message is in XML format and has an associated schema.
- [ ] At least one message is in XML format and has an associated schema. (**optional**)
- [x] At least one response is in JSON format
- [ ] There are at least 3 resources and they are related to each other.
- [x] There are at least 3 resources and they are related to each other (sneakers, users, reviews).
- [x] One of the collections has at least **1000 documents**
- [x] There is a **dataset** to seed this collection in the repository ( -> this dataset is in **JSON format**)
- [ ] At least one route allows pagination
- [x] At least one route allows filtering data to search inside this collection

- [x] Uses an external API
- [ ] At least one consumed message is in XML format
- [ ] At least one consumed message is in XML format (**optional**)
- [x] At least one consumed message is in JSON format
- [x] The consumed information is integrated with our API and data is saved in our DB.
- [x] The API keeps working even if the external API is down.
43 changes: 22 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading