Skip to content

Commit adcd173

Browse files
authored
Merge pull request #59 from beckn/api-validation-fix
Fix API structure for track, on_track, status and cancel apis
2 parents 367fea5 + 61ffd95 commit adcd173

File tree

2 files changed

+46
-169
lines changed

2 files changed

+46
-169
lines changed

api/beckn.yaml

Lines changed: 39 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -214,107 +214,6 @@ paths:
214214
application/json:
215215
schema:
216216
$ref: '#/components/schemas/ErrorResponse'
217-
/beckn/discover/offer:
218-
post:
219-
summary: Compute/prune final offers for a given selection of items and/or offers (no Order envelope)
220-
description: >
221-
Client (BAP) submits a selection of items and/or offers. The BPP computes applicable, priced offers and returns them asynchronously via /beckn/on_discover/offer. This is semantically similar to /select, but avoids the Order wrapper to keep the intent clear: "give me offers for these choices".
222-
223-
requestBody:
224-
required: true
225-
content:
226-
application/json:
227-
schema:
228-
type: object
229-
required: [context, message]
230-
properties:
231-
context:
232-
allOf:
233-
- $ref: "#/components/schemas/DiscoveryContext"
234-
- type: object
235-
properties: {action: {const: "discover_offer"}}
236-
message:
237-
type: object
238-
required: [selection]
239-
properties:
240-
# The selection may be a set of items, a set of offers, or both.
241-
selection:
242-
type: object
243-
properties:
244-
items:
245-
type: array
246-
minItems: 1
247-
items:
248-
type: object
249-
required: ['beckn:id']
250-
properties:
251-
beckn:id:
252-
$ref: "https://raw.githubusercontent.com/beckn/protocol-specifications-new/refs/heads/main/schema/core/v2/attributes.yaml#/components/schemas/Item/properties/beckn:id"
253-
quantity:
254-
type: number
255-
description: Optional requested quantity for this item
256-
offers:
257-
type: array
258-
minItems: 1
259-
items:
260-
type: object
261-
required: ['beckn:id']
262-
properties:
263-
beckn:id:
264-
$ref: "https://raw.githubusercontent.com/beckn/protocol-specifications-new/refs/heads/main/schema/core/v2/attributes.yaml#/components/schemas/Offer/properties/beckn:id"
265-
anyOf:
266-
- required: [items]
267-
- required: [offers]
268-
# Optional scoping hints (kept open; networks can define attribute packs if needed)
269-
provider:
270-
$ref: "https://raw.githubusercontent.com/beckn/protocol-specifications-new/refs/heads/main/schema/core/v2/attributes.yaml#/components/schemas/Provider/properties/beckn:id"
271-
constraints:
272-
type: object
273-
description: Optional constraints (e.g., fulfillment mode/slots, region, eligibility). Extend via attribute packs as needed.
274-
additionalProperties: true
275-
responses:
276-
'200':
277-
$ref: '#/components/responses/Ack200'
278-
'400':
279-
$ref: '#/components/responses/Ack400'
280-
'500':
281-
$ref: '#/components/responses/Ack500'
282-
/beckn/on_discover/offer:
283-
post:
284-
summary: Provider returns computed offers for the selection
285-
description: >
286-
BPP responds with the final set of offers applicable to the submitted selection. Each Offer must reference the base items via beckn:items (schema:itemOffered). Additional pricing/eligibility details can be carried in offerAttributes packs.
287-
288-
requestBody:
289-
required: true
290-
content:
291-
application/json:
292-
schema:
293-
type: object
294-
required: [context, message]
295-
properties:
296-
context:
297-
allOf:
298-
- $ref: "#/components/schemas/DiscoveryContext"
299-
- type: object
300-
properties: {action: {const: "on_discover_offer"}}
301-
message:
302-
type: object
303-
required: [offers]
304-
properties:
305-
# Full Offer objects are returned (not just ids) so clients can render price/terms immediately.
306-
offers:
307-
type: array
308-
minItems: 1
309-
items:
310-
$ref: "https://raw.githubusercontent.com/beckn/protocol-specifications-new/refs/heads/main/schema/core/v2/attributes.yaml#/components/schemas/Offer"
311-
responses:
312-
'200':
313-
$ref: '#/components/responses/Ack200'
314-
'400':
315-
$ref: '#/components/responses/Ack400'
316-
'500':
317-
$ref: '#/components/responses/Ack500'
318217
/beckn/select:
319218
post:
320219
summary: "Buyer selects items/offers — returns priced order"
@@ -552,6 +451,7 @@ paths:
552451
order:
553452
oneOf:
554453
- type: object
454+
additionalProperties: false
555455
required:
556456
- beckn:id
557457
properties:
@@ -713,6 +613,7 @@ paths:
713613
order:
714614
oneOf:
715615
- type: object
616+
additionalProperties: false
716617
required:
717618
- beckn:id
718619
properties:
@@ -875,32 +776,24 @@ paths:
875776
message:
876777
type: object
877778
required:
878-
- order
779+
- tracking
879780
properties:
880-
order:
881-
oneOf:
882-
- type: object
883-
required:
884-
- beckn:id
885-
properties:
886-
beckn:id:
887-
$ref: 'https://raw.githubusercontent.com/beckn/protocol-specifications-new/refs/heads/main/schema/core/v2/attributes.yaml#/components/schemas/Order/properties/beckn:id'
888-
fulfillment:
889-
oneOf:
890-
- type: object
891-
properties:
892-
beckn:id:
893-
$ref: 'https://raw.githubusercontent.com/beckn/protocol-specifications-new/refs/heads/main/schema/core/v2/attributes.yaml#/components/schemas/Fulfillment/properties/beckn:id'
894-
- $ref: 'https://raw.githubusercontent.com/beckn/protocol-specifications-new/refs/heads/main/schema/core/v2/attributes.yaml#/components/schemas/Fulfillment'
895-
- allOf:
896-
- $ref: 'https://raw.githubusercontent.com/beckn/protocol-specifications-new/refs/heads/main/schema/core/v2/attributes.yaml#/components/schemas/Order'
897-
- type: object
898-
required:
899-
- beckn:id
900-
mode_hint:
901-
type: string
902-
description: Optional delivery mode for the tracking handle.
903-
enum: [link_only, deep_link, webhook, ws_handle]
781+
tracking:
782+
type: object
783+
required:
784+
- id
785+
properties:
786+
id:
787+
type: string
788+
description: Tracking identifier
789+
callbackUrl:
790+
type: string
791+
format: uri
792+
description: Optional callback URL for streaming tracking coordinates/updates
793+
mode_hint:
794+
type: string
795+
description: Optional delivery mode for the tracking handle.
796+
enum: [link_only, deep_link, webhook, ws_handle]
904797
responses:
905798
'200':
906799
$ref: '#/components/responses/Ack200'
@@ -928,10 +821,11 @@ paths:
928821
const: on_track
929822
message:
930823
type: object
931-
required: [tracking]
824+
required:
825+
- tracking
932826
properties:
933827
tracking:
934-
$ref: 'https://raw.githubusercontent.com/beckn/protocol-specifications-new/refs/heads/main/schema/core/v2/attributes.yaml#/components/schemas/Tracking'
828+
$ref: 'https://raw.githubusercontent.com/beckn/protocol-specifications-new/refs/heads/main/schema/core/v2/attributes.yaml#/components/schemas/TrackAction'
935829
responses:
936830
'200':
937831
$ref: '#/components/responses/Ack200'
@@ -1019,7 +913,7 @@ paths:
1019913
$ref: '#/components/responses/Ack400'
1020914
'500':
1021915
$ref: '#/components/responses/Ack500'
1022-
/beckn/v2/catalog/publish:
916+
/beckn/catalog/publish:
1023917
post:
1024918
summary: Publish one or more catalogs for indexing
1025919
description: |
@@ -1059,7 +953,7 @@ paths:
1059953
$ref: '#/components/responses/Ack400'
1060954
'500':
1061955
$ref: '#/components/responses/Ack500'
1062-
/beckn/v2/catalog/on_publish:
956+
/beckn/catalog/on_publish:
1063957
post:
1064958
summary: Callback with catalog publish processing results
1065959
description: |
@@ -1086,19 +980,20 @@ paths:
1086980
bpp_id: "discovery-indexer.example.com"
1087981
bpp_uri: "https://discovery-indexer.example.com"
1088982
ttl: "PT30S"
1089-
results:
1090-
- catalog_id: "catalog-001"
1091-
status: "ACCEPTED"
1092-
item_count: 42
1093-
warnings:
1094-
- code: "NON_NORMALIZED_BRAND"
1095-
message: "Some brand values were normalized"
1096-
- catalog_id: "catalog-002"
1097-
status: "REJECTED"
1098-
error:
1099-
code: "INVALID_ITEM"
1100-
message: "Invalid item payload at index 3"
1101-
paths: "catalogs[1].items[3]"
983+
message:
984+
results:
985+
- catalog_id: "catalog-001"
986+
status: "ACCEPTED"
987+
item_count: 42
988+
warnings:
989+
- code: "NON_NORMALIZED_BRAND"
990+
message: "Some brand values were normalized"
991+
- catalog_id: "catalog-002"
992+
status: "REJECTED"
993+
error:
994+
code: "INVALID_ITEM"
995+
message: "Invalid item payload at index 3"
996+
paths: "catalogs[1].items[3]"
1102997
responses:
1103998
'200':
1104999
$ref: '#/components/responses/Ack200'
@@ -1492,7 +1387,7 @@ components:
14921387
*context.version* MUST indicate the supported protocol version (e.g., "2.0.0").
14931388
CatalogPublishResponse:
14941389
type: object
1495-
required: [context, results]
1390+
required: [context, message]
14961391
properties:
14971392
context:
14981393
allOf:

schema/core/v2/attributes.yaml

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -810,34 +810,16 @@ components:
810810
x-jsonld:
811811
'@type': 'schema:TrackAction'
812812
properties:
813-
target:
814-
type: object
815-
description: schema.org EntryPoint
816-
x-jsonld:
817-
'@type': 'schema:EntryPoint'
818-
properties:
819-
url:
820-
type: string
821-
format: uri
822-
description: Tracking page URL
823-
x-jsonld:
824-
'@id': 'schema:url'
825-
additionalProperties: true
826-
deliveryMethod:
813+
id:
827814
type: string
828-
enum: ["DELIVERY","PICKUP","RESERVATION","DIGITAL"]
829-
description: |
830-
DELIVERY → last-mile / parcel logistics
831-
PICKUP → customer collects from a place
832-
RESERVATION → entitlement/booking is fulfilled (tickets, seats, appointments)
833-
DIGITAL → digital good / license access
834-
x-jsonld:
835-
'@id': 'schema:deliveryMethod'
836-
reservationId:
815+
description: Tracking action identifier
816+
x-jsonld: { "@id": "schema:identifier" }
817+
url:
837818
type: string
838-
description: Unique identifier for the reservation (schema.org Reservation.reservationId).
819+
format: uri
820+
description: Tracking page URL
839821
x-jsonld:
840-
'@id': 'schema:reservationId'
822+
'@id': 'schema:url'
841823
additionalProperties: true
842824

843825
# -----------------------------

0 commit comments

Comments
 (0)