Skip to content

Commit 2e38fe0

Browse files
committed
Day 9: Schema and Swagger UI code added
1 parent 8ec274c commit 2e38fe0

File tree

3 files changed

+311
-0
lines changed

3 files changed

+311
-0
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ requires-python = ">=3.14"
77
dependencies = [
88
"black>=25.11.0",
99
"coverage>=7.12.0",
10+
"django-filter>=25.2",
1011
"django-jazzmin>=3.0.1",
1112
"django-silk>=5.4.3",
1213
"djangorestframework>=3.16.1",

schema.yml

Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ paths:
4040
schema:
4141
$ref: '#/components/schemas/AdminUserDetail'
4242
description: ''
43+
/api/delete-account/:
44+
get:
45+
operationId: delete_account_retrieve
46+
tags:
47+
- delete-account
48+
security:
49+
- jwtAuth: []
50+
- {}
51+
responses:
52+
'200':
53+
description: No response body
4354
/api/login/:
4455
post:
4556
operationId: login_create
@@ -67,6 +78,140 @@ paths:
6778
schema:
6879
$ref: '#/components/schemas/Login'
6980
description: ''
81+
/api/products/:
82+
get:
83+
operationId: products_list
84+
parameters:
85+
- in: query
86+
name: brand
87+
schema:
88+
type: integer
89+
- name: ordering
90+
required: false
91+
in: query
92+
description: Which field to use when ordering the results.
93+
schema:
94+
type: string
95+
- name: page
96+
required: false
97+
in: query
98+
description: A page number within the paginated result set.
99+
schema:
100+
type: integer
101+
- in: query
102+
name: price
103+
schema:
104+
type: number
105+
- name: search
106+
required: false
107+
in: query
108+
description: A search term.
109+
schema:
110+
type: string
111+
- in: query
112+
name: status
113+
schema:
114+
type: string
115+
enum:
116+
- out_of_stock
117+
- stock
118+
description: |-
119+
* `stock` - Stock
120+
* `out_of_stock` - Out of Stock
121+
tags:
122+
- products
123+
security:
124+
- jwtAuth: []
125+
responses:
126+
'200':
127+
content:
128+
application/json:
129+
schema:
130+
$ref: '#/components/schemas/PaginatedProductList'
131+
description: ''
132+
/api/products/{product_id}/:
133+
get:
134+
operationId: products_retrieve
135+
parameters:
136+
- in: path
137+
name: product_id
138+
schema:
139+
type: integer
140+
required: true
141+
tags:
142+
- products
143+
security:
144+
- jwtAuth: []
145+
responses:
146+
'200':
147+
content:
148+
application/json:
149+
schema:
150+
$ref: '#/components/schemas/Product'
151+
description: ''
152+
/api/products/{product_id}/review/:
153+
post:
154+
operationId: products_review_create
155+
parameters:
156+
- in: path
157+
name: product_id
158+
schema:
159+
type: integer
160+
required: true
161+
tags:
162+
- products
163+
requestBody:
164+
content:
165+
application/json:
166+
schema:
167+
$ref: '#/components/schemas/ProductReview'
168+
application/x-www-form-urlencoded:
169+
schema:
170+
$ref: '#/components/schemas/ProductReview'
171+
multipart/form-data:
172+
schema:
173+
$ref: '#/components/schemas/ProductReview'
174+
required: true
175+
security:
176+
- jwtAuth: []
177+
responses:
178+
'200':
179+
content:
180+
application/json:
181+
schema:
182+
$ref: '#/components/schemas/ProductReview'
183+
description: ''
184+
/api/profile/{username}/:
185+
get:
186+
operationId: profile_retrieve
187+
parameters:
188+
- in: path
189+
name: username
190+
schema:
191+
type: string
192+
required: true
193+
tags:
194+
- profile
195+
security:
196+
- jwtAuth: []
197+
responses:
198+
'200':
199+
description: No response body
200+
put:
201+
operationId: profile_update
202+
parameters:
203+
- in: path
204+
name: username
205+
schema:
206+
type: string
207+
required: true
208+
tags:
209+
- profile
210+
security:
211+
- jwtAuth: []
212+
responses:
213+
'200':
214+
description: No response body
70215
/api/register/admin/:
71216
post:
72217
operationId: register_admin_create
@@ -250,6 +395,22 @@ components:
250395
- total_bookings
251396
- total_spent
252397
- username
398+
Brand:
399+
type: object
400+
properties:
401+
id:
402+
type: integer
403+
readOnly: true
404+
name:
405+
type: string
406+
maxLength: 100
407+
category:
408+
type: string
409+
readOnly: true
410+
required:
411+
- category
412+
- id
413+
- name
253414
Login:
254415
type: object
255416
properties:
@@ -261,6 +422,121 @@ components:
261422
required:
262423
- identifier
263424
- password
425+
PaginatedProductList:
426+
type: object
427+
required:
428+
- count
429+
- results
430+
properties:
431+
count:
432+
type: integer
433+
example: 123
434+
next:
435+
type: string
436+
nullable: true
437+
format: uri
438+
example: http://api.example.org/accounts/?page=4
439+
previous:
440+
type: string
441+
nullable: true
442+
format: uri
443+
example: http://api.example.org/accounts/?page=2
444+
results:
445+
type: array
446+
items:
447+
$ref: '#/components/schemas/Product'
448+
Product:
449+
type: object
450+
properties:
451+
id:
452+
type: integer
453+
readOnly: true
454+
product_name:
455+
type: string
456+
maxLength: 255
457+
description:
458+
type: string
459+
price:
460+
type: string
461+
format: decimal
462+
pattern: ^-?\d{0,8}(?:\.\d{0,2})?$
463+
tags:
464+
type: array
465+
items:
466+
$ref: '#/components/schemas/Tag'
467+
status:
468+
$ref: '#/components/schemas/StatusEnum'
469+
technical_specifications:
470+
nullable: true
471+
brand:
472+
$ref: '#/components/schemas/Brand'
473+
images:
474+
type: array
475+
items:
476+
$ref: '#/components/schemas/ProductImage'
477+
reviews:
478+
type: array
479+
items:
480+
$ref: '#/components/schemas/ProductReview'
481+
readOnly: true
482+
average_rating:
483+
type: number
484+
format: double
485+
readOnly: true
486+
url:
487+
type: string
488+
readOnly: true
489+
required:
490+
- average_rating
491+
- brand
492+
- id
493+
- images
494+
- price
495+
- product_name
496+
- reviews
497+
- status
498+
- tags
499+
- url
500+
ProductImage:
501+
type: object
502+
properties:
503+
id:
504+
type: integer
505+
readOnly: true
506+
image:
507+
type: string
508+
format: uri
509+
required:
510+
- id
511+
- image
512+
ProductReview:
513+
type: object
514+
properties:
515+
id:
516+
type: integer
517+
readOnly: true
518+
username:
519+
type: string
520+
readOnly: true
521+
rating:
522+
type: integer
523+
maximum: 5
524+
minimum: 1
525+
review_text:
526+
type: string
527+
image:
528+
type: string
529+
format: uri
530+
nullable: true
531+
created_at:
532+
type: string
533+
format: date-time
534+
readOnly: true
535+
required:
536+
- created_at
537+
- id
538+
- rating
539+
- username
264540
ProfileStatusEnum:
265541
enum:
266542
- inactive
@@ -316,6 +592,26 @@ components:
316592
* `user` - User
317593
* `admin` - Admin
318594
* `technician` - Technician
595+
StatusEnum:
596+
enum:
597+
- stock
598+
- out_of_stock
599+
type: string
600+
description: |-
601+
* `stock` - Stock
602+
* `out_of_stock` - Out of Stock
603+
Tag:
604+
type: object
605+
properties:
606+
id:
607+
type: integer
608+
readOnly: true
609+
name:
610+
type: string
611+
maxLength: 50
612+
required:
613+
- id
614+
- name
319615
TechnicianSummary:
320616
type: object
321617
properties:

uv.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)