Skip to content

Commit a3414a5

Browse files
committed
chore: set API description is valid. 🎉
1 parent 3f5fe7e commit a3414a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1623
-1551
lines changed

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
npx lint-staged
4+
npx lint-staged

.husky/pre-push.bak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
npm test
4+
npm test && npm run validate && npm run format:check

public/api_spec_image_1.png

1.18 MB
Loading

sdks/javascript/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,37 @@ npm install @cocoaflow/js-sdk
1919
### Proposed Usage Pattern
2020

2121
```typescript
22-
import { CocoaFlowAPI } from '@cocoaflow/js-sdk';
22+
import { CocoaFlowAPI } from "@cocoaflow/js-sdk";
2323

2424
// Initialize the client
2525
const client = new CocoaFlowAPI({
26-
apiKey: 'your-api-key',
27-
baseURL: 'https://api.cocoaflow.com'
26+
apiKey: "your-api-key",
27+
baseURL: "https://api.cocoaflow.com",
2828
});
2929

3030
// Authenticate
3131
await client.auth.login({
32-
email: 'user@example.com',
33-
password: 'password'
32+
email: "user@example.com",
33+
password: "password",
3434
});
3535

3636
// Create a farm
3737
const farm = await client.farms.create({
3838
location: {
3939
lat: 6.5244,
40-
lng: 3.3792
40+
lng: 3.3792,
4141
},
42-
farmer_id: 'clh1234567890abcdef',
43-
village: 'Ibadan Village',
44-
division: 'Oyo Division',
45-
council: 'Ibadan Council'
42+
farmer_id: "clh1234567890abcdef",
43+
village: "Ibadan Village",
44+
division: "Oyo Division",
45+
council: "Ibadan Council",
4646
});
4747

4848
// List farms with pagination
4949
const farms = await client.farms.list({
5050
limit: 20,
5151
offset: 0,
52-
company_id: 'clh1234567890abcdef'
52+
company_id: "clh1234567890abcdef",
5353
});
5454
```
5555

