-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathapi_config.yaml
More file actions
261 lines (251 loc) · 5.52 KB
/
api_config.yaml
File metadata and controls
261 lines (251 loc) · 5.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# LightAPI Configuration File
api:
title: "YAML-Configured API"
version: "1.0.0"
description: "API generated from YAML configuration"
database:
url: "sqlite:///./yaml_api.db"
server:
host: "localhost"
port: 8000
debug: true
cors:
origins:
- "http://localhost:3000"
- "http://localhost:8080"
models:
User:
table_name: "users"
fields:
id:
type: "Integer"
primary_key: true
auto_increment: true
username:
type: "String"
length: 50
nullable: false
unique: true
validation:
min_length: 3
max_length: 50
pattern: "^[a-zA-Z0-9_]+$"
email:
type: "String"
length: 100
nullable: false
unique: true
validation:
format: "email"
full_name:
type: "String"
length: 200
nullable: true
age:
type: "Integer"
nullable: true
validation:
min: 0
max: 150
is_active:
type: "Boolean"
default: true
created_at:
type: "DateTime"
default: "now"
endpoints:
- method: "GET"
path: "/users"
description: "List all users"
pagination: true
filtering:
- "username"
- "email"
- "is_active"
sorting:
- "username"
- "created_at"
- method: "GET"
path: "/users/{id}"
description: "Get user by ID"
- method: "POST"
path: "/users"
description: "Create new user"
validation: true
- method: "PUT"
path: "/users/{id}"
description: "Update user"
validation: true
- method: "DELETE"
path: "/users/{id}"
description: "Delete user"
Product:
table_name: "products"
fields:
id:
type: "Integer"
primary_key: true
auto_increment: true
name:
type: "String"
length: 200
nullable: false
validation:
min_length: 2
max_length: 200
description:
type: "Text"
nullable: true
price:
type: "Float"
nullable: false
validation:
min: 0
max: 1000000
category:
type: "String"
length: 50
nullable: false
validation:
choices:
- "electronics"
- "clothing"
- "books"
- "home"
- "sports"
- "toys"
in_stock:
type: "Boolean"
default: true
stock_quantity:
type: "Integer"
default: 0
validation:
min: 0
created_at:
type: "DateTime"
default: "now"
updated_at:
type: "DateTime"
default: "now"
auto_update: true
endpoints:
- method: "GET"
path: "/products"
description: "List all products"
pagination: true
filtering:
- "name"
- "category"
- "price"
- "in_stock"
sorting:
- "name"
- "price"
- "created_at"
search:
fields:
- "name"
- "description"
- method: "GET"
path: "/products/{id}"
description: "Get product by ID"
- method: "POST"
path: "/products"
description: "Create new product"
validation: true
- method: "PUT"
path: "/products/{id}"
description: "Update product"
validation: true
- method: "DELETE"
path: "/products/{id}"
description: "Delete product"
Order:
table_name: "orders"
fields:
id:
type: "Integer"
primary_key: true
auto_increment: true
user_id:
type: "Integer"
nullable: false
foreign_key:
table: "users"
field: "id"
product_id:
type: "Integer"
nullable: false
foreign_key:
table: "products"
field: "id"
quantity:
type: "Integer"
nullable: false
validation:
min: 1
max: 1000
total_price:
type: "Float"
nullable: false
validation:
min: 0
status:
type: "String"
length: 20
default: "pending"
validation:
choices:
- "pending"
- "confirmed"
- "shipped"
- "delivered"
- "cancelled"
order_date:
type: "DateTime"
default: "now"
endpoints:
- method: "GET"
path: "/orders"
description: "List all orders"
pagination: true
filtering:
- "user_id"
- "product_id"
- "status"
sorting:
- "order_date"
- "total_price"
- method: "GET"
path: "/orders/{id}"
description: "Get order by ID"
- method: "POST"
path: "/orders"
description: "Create new order"
validation: true
- method: "PUT"
path: "/orders/{id}"
description: "Update order"
validation: true
- method: "DELETE"
path: "/orders/{id}"
description: "Delete order"
middleware:
- name: "cors"
enabled: true
- name: "logging"
enabled: true
level: "INFO"
- name: "rate_limiting"
enabled: false
requests_per_minute: 100
authentication:
enabled: false
type: "jwt"
secret_key: "your-secret-key"
token_expiry: 3600
caching:
enabled: false
backend: "redis"
default_ttl: 300