Skip to content

Commit a01e251

Browse files
committed
FIX issue #193: Add README.md within the tools/ folder
1 parent bcf5f2d commit a01e251

File tree

3 files changed

+100
-4
lines changed

3 files changed

+100
-4
lines changed

tools/README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
## Tools
2+
3+
This `tools/` folder does contain a few tools/scripts that help us to develop the papiNet API standard.
4+
5+
### `analyse-uom.js`
6+
7+
This script will list all the `uom` (unit of measure) within the schemas of the papiNet API OpenAPI documentation.
8+
9+
```text
10+
node analyse-uom.js
11+
```
12+
13+
### `validate.cmd`
14+
15+
This script will validate all the instances within the `..\3.0.0\mock\` folder against their respective schemas from the papiNet API OpenAPI documentation.
16+
17+
This script is using the `yq` and `ajv` commands. The `ajv` command is using [Node.js](https://nodejs.org/en).
18+
19+
```text
20+
validate.cmd
21+
```
22+
23+
#### How to install `yq` on Windows without administrative rights
24+
25+
1\. Download the latest version of the binary `yq_windows_amd64.zip` at <https://github.com/mikefarah/yq/releases/latest>
26+
27+
2\. Create a new subfolder `yq` within the folder `C:\Users\{Username}\AppData\Local\Programs`.
28+
29+
3\. Unzip the file `yq_windows_amd64.exe` from the `yq_windows_amd64.zip` archive into the folder `C:\Users\{Username}\AppData\Local\Programs\yq` and rename it to `yq.exe`.
30+
31+
4\. From a Windows Command Prompt run the following command:
32+
33+
```text
34+
rundll32.exe sysdm.cpl,EditEnvironmentVariables
35+
```
36+
37+
5\. From the "User variables for {Username}" section, click on the "New..." button to create a new variable with the name `YQ_BIN` and the value `C:\Users\{Username}\AppData\Local\Programs\yq`.
38+
39+
6\. From the "User variables for {Username}" section, select the `Path` variable and click on the "Edit.." button, then click on the "New" button and add the line `%YQ_BIN%` at the end.
40+
41+
7\. From a **new** Windows Command Prompt run the following command to verify the installation:
42+
43+
```text
44+
yq --version
45+
```
46+
47+
#### How to install Node.js on Windows without administrative rights
48+
49+
1\. Download the latest version at <https://nodejs.org/en/download>; Click on the "Standalone Binary (.zip)" button while having selected "Windows" as _operating system_ and "x64" as _architecture_.
50+
51+
2\. 3\. Unzip the folder `node-v22.12.0-win-x64` from `node-v22.12.0-win-x64.zip` archive into the folder `C:\Users\{Username}\AppData\Local\Programs`.
52+
53+
3\. From a Windows Command Prompt run the following command:
54+
55+
```text
56+
rundll32.exe sysdm.cpl,EditEnvironmentVariables
57+
```
58+
59+
4\. From the "User variables for {Username}" section, click on the "New..." button to create a new variable with the name `NODE_BIN` and the value `C:\Users\{Username}\AppData\Local\Programs\node-v22.12.0-win-x64`.
60+
61+
5\. From the "User variables for {Username}" section, select the `Path` variable and click on the "Edit.." button, then click on the "New" button and add the line `%NODE_BIN%` at the end.
62+
63+
6\. From a **new** Windows Command Prompt run the following command to verify the installation:
64+
65+
```text
66+
node --version
67+
```
68+
69+
```text
70+
npm --version
71+
```
72+
73+
#### How to install `ajv` on Windows (without administrative rights)
74+
75+
```text
76+
npm install -g ajv-cli
77+
```
78+
79+
```text
80+
npm install -g ajv-formats
81+
```
82+
83+
### `check-instances-with-markdown-and-pact.py` (work in progress)
84+
85+
This Python script analyzes if the instances within the `..\3.0.0\mock\` folder are used within the use case file `..\3.0.0\paper-board-pulp-warehouse-logistics.md` and the Pact file `..\3.0.0\papiNet.PACT.json`.
86+
87+
```text
88+
python check-instances-with-markdown-and-pact.py
89+
```
90+
91+
You can install Python without administrative rights using the Python Windows Installer available at <https://www.python.org/downloads/>.

tools/analyse-uom.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
/*
2+
RUN: node analyse-uom.js
3+
PURPOSE: This script will list all the `uom` (unit of measure) within the
4+
schemas of the papiNet API OpenAPI documentation.
5+
*/
6+
17
const fs = require('fs');
28
const YAML = require('yaml');
39

410
const file = fs.readFileSync('../3.0.0/papiNet-API.yaml', 'utf8');
511

612
const doc = YAML.parse(file);
713

14+
dumpKeys('', doc.components.schemas);
15+
816
function dumpKeys(context, current) {
917
for (key in current) {
1018
if (current[key].type == 'object' || current[key].type == 'array') {
@@ -35,6 +43,3 @@ function dumpKeys(context, current) {
3543
}
3644
}
3745
}
38-
39-
dumpKeys('', doc.components.schemas);
40-

tools/generate-pact-from-md.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def main():
66
# Input file name:
77
input_file_name = "../3.0.0/paper-board-pulp-warehouse-logistics.md"
88
# Output file
9-
output_file_name = "../3.0.0/mock/papiNet.PACT.json"
9+
output_file_name = "../3.0.0/mock/papiNet.PACT.generated.json"
1010

1111
# Pact skeleton:
1212
pact = {

0 commit comments

Comments
 (0)