@@ -65,7 +65,7 @@ const farms = await client.farms.list({
6565
## API Coverage (Based on Specification)
6666

6767
- ✅ Companies Management
68-
- ✅ User Management
68+
- ✅ User Management
6969
- ✅ Farmer Profiles
7070
- ✅ Farm Operations
7171
- ✅ Project Management
@@ -98,4 +98,4 @@ const farms = await client.farms.list({
9898

9999
## License
100100

101-
Apache 2.0
101+
Apache 2.0

sdks/python/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ farm_details = client.farms.get(farm_id='clh1234567890abcdef')
6161
## API Coverage
6262

6363
- ✅ Companies Management
64-
- ✅ User Management
64+
- ✅ User Management
6565
- ✅ Farmer Profiles
6666
- ✅ Farm Operations
6767
- ✅ Project Management
@@ -80,7 +80,7 @@ from cocoaflow import AsyncCocoaFlowAPI
8080

8181
async def main():
8282
client = AsyncCocoaFlowAPI(api_key='your-api-key')
83-
83+
8484
# Create multiple farms
8585
farms = []
8686
for i in range(5):
@@ -92,7 +92,7 @@ async def main():
9292
'council': 'Ibadan Council'
9393
})
9494
farms.append(farm)
95-
95+
9696
return farms
9797

9898
# Run async function
@@ -107,4 +107,4 @@ farms = asyncio.run(main())
107107

108108
## License
109109

110-
Apache 2.0
110+
Apache 2.0

swt_api_spec/cocoaflow-api.yaml

Lines changed: 20 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ paths:
244244
"/farms/{id}":
245245
$ref: paths/farm/farm_{id}.yaml
246246
"/audits": # unified audits endpoint
247-
$ref: paths/audits.yaml
247+
$ref: paths/audit/audits.yaml
248248
"/audits/{audit_id}": # unified audits endpoint
249-
$ref: "paths/audits.yaml"
249+
$ref: "paths/audit/audits_{id}.yaml"
250250
"/receipts": # receipts
251251
$ref: paths/receipt/receipt.yaml
252252
"/receipts/{id}":
@@ -263,23 +263,22 @@ paths:
263263
$ref: paths/market/market_{company_id}.yaml
264264
"/inspection_data": # inspection_data
265265
$ref: "paths/inspection_data/inspection_data.yaml"
266-
"/inspection_data/{inspection_id}": # inspection_data
267-
$ref: "paths/inspection_data/inspection_data_{inspection_id}.yaml"
268-
266+
"/inspection_data/{project_id}": # inspection_data
267+
$ref: "paths/inspection_data/inspection_data_{id}.yaml"
269268
"/subscriptions": # subcription
270269
$ref: "paths/subscription/subscription.yaml"
271270
"/subscriptions/{subscription_id}": # subscription
272-
$ref: "paths/subscription/subscription_{subscription_id}.yaml"
271+
$ref: "paths/subscription/subscription_{id}.yaml"
273272
"/subscriptions/{company_id}/company":
274273
$ref: paths/subscription/subscription_{company_id }_company.yaml
275274
"/trainings": # training
276275
$ref: paths/training/training.yaml
277276
"/trainings/{training_id}": # training
278-
$ref: "paths/training/training.yaml"
277+
$ref: "paths/training/training_{id}.yaml"
279278
"/transaction": # transaction
280-
$ref: paths/transaction.yaml
279+
$ref: paths/transaction/transaction.yaml
281280
"/transaction/{transaction_id}": # transaction
282-
$ref: "paths/transaction.yaml"
281+
$ref: "paths/transaction/transaction_{id}.yaml"
283282
"/campaign_stocks": #campaign_stock
284283
$ref: paths/campaign_stock/campaign_stock.yaml
285284
"/campaign_stocks/{campaign_id}":
@@ -295,9 +294,9 @@ paths:
295294
"/collector_agents/{id}":
296295
$ref: paths/collector_agent/collector_agent_{id}.yaml
297296
"/training_session": #participants
298-
$ref: paths/training_session.yaml
297+
$ref: paths/training_sessions/training_session.yaml
299298
"/training_session/{session_id}": #participants
300-
$ref: paths/training_session.yaml
299+
$ref: paths/training_sessions/training_session_{id}.yaml
301300
"/price_plan_requirements":
302301
$ref: paths/price_plan_requirement.yaml
303302
components:
@@ -366,165 +365,27 @@ components:
366365
367366
parameters:
368367
PaginationLimit:
369-
name: limit
370-
in: query
371-
description: Number of items to return (max 100)
372-
required: false
373-
schema:
374-
type: integer
375-
minimum: 1
376-
maximum: 100
377-
default: 20
378-
example: 20
368+
$ref: components/parameters/PaginationLimit.yaml
379369
PaginationOffset:
380-
name: offset
381-
in: query
382-
description: Number of items to skip for pagination
383-
required: false
384-
schema:
385-
type: integer
386-
minimum: 0
387-
default: 0
388-
example: 0
370+
$ref: components/parameters/PaginationOffset.yaml
389371
CompanyId:
390-
name: company_id
391-
in: query
392-
description: Filter by company ID
393-
required: false
394-
schema:
395-
type: string
396-
format: cuid
397-
example: "clh1234567890abcdef"
372+
$ref: components/parameters/CompanyId.yaml
398373
DateRangeStart:
399-
name: start_date
400-
in: query
401-
description: Start date for filtering (ISO 8601 format)
402-
required: false
403-
schema:
404-
type: string
405-
format: date
406-
example: "2024-01-01"
374+
$ref: components/parameters/DateRangeStart.yaml
407375
DateRangeEnd:
408-
name: end_date
409-
in: query
410-
description: End date for filtering (ISO 8601 format)
411-
required: false
412-
schema:
413-
type: string
414-
format: date
415-
example: "2024-12-31"
376+
$ref: components/parameters/DateRangeEnd.yaml
416377

417378
responses:
418379
UnauthorizedError:
419-
description: Authentication credentials were missing or invalid
420-
content:
421-
application/json:
422-
schema:
423-
type: object
424-
properties:
425-
error:
426-
type: string
427-
example: "Unauthorized"
428-
message:
429-
type: string
430-
example: "Invalid or missing authentication token"
431-
code:
432-
type: string
433-
example: "AUTH_REQUIRED"
380+
$ref: components/responses/UnauthorizedError.yaml
434381
ForbiddenError:
435-
description: The request was understood but the server is refusing to authorize it
436-
content:
437-
application/json:
438-
schema:
439-
type: object
440-
properties:
441-
error:
442-
type: string
443-
example: "Forbidden"
444-
message:
445-
type: string
446-
example: "Insufficient permissions to access this resource"
447-
code:
448-
type: string
449-
example: "INSUFFICIENT_PERMISSIONS"
382+
$ref: components/responses/ForbiddenError.yaml
450383
ValidationError:
451-
description: The request was well-formed but contains invalid parameters
452-
content:
453-
application/json:
454-
schema:
455-
type: object
456-
properties:
457-
error:
458-
type: string
459-
example: "Validation Error"
460-
message:
461-
type: string
462-
example: "Request validation failed"
463-
details:
464-
type: array
465-
items:
466-
type: object
467-
properties:
468-
field:
469-
type: string
470-
example: "email"
471-
message:
472-
type: string
473-
example: "Invalid email format"
474-
code:
475-
type: string
476-
example: "VALIDATION_ERROR"
384+
$ref: components/responses/ValidationError.yaml
477385
RateLimitError:
478-
description: Too many requests, please try again later
479-
headers:
480-
X-RateLimit-Limit:
481-
description: The number of allowed requests in the current period
482-
schema:
483-
type: integer
484-
X-RateLimit-Remaining:
485-
description: The number of remaining requests in the current period
486-
schema:
487-
type: integer
488-
X-RateLimit-Reset:
489-
description: The number of seconds left in the current period
490-
schema:
491-
type: integer
492-
content:
493-
application/json:
494-
schema:
495-
type: object
496-
properties:
497-
error:
498-
type: string
499-
example: "Rate Limit Exceeded"
500-
message:
501-
type: string
502-
example: "Too many requests, please try again later"
503-
retry_after:
504-
type: integer
505-
example: 3600
506-
code:
507-
type: string
508-
example: "RATE_LIMIT_EXCEEDED"
386+
$ref: components/responses/RateLimitError.yaml
509387
ServerError:
510-
description: Internal server error
511-
content:
512-
application/json:
513-
schema:
514-
type: object
515-
properties:
516-
error:
517-
type: string
518-
example: "Internal Server Error"
519-
message:
520-
type: string
521-
example: "An unexpected error occurred"
522-
request_id:
523-
type: string
524-
example: "req_1234567890abcdef"
525-
code:
526-
type: string
527-
example: "INTERNAL_ERROR"
388+
$ref: components/responses/ServerError.yaml
528389

529390
security:
530391
- BearerAuth: []

swt_api_spec/components/parameters/CompanyId.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ required: false
55
schema:
66
type: string
77
format: cuid
8-
example: "clh1234567890abcdef"
8+
example: "clh1234567890abcdef"

swt_api_spec/components/parameters/DateRangeEnd.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ required: false
55
schema:
66
type: string
77
format: date
8-
example: "2024-12-31"
8+
example: "2024-12-31"

swt_api_spec/components/parameters/DateRangeStart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ required: false
55
schema:
66
type: string
77
format: date
8-
example: "2024-01-01"
8+
example: "2024-01-01"

swt_api_spec/components/parameters/PaginationLimit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ schema:
77
minimum: 1
88
maximum: 100
99
default: 20
10-
example: 20
10+
example: 20

0 commit comments

Comments
 (0)