- Java version: 21
From root directory, run:
chmod +x copy-resources.sh && \
mvn clean install
mvn compile
curl -X POST 'http://localhost:8081/render?schemaType=CoA&schemaVersion=1.0' \
-H 'Content-Type: application/json' \
-d '{"key":"value", "anotherKey": {"nestedKey":"nestedValue"}}'
mvn exec:java -Dexec.mainClass="com.materialidentity.schemaservice.App"
java -jar target/schema-service-1.0-SNAPSHOT.jar
mvn spring-boot:run
mvn test
To use the UI to interact with the service, run command:
cd ui && npm install
npm start
node scripts/render-demo.js --certificatePath path_to_certificate --schemaType type --schemaVersion version
Example:
node scripts/render-demo.js --certificatePath ../test/fixtures/EN10168/v0.4.1/valid_certificate_2.json --schemaType EN10168 --schemaVersion v4.0.1
http://localhost:8081/api-docs http://localhost:8081/swagger-ui/index.html
All schemas, certificates, stylesheets and fixtures can be found in the ./schemas
folder.
The filepath convention is as follows: ./schemas/<schema-type>/<version>/
.
If you are a part of S1EVEN team and would like to test the app with private schemas, log in to dotenv using npx dotenv-vault login
and pull using npx dotenv-vault@latest pull
to get environment variables for running the script.
This will run the copy-from-s3bucket script which will pull all private schemas and fixtures.
To add a new version, create a new folder with the version as the name. When the schemas-service app is built,
the script copy-resources.sh
will be run automatically and will copy across the needed stylesheet.xsl
and translations.json
files.
The file schema.json
is obligatory, and for PDF validation valid stylesheet.xsl
and translations.json
files.
Rendering text fixtures should be added using the same file structure in the fixtures
folder. Any valid_certificate_*.json
files will be rendered and the result checked against the corresponding valid_certificate_*.pdf
file.
The creation of a PDF from JSON is based on Apache FOP. The steps are:
-
JSON to XML Transformation
The JSON is transformed to XML
-
XML + XSLT to FO Transformation
The XSLT found next to the corresponding
schema.json
is applied to the XML from step 1. The output is a XSL-FO document. -
FO to PDF Transformation
An Apache FOP processes the XSL-FO to create the PDF.
The script generates the XML output of step 1.
npm run json2xml <relative filepath to schema>
Example:
npm run json2xml test/fixtures/CoA/v1.1.0/valid_certificate_1.json
It will save the resulting file to the same directory as the original .json file.