### Install Swagger CLI Tool
Source: https://github.com/beckn/protocol-specifications/blob/master/api/transaction/README.md
Provides the command to install the swagger command-line interface tool globally using npm, which is required for bundling OpenAPI definitions.
```bash
sudo npm install -g swagger-cli
```
--------------------------------
### Schema Index File Example
Source: https://github.com/beckn/protocol-specifications/blob/master/api/registry/README.md
An example of how to structure the `index.yaml` file within the `api/registry/components/schemas/` directory. This file lists all schema files with their respective `$ref` pointers, ensuring they are compiled correctly.
```yaml
Gps:
$ref: "../../../../schema/Gps.yaml"
Location:
$ref: "../../../../schema/Location.yaml"
...
```
--------------------------------
### Install Swagger CLI
Source: https://github.com/beckn/protocol-specifications/blob/master/api/registry/README.md
Command to install the swagger command-line tool globally using npm. This tool is required for bundling OpenAPI specifications.
```bash
sudo npm install -g swagger-cli
```
--------------------------------
### Unresolved OpenAPI Index File Example
Source: https://github.com/beckn/protocol-specifications/blob/master/api/registry/README.md
An example of the `index.yaml` file located in the `api/registry/components/` directory. This file contains the base OpenAPI structure and references to individual API definitions found in the `io` folder, serving as the input for the bundling process.
```APIDOC
openapi: 3.0.0
info:
title: Beckn Protocol Core
description: Beckn Core API specification
version: "1.0.0"
security:
- SubscriberAuth: []
- GatewaySubscriberAuth: []
/lookup:
description: Look up platforms listed on the network registry. This is a protected endpoint only accessible to network participants that have subscribed to the network (i.e Subscribers). Any subscriber can query the Registry by sending a `Lookup` object. The Registry will respond with all the platforms that match the lookup parameters.
post:
tags:
- Registry
requestBody:
content:
application/json:
schema:
$ref : "./io/Lookup.yaml"
...
```
--------------------------------
### HTML Form Example for Package Details
Source: https://github.com/beckn/protocol-specifications/blob/master/docs/BECKN-007-The-XInput-Schema.md
An example of an HTML form used to collect specific details about a package, including item count, dimensions, and category, before order confirmation.
```html
```
--------------------------------
### BLAKE2b-512 Hashing Example
Source: https://github.com/beckn/protocol-specifications/blob/master/docs/BECKN-006-Signing-Beckn-APIs-In-HTTP-Draft-01.md
Demonstrates the output of the BLAKE2b-512 hashing algorithm for a sample input string, shown in both hexadecimal and base64 encoded formats.
```text
BLAKE2b-512("The quick brown fox jumps over the lazy dog") =
a8add4bdddfd93e4877d2746e62817b116364a1fa7bc148d95090bc7333b3673f82401cf7aa2e4cb1ecd90296e3f14cb5413f8ed77be73045b13914cdcd6a918
Base64 encoded:
qK3Uvd39k+SHfSdG5igXsRY2Sh+nvBSNlQkLxzM7NnP4JAHPeqLkyx7NkCluPxTLVBP47Xe+cwRbE5FM3NapGA==
```
--------------------------------
### Beckn Payment Object Examples
Source: https://github.com/beckn/protocol-specifications/blob/master/docs/BECKN-002-Payments-On-Beckn-Enabled-Networks.md
Illustrates various configurations of the Beckn Payment Object for different payment scenarios, including collection by BAP or BPP, and different transaction stages and methods.
```JSON
{
"collected_by": "bap",
"uri": "payto://bank/98273982749428?amount=$currency:$value&ifsc=$ifsc&message=hello",
"tl_method": "PAYTO",
"type": "POST_FULFILLMENT",
"status": "NOT-PAID",
"params": {
"ifsc": "SBIN0000575",
"value": "200",
"currency": "INR"
},
"time": {
"range": {
"end": "2021-11-30 00:00:00"
}
}
}
```
```JSON
{
"uri": "payto://upi/example@upi?amount=$currency:$value&message=hello",
"tl_method": "PAYTO",
"type": "ON-ORDER",
"status": "NOT-PAID",
"params": {
"value": "200",
"currency": "INR"
}
}
```
```JSON
{
"uri": "https://pay.example.com?amount=$value&cur=$currency",
"tl_method": "HTTP/POST",
"type": "ON-ORDER",
"status": "NOT-PAID",
"params": {
"value": "200",
"currency": "INR"
}
}
```
--------------------------------
### Example BAP Search Request Body
Source: https://github.com/beckn/protocol-specifications/blob/master/docs/BECKN-006-Signing-Beckn-APIs-In-HTTP-Draft-01.md
This JSON object represents an example request body sent by a BAP to a BG (Beckn Gateway) for a search action. It includes context like domain, city, transaction ID, and message details specifying fulfillment locations.
```JSON
{
"context": {
"domain": "nic2004:60212",
"country": "IND",
"city": "Kochi",
"action": "search",
"core_version": "0.9.1",
"bap_id": "bap.stayhalo.in",
"bap_uri": "https://8f9f-49-207-209-131.ngrok.io/protocol/",
"transaction_id": "e6d9f908-1d26-4ff3-a6d1-3af3d3721054",
"message_id": "a2fe6d52-9fe4-4d1a-9d0b-dccb8b48522d",
"timestamp": "2022-01-04T09:17:55.971Z",
"ttl": "P1M"
},
"message": {
"intent": {
"fulfillment": {
"start": {
"location": {
"gps": "10.108768, 76.347517"
}
},
"end": {
"location": {
"gps": "10.102997, 76.353480"
}
}
}
}
}
}
```
--------------------------------
### xForms 2.0 Submission URL Example
Source: https://github.com/beckn/protocol-specifications/blob/master/docs/BECKN-007-The-XInput-Schema.md
Demonstrates the syntax for defining a submission URL in xForms 2.0 using the 'action' attribute within the 'xforms:submission' tag. This specifies the endpoint for form data submission.
```XML
```
--------------------------------
### Bundle OpenAPI Definitions with swagger-cli
Source: https://github.com/beckn/protocol-specifications/blob/master/api/transaction/README.md
Command to bundle a set of OpenAPI definitions into a single, resolved YAML file using the swagger-cli tool. It takes an input index file and specifies an output file path.
```bash
swagger-cli bundle api/transaction/components/index.yaml --outfile api/transaction/build/transaction.yaml --type yaml
```
--------------------------------
### Schema Index File Structure
Source: https://github.com/beckn/protocol-specifications/blob/master/api/transaction/README.md
Defines the structure for the schema index file (index.yaml) used to list and reference schema files within the core/v0/api/components/schemas/ directory. Ensures all schemas are compiled.
```yaml
Ack:
$ref: "../../../../Ack.yaml"
AddOn:
$ref: "../../../../AddOn.yaml"
...
```
--------------------------------
### BECKN Candidate Information HTML Form
Source: https://github.com/beckn/protocol-specifications/blob/master/docs/BECKN-007-The-XInput-Schema.md
An example HTML form used in a BECKN protocol scenario for a recruitment agency to collect candidate details before confirming a job application. This form includes fields for location preference, experience, and technologies.
```html
```
--------------------------------
### HTML Form Submission URL Example
Source: https://github.com/beckn/protocol-specifications/blob/master/docs/BECKN-007-The-XInput-Schema.md
Illustrates how the submission URL is specified within an HTML form tag using the 'action' attribute. This is crucial for BAPs to know where to send form data.
```HTML
```
--------------------------------
### Unresolved OpenAPI Definition Structure
Source: https://github.com/beckn/protocol-specifications/blob/master/api/transaction/README.md
Illustrates the structure of an unresolved OpenAPI definition file (index.yaml) located in api/transaction/components/. It includes API metadata and path definitions referencing schema components.
```yaml
openapi: 3.1.0
info:
title: Beckn Protocol Core
description: Beckn Core API specification
version: "1.1.1"
security:
- SubscriberAuth: []
paths:
/search:
post:
tags:
- Beckn Provider Platform (BPP)
- Beckn Gateway (BG)
description: BAP declares the customer's intent to buy/avail products or services
requestBody:
content:
application/json:
schema:
$ref : "./io/Search.yaml"
responses:
default:
$ref: "./io/Response.yaml"
...
```
--------------------------------
### Beckn Payment Collection Example (JSON)
Source: https://github.com/beckn/protocol-specifications/blob/master/docs/BECKN-002-Payments-On-Beckn-Enabled-Networks.md
This JSON payload illustrates a payment collection scenario within the Beckn protocol. It details payment collection by a BAP, the UPI payment URI, currency, amount, and the settlement time range. This structure is used to represent payment-related information in Beckn transactions.
```json
{
"collected_by": "bap",
"uri": "upi://pay?pa=UPIID@oksbi&pn=NAME&&tr=123456789&cu=INR&am=200",
"tl_method": "UPI",
"type": "POST_FULFILLMENT",
"status": "NOT-PAID",
"params": {
"value": "200",
"currency": "INR"
},
"time": {
"range": {
"end": "2022-02-15 00:00:00"
}
}
}
```
--------------------------------
### BECKN Protocol Form Schemas
Source: https://github.com/beckn/protocol-specifications/blob/master/docs/BECKN-007-The-XInput-Schema.md
Defines the core schemas for handling custom user input via forms within the BECKN protocol. This includes XInput for integrating forms into transactions, Form for defining the form structure and content source, FormResponse for capturing submission results, and Error for detailing any issues during submission. Usage examples illustrate integration points within Item, Order, Feedback, and CancellationTerm schemas.
```APIDOC
BECKN Protocol Form Schemas:
XInput:
type: object
properties:
form:
$ref: Form
required:
description: Indicates whether the form data is mandatorily required by the BPP to confirm the order.
type: boolean
default: true
Form:
description: Describes a form that needs to be rendered to the BAP user before the confirmation of an order.
type: object
properties:
url:
description: The URL from where the form can be fetched. The content fetched from the url must be processed as per the mime_type specified in this object. The BAP can choose to render the form as-is as an embeddable element, or process it further to blend it with the style of the application. In case the interface is non-visual, the BAP can process the form data and reproduce it as per the UI requirements.
type: string
format: uri
mime_type:
description: This field indicates the nature and format of the form received by querying the url. MIME types are defined and standardized in IETF's RFC 6838. If the mime_type is text/html, the application must render it inside a web view. If the mime_type is application/xml, then the application must consider it as an xForms 2.0 object and render it as per the XForms 2.0 specification.
type: string
enum:
- text/html
- application/xml
submission_id:
type: string
format: uuid
FormResponse:
description: Describes the response to a form submission
type: object
properties:
status:
description: Contains the status of form submission.
type: boolean
default: true
submission_id:
description: This contains a UUID generated by the BPP on successful submission of the form.
type: string
format: uuid
errors:
type: array
items:
$ref: Error
Error:
description: Describes an error object returned by the API in case of an exception scenario. The exception may be a technical one like a schema or a signature verification error; or business-related like an item not found, or an agent not available.
type: object
properties:
code:
type: string
description: For full list of error codes, refer to docs/protocol-drafts/BECKN-RFC-005-ERROR-CODES-DRAFT-01.md of this repo
path:
type: string
description: Path to json schema generating the error. Used only during json schema validation errors
message:
type: string
description: Human readable message describing the error. Used mainly for logging. Not recommended to be shown to the user.
required:
- code
- path
Usage Examples:
The XInput object can be found in the following schemas:
1. Item
2. Order
3. Feedback
4. CancellationTerm
Usage in the Item schema:
Item:
type: object
properties:
xinput:
$ref: '#/components/schemas/XInput'
...
Usage in the Order schema:
Order:
type: object
properties:
xinput:
$ref: '#/components/schemas/XInput'
...
Usage in the Feedback schema:
Feedback:
type: object
properties:
xinput:
$ref: '#/components/schemas/XInput'
...
Usage in the CancellationTerm schema:
CancellationTerm:
type: object
properties:
xinput:
$ref: '#/components/schemas/XInput'
...
```
--------------------------------
### Bundle OpenAPI Specification
Source: https://github.com/beckn/protocol-specifications/blob/master/api/registry/README.md
Command to bundle the unresolved OpenAPI definition file (`api/registry/components/index.yaml`) into a single, resolved YAML file (`api/registry/build/registry.yaml`) using the swagger-cli.
```bash
swagger-cli bundle api/registry/components/index.yaml --outfile api/registry/build/registry.yaml --type yaml
```
--------------------------------
### BECKN Order Object with Form Data
Source: https://github.com/beckn/protocol-specifications/blob/master/docs/BECKN-007-The-XInput-Schema.md
Illustrates a BECKN protocol order object containing form details, including URL and MIME type, sent from BPP to BAP during the init action. This allows the BAP to fetch and render necessary forms for user input.
```json
{
"context" : {
"action" : "on_init",
"..." : "// other context details"
},
"message" : {
"order" : {
"items" : [
{
"id" : "4aa3feca-96b5-47dd-a233-f7fd2525922c",
"descriptor" : {
"name" : "Hyperlocal delivery"
},
"price" : {
"value" : "50",
"currency" : "INR"
}
}
],
"xinput" : {
"form" : {
"url" : "https://api.example-bpp.com/getForm?id=t8923y4ryu328473y4",
"mime_type" : "text/html"
}
},
"billing" : {
"..." : "// billing details"
},
"fulfillment" : {
"..." : "// fulfillment details"
},
"..." : "// other order level details"
}
}
}
```
--------------------------------
### Beckn Form Submission Process
Source: https://github.com/beckn/protocol-specifications/blob/master/docs/BECKN-007-The-XInput-Schema.md
Details the steps BAPs must follow for submitting form data, including identifying the submission URL from HTML or xForms and digitally signing the request body.
```apidoc
Beckn Form Submission:
1. **Identify Submission URL**:
- For HTML forms: Extract from the `action` attribute of the `