Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON schemas in doc/ (only some commands so far) #4501

Merged
merged 19 commits into from
May 27, 2021

Conversation

rustyrussell
Copy link
Contributor

@rustyrussell rustyrussell commented May 1, 2021

This is the result of my json schema adventures so far; we'll see what it looks like when I've done commands D H through Z :)

It both checks the schema validity on every command during a test run, and generates documentation for us.

Inspired by #4286

@rustyrussell rustyrussell added this to the v0.10.1 milestone May 1, 2021
@rustyrussell rustyrussell requested a review from cdecker as a code owner May 1, 2021 07:30
@rustyrussell rustyrussell force-pushed the guilt/formal-json branch 3 times, most recently from f70d8ad to 459c07c Compare May 2, 2021 03:16
@rustyrussell rustyrussell force-pushed the guilt/formal-json branch 3 times, most recently from 4cea97e to 37e14c6 Compare May 13, 2021 05:36
@rustyrussell rustyrussell added json-rpc Optech Make Me Famous! Look! Look! Look! COOL NEW FEATURE! labels May 14, 2021
It needs to be defined before we include them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Copy link
Member

@cdecker cdecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great improvement, I don't envy you for having to dig through all these commands, but the final result is just awesome 👍

ACK a65fd7f

the amount the destination received, in "NNNmsat" format.

These three can all be extracted from *bolt11*, hence are obsolete.
[comment]: # (GENERATE-FROM-SCHEMA-START)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very interesting, I didn't know this worked in md.

Comment on lines +76 to +77
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation made this diff a bit hard to read, but can be formatted in a new pass later.

For markdown, there's no simple comment prefix: we need a postfix too.
We also need to use "" since we want to use ' in some of the Makefiles
in future when V=1.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Nested lists don't work (it puts the .RS at the end of the line
instead of on a line by itself), so we sed it.

	refi64/mrkd#4

This fixes up formatting on a number of existing pages..

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
result should *always* be an object.  This allows it to add fields
without breaking the API.  A command which returns "result" as a
string is living in sin.

This changes one of the two callers of "command_success_str".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This is hard to parse, and not extensible in future, and disagrees with
the man page (and caught by schema).

Technically this is an API break, but it can't be done neatly anyway
and it's unlikely someone is relying on this today :(

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: JSONRPC: `autocleaninvoice` now returns an object, not a raw string.
As mentioned in previous commits: "result" must be an object,
and anything else is an antipattern.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Undocumented (caught by json schema!) if we discard channel because it
wasn't open yet, then close returned the empty object.  Make it return
a new type in this case.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSONRPC: `close` returns `type` "unopened" if it simply discards channel instead of empty object.
Otherwise our schema is pretty meaningless, since invalid decodes
can have missing "required" fields.

Also fix a typo "blinded_payindo".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Experimental: JSON-RPC: `decode` now gives a `valid` boolean (it does partial decodes of some invalid data).
This adds our first (basic) schema, and sews support into pyln-testing
so it will load schemas for any method for doc/schemas/{method}.schema.json.

All JSON responses in a test run are checked against the schema (if any).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…th schema.

It can also be run standalone for debugging.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We start with the listpays manpage.  Which is now complete!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
addgossip, check, createinvoice, createonion.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
One of the more complex ones.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…annel, fundchannel_cancel, fundchannel_complete, fundchannel_start, fundpsbt, getinfo, getlog, getroute.

We also add a test for getlog, since it was never called by the
testsuite.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@rustyrussell
Copy link
Contributor Author

Rebase and fixed obv typo in Makefile.

Ack b22e8ac

@rustyrussell rustyrussell merged commit a027b3a into ElementsProject:master May 27, 2021
laanwj added a commit to laanwj/cln4rust that referenced this pull request Nov 11, 2021
28b0b06 pay: 0.10.0 fix incompatible response (elsirion)

Pull request description:

  A few fields of the pay response were removed and one added since this crate was last updated. This PR fixes the pay command. Others might be incompatible too, but would require more extensive testing. Easy testing will be possible once ElementsProject/lightning#4501 lands.

ACKs for top commit:
  laanwj:
    Code review ACK 28b0b06

Tree-SHA512: 184ea4665425185c13a61639aac5660ffeec42446f19342de8da37cb49a17de0caa9f81d3255ceb6e3f77f52a97bfb5936f402150b1e64793cbf4f1c263e3559
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
json-rpc Optech Make Me Famous! Look! Look! Look! COOL NEW FEATURE!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants