Skip to content

Commit

Permalink
docs: add json-schema statement and example (#167)
Browse files Browse the repository at this point in the history
* docs: add json-schema plugin statement to the list of all slangroom statements

* docs(examples): add json-schema plugin example
  • Loading branch information
matteo-cristino authored Jun 24, 2024
1 parent 6bc0612 commit 28400d6
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 37 deletions.
1 change: 1 addition & 0 deletions docs/examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ SPDX-License-Identifier: CC-BY-NC-SA-4.0
<!--@include: git/index.md-->
<!--@include: helpers/index.md-->
<!--@include: http/index.md-->
<!--@include: json-schema/index.md-->
14 changes: 14 additions & 0 deletions docs/examples/json-schema/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!--
SPDX-FileCopyrightText: 2024 Dyne.org foundation
SPDX-License-Identifier: CC-BY-NC-SA-4.0
-->

## json-schema plugin examples

### validate json
::: code-group
<<< @/examples/json-schema/validate.zen{3 gherkin:line-numbers}
<<< @/examples/json-schema/validate.data{json}
<<< @/examples/json-schema/validate.keys{json}
:::
6 changes: 6 additions & 0 deletions docs/examples/json-schema/validate.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"json_data": {
"first_name": "Jhon",
"last_name": "Doe"
}
}
17 changes: 17 additions & 0 deletions docs/examples/json-schema/validate.keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"json_schema": {
"type": "object",
"properties": {
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
}
},
"required": [
"first_name",
"last_name"
]
}
}
6 changes: 6 additions & 0 deletions docs/examples/json-schema/validate.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rule unknown ignore

Given I send json_data 'json_data' and send json_schema 'json_schema' and validate json and output into 'result'

Given I have a 'string dictionary' named 'result'
Then print the 'result'
21 changes: 13 additions & 8 deletions docs/statements/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,20 @@ neither the open/connect part nor the parameters part are present.
| connect | object | do same delete |
| connect | object,headers | do same delete |

## json-schema plugin
| open/connect | params | phrase |
| ------------ | --------------------- | ------------- |
| | json_data,json_schema | validate json |

## oauth plugin
| open/connect | params | phrase |
| ------------ | ------------------------------------- | --------------------------------- |
| | request,server_data | generate access token |
| | request,server_data | verify request parameters |
| | request,server_data | generate authorization code |
| | request,client,server_data,expires_in | generate request uri |
| | token,server_data | get claims from token |
| | request_uri,data,server_data | add data to authorization details |
| open/connect | params | phrase |
| ------------ | ------------------------------------- | ------------------------------------ |
| | request,server_data | generate access token |
| | request,server_data | verify request parameters |
| | request,server_data | generate authorization code |
| | request,client,server_data,expires_in | generate request uri |
| | token,server_data | get authorization details from token |
| | request_uri,data,server_data | add data to authorization details |

## pocketbase plugin
| open/connect | params | phrase |
Expand Down
4 changes: 3 additions & 1 deletion docs/statements/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {fs as sl_fs} from "@slangroom/fs";
import {git} from "@slangroom/git";
import {helpers} from "@slangroom/helpers";
import {http} from "@slangroom/http";
import {JSONSchema} from "@slangroom/json-schema";
import {oauth} from "@slangroom/oauth";
import {pocketbase} from "@slangroom/pocketbase";
import {qrcode} from "@slangroom/qrcode";
Expand All @@ -24,7 +25,7 @@ import {timestamp} from "@slangroom/timestamp";
import {wallet} from "@slangroom/wallet";
import {zencode} from "@slangroom/zencode";

const IGNORED_PKG = ['browser', 'core', 'deps', 'ignored', 'json-schema', 'shared']
const IGNORED_PKG = ['browser', 'core', 'deps', 'ignored', 'shared']

const __dirname = dirname(fileURLToPath(import.meta.url));
const ourDirPath = path.resolve(__dirname, "./");
Expand Down Expand Up @@ -59,6 +60,7 @@ const generateTable = (plugin, name) => {
[git, 'git'],
[helpers, 'helpers'],
[http, 'http'],
[JSONSchema, 'json-schema'],
[oauth, 'oauth'],
[pocketbase, 'pocketbase'],
[qrcode, 'qrcode'],
Expand Down
57 changes: 29 additions & 28 deletions docs/statements/package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
{
"name": "statements",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@slangroom/core": "workspace:^",
"@slangroom/db": "workspace:^",
"@slangroom/ethereum": "workspace:^",
"@slangroom/fs": "workspace:^",
"@slangroom/git": "workspace:^",
"@slangroom/helpers": "workspace:^",
"@slangroom/http": "workspace:^",
"@slangroom/oauth": "workspace:^",
"@slangroom/pocketbase": "workspace:^",
"@slangroom/qrcode": "workspace:^",
"@slangroom/redis": "workspace:^",
"@slangroom/shell": "workspace:^",
"@slangroom/timestamp": "workspace:^",
"@slangroom/wallet": "workspace:^",
"@slangroom/zencode": "workspace:^",
"markdown-table": "^3.0.3"
}
"name": "statements",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@slangroom/core": "workspace:^",
"@slangroom/db": "workspace:^",
"@slangroom/ethereum": "workspace:^",
"@slangroom/fs": "workspace:^",
"@slangroom/git": "workspace:^",
"@slangroom/helpers": "workspace:^",
"@slangroom/http": "workspace:^",
"@slangroom/json-schema": "workspace:^",
"@slangroom/oauth": "workspace:^",
"@slangroom/pocketbase": "workspace:^",
"@slangroom/qrcode": "workspace:^",
"@slangroom/redis": "workspace:^",
"@slangroom/shell": "workspace:^",
"@slangroom/timestamp": "workspace:^",
"@slangroom/wallet": "workspace:^",
"@slangroom/zencode": "workspace:^",
"markdown-table": "^3.0.3"
}
}
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 28400d6

Please sign in to comment.