Input Specification File
The Blockchain App Builder initialization command reads the input specification file and generates the scaffolded project with several tools to assist in the chaincode development process.
With the specification file you can specify multiple asset definitions and behavior, CRUD and non-CRUD method declaration, custom methods, validation of arguments, auto marshalling/unmarshalling, transparent persistence capability, and invoking rich data queries using SQL SELECTs or CouchDB Query Language. These features will be generated for you.
yaml
or json
. You can see sample specification files in both formats in the Blockchain App Builder package download:
fabcar.yml
marbles.yml
Note:
As per Go conventions, exported names begin with a capital letter. Therefore all the asset properties and methods must have names starting with capital letters in the specification file.Structure of the Specification File
The specification file should be structured in the following way:
assets:
name:
properties:
name:
type:
id:
derived:
strategy:
algorithm:
format:
mandatory:
default:
validate:
methods:
crud:
others:
type:
customMethods:
Table C-2 Specification File Parameter Descriptions and Examples
Entry | Description | Examples |
---|---|---|
assets: |
This property takes the definition and behavior of the asset. You can give multiple asset definitions here. |
|
name: |
The name of the asset. |
|
properties: |
Describe all the properties of an asset. |
|
name: |
The name of the property. |
|
type: |
Basic types are supported:
For Go chaincodes,
number is mapped to init . Other types such as
|
|
id: |
This specifies the identifier of this asset. This property is mandatory. |
|
derived: |
This property specifies that the id property is derived from other keys. Dependent properties should be This property has two mandatory parameters:
Example 1:
Example 2:
|
Example 1
Example 2
|
mandatory: |
The corresponding property is mandatory and cannot be skipped while creating an asset. |
|
default: |
This gives you the default value of this property. |
|
validate: |
The given property is validated against some of the out-of-box validations provided by Blockchain App Builder. You can chain validations if you ensure that the chain is valid. If the |
|
validate:
type: number |
These validations can be chained together separated by commas. |
|
validate:
type: string |
For Go chaincodes, regular expressions which contain certain reserved characters or whitespace characters should be properly escaped. |
|
validate:
type: boolean |
In the example, the validation of property |
|
validate:
type: array |
By type itself, in the form of You can enter limits to the array in the format |
|
validate:
type: date |
Date should be one of these formats:
|
|
methods: |
Use this to state which of the CRUD (Create/Read/Update/Delete) or additional methods are to be generated. By default, if nothing is entered, all CRUD and other methods are generated. |
|
crud: |
If this array is left empty, no CRUD methods will be created. If the |
|
others: |
If this array is left empty, no other methods will be created. If the |
|
type: |
This attribute if set to In the example, the property |
Asset:
employee
Asset:
address
|
customMethods: |
This property creates invokable custom method templates in the main controller file. It takes the method signature and creates the function declaration in the controller file. You can provide language specific function declarations here. We provide a custom method named |
TypeScript
Go
|