You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/contribute-to-core-lightning/coding-style-guidelines/writing-json-schemas.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,13 +26,13 @@ You should always list all fields which are _always_ present in `"required"`.
26
26
27
27
We extend the basic types; see [fixtures.py](https://github.com/ElementsProject/lightning/tree/master/contrib/pyln-testing/pyln/testing/fixtures.py).
28
28
29
-
In addition, before committing a new schema or a new version of it, make sure that it is well formatted. If you don't want do it by hand, use `make fmt-schema` that uses jq under the hood.
29
+
In addition, before committing a new schema or a new version of it, make sure that it is well formatted. If you don't want to do it by hand, use `make fmt-schema` that uses jq under the hood.
30
30
31
31
### Using Conditional Fields
32
32
33
33
Sometimes one field is only sometimes present; if you can, you should make the schema know when it should (and should not!) be there.
34
34
35
-
There are two kinds of conditional fields expressable: fields which are only present if another field is present, or fields only present if another field has certain values.
35
+
There are two kinds of conditional fields expressible: fields which are only present if another field is present, or fields only present if another field has certain values.
36
36
37
37
To add conditional fields:
38
38
@@ -43,11 +43,11 @@ To add conditional fields:
43
43
5. If a field requires another field value, use the pattern
6. Inside the "then", use `"additionalProperties": false` and place empty `{}` for all the other possible properties.
46
-
7. If you haven't covered all the possibilties with `if` statements, add an `else` with `"additionalProperties": false` which simply mentions every allowable property. This ensures that the fields can _only_ be present when conditions are met.
46
+
7. If you haven't covered all the possibilities with `if` statements, add an `else` with `"additionalProperties": false` which simply mentions every allowable property. This ensures that the fields can _only_ be present when conditions are met.
47
47
48
48
### Exceptions in dynamic schema generation
49
49
50
-
- If response (`RETURN VALUE`) should not be generated dynamically and you want it to be a custom text message instead. You can use `return_value_notes` to add custom text with empty `properties`. Examples: `setpsbtversion`, `commando`, `recover`.
50
+
- If response (`RETURN VALUE`) should not be generated dynamically, and you want it to be a custom text message instead. You can use `return_value_notes` to add custom text with empty `properties`. Examples: `setpsbtversion`, `commando`, `recover`.
51
51
- If only one of multiple request parameters can be provided then utilize `oneOfMany`
52
52
key with condition defining arrays. For example, `plugin` command defines it as
53
53
`"oneOfMany": [["plugin", "directory"]]` and it prints the parameter output as
@@ -60,13 +60,13 @@ To add conditional fields:
60
60
use `dependentUpon` key where object key can be mapped with the array of dependent params.
61
61
For example, `listforwards` command has `start` and `limit` params dependent upon `index` and
62
62
it can be defined as `"dependentUpon": { "index": ["start", "limit"] }` in the json and it will
63
-
generate the markdown syntax as `[*index* [*start*] [*limit*]]`.
63
+
generate the Markdown syntax as `[*index* [*start*] [*limit*]]`.
64
64
65
65
### Re-generate examples listed in rpc schemas (doc/schemas/lightning-*.json)
66
66
67
67
1. The `autogenerate-rpc-examples.py` script regenerates RPC examples for methods listed in `doc/schemas/lightning-*.json` files.
68
68
2. It uses our pre-existing pytest suite to perform this task.
69
-
3. The script runs a test named `test_generate_examples`, which sets up test nodes, records RPC requests, and captures responses.
69
+
3. The script runs a test named `test_generate_examples`, which sets up test nodes, records RPC requests, and captures responses. If you have added an RPC, make sure to add its use to the scripts here.
70
70
4. To prevent accidental overwriting of examples with other tests, set the environment variable `GENERATE_EXAMPLES=True` before running the script.
71
71
5. By default, all methods are regenerated. To specify which methods to regenerate, set the `REGENERATE` environment variable with a comma-separated list of method names. Eg. `REGENERATE='getinfo,connect'` will only regenerate examples for the getinfo and connect RPCs.
72
72
6. The dev-bitcoind-poll is set to 3 seconds. Ensure the `TIMEOUT` environment variable is set to more than 3 seconds to avoid test failures due to a short waiting time for bitcoind responses.
0 commit comments