This allows the generation of a form from a model file.
Currently, the form for one of the assets is generated. Tool can be accessed via a rest api.
Server-side rendering might be required if we want to continue to use composer-common as some of the packages in common are not designed to be run on a browser.
Some highlights
Custom class passing
Tool accepts an object with custom classes for input field and label. Will be extended to support more customization.
Accepts file or string
Will be useful to testing in an web page where we copy and paste the model file
Can also be useful when we are testing using the cli
To test
Clone branch
Run npm install and then npm run test
Tests will be ran
Start the server: node api/server.js in the main package folder
Using postman or curl, make a post request to http://localhost:7777/api/form with the following body:
{
"file": "namespace org.accordproject.finance.bond import org.accordproject.organization.Organization from https://models.accordproject.org/organization.cto import org.accordproject.time.Duration from https://models.accordproject.org/time.cto import org.accordproject.money.CurrencyCode from https://models.accordproject.org/money.cto enum CouponType { o FIXED o FLOATING } concept PaymentFrequency { o Integer periodMultiplier o Duration period } /** * Definition of a Bond, based on the FpML schema: * http://www.fpml.org/spec/fpml-5-3-2-wd-2/html/reporting/schemaDocumentation/schemas/fpml-asset-5-3_xsd/elements/bond.html * */ concept Bond { o String[] instrumentId o String description optional o CurrencyCode currency optional o String[] exchangeId o String clearanceSystem optional o String definition optional o String seniority optional o CouponType couponType optional o Double couponRate optional o DateTime maturity o Double parValue o Double faceAmount o PaymentFrequency paymentFrequency o String dayCountFraction --> Organization issuer } asset BondAsset identified by ISINCode { o String ISINCode o Bond bond }"
}
You should get a html form as string. This can be rendered in any
N/B:
Currently using the bond model and hardcoding the Type to use. Will update to work with any model.
This allows the generation of a form from a model file.
Currently, the form for one of the assets is generated. Tool can be accessed via a rest api.
Server-side rendering might be required if we want to continue to use
composer-common
as some of the packages in common are not designed to be run on a browser.Some highlights
input
field andlabel
. Will be extended to support more customization.To test
npm install
and thennpm run test
node api/server.js
in themain
package folderhttp://localhost:7777/api/form
with the following body:N/B: Currently using the
bond
model and hardcoding the Type to use. Will update to work with any model.