Input Specification File
The Blockchain App Builder initialization command reads the input specification file and generates the scaffolded project, which includes tools to assist in the chaincode development process.
In 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 the ability to complete rich data queries using SQL SELECT statements or the CouchDB query language. These features are generated for you.
Fabcar-Typescript.yml
Marbles-Go.yml
Note:
In accordance with 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
Typically, you structure a specification file in the following way:
assets:
name:
type:
properties:
name:
type:
id:
derived:
strategy:
algorithm:
format:
mandatory:
default:
validate:
methods:
crud:
others:
customMethods:
Blockchain App Builder supports two special asset types, embedded assets and token
assets, in addition to generic assets with no specified type. The special assets are
defined as type: embedded
or type: token
under the
assets:
section of the specification file.
Table 3-2 Specification File Parameter Descriptions and Examples
Entry | Description | Examples |
---|---|---|
assets: |
This property takes the definition and behavior of the asset. You can define multiple assets. |
|
name: |
The name of the asset. The following names are reserved. Do not use these names for
assets.
|
|
type: |
Asset types The following special asset types are supported:
If you do not specify a |
|
type: type: embedded |
If this property is set to In the example, the property
Embedded assets do not support circular references.
For instance, in the previous example the
|
Asset:
employee
Asset:
address
|
properties: |
Describes all of the properties of an asset. |
|
name: |
The name of the property. |
|
id: |
This specifies the identifier of this asset. This property is mandatory. |
|
type: |
Property types The following basic property types are supported:
For Go chaincodes,
number is mapped
to int and float is mapped to
float64 . Other types are not currently
supported, including the following types:
|
|
derived: |
This property specifies that the id property is derived from other keys. Dependent properties must be of the 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: |
The default value of this property. |
|
validate: |
The given property is validated against some of the ready-to-use 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 must 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 |
The date must be one of these formats:
|
|
methods: |
Use this to state which of the CRUD (Create/Read/Update/Delete) or additional methods to generate. By default all CRUD and other methods are generated. |
|
crud: |
If this array is left empty, no CRUD methods will be created. If the The |
|
others: |
If this array is left empty, no other methods will be created. If the The |
|
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. A custom method named |
TypeScript
Go
|