Skip to content

Add generated xdr-json schema files#418

Merged
leighmcculloch merged 2 commits intomainfrom
add-xdr-json-schema
Mar 11, 2025
Merged

Add generated xdr-json schema files#418
leighmcculloch merged 2 commits intomainfrom
add-xdr-json-schema

Conversation

@leighmcculloch
Copy link
Copy Markdown
Member

@leighmcculloch leighmcculloch commented Mar 8, 2025

What

Add generated xdr-json schema files.

Why

So that XDR-JSON schema files can be referenced via a URL for any commit / build / release of the stellar-xdr crate.

So that tooling that embeds the stellar-xdr crate (CLI, Lab, RPC), and supports parsing XDR-JSON and converting from XDR to and from JSON, can also reference a schema URL for IDEs and editors like VS Code that can use JSON schema to auto-complete and provide hints about valid and invalid JSON.

The generated JSON files are checked by CI via the existing generate job, that doesn't need updating to do the checks because it broadly checks for any diff after regeneration.

As a bonus, after this change is merged, any future changes to the XDR will be more clearly evident as to how they impact the XDR-JSON schema.

Known limitations

This change doesn't yet embed a $schema key into JSON generated or parsed yet. It is unclear yet if we will add that here, or not, because not all uses of the XDR-JSON would benefit from it. So applications, like the CLI, that will use it, may do so as needed separately.

This change doesn't result in the JSON being served on a particularly friendly URL, but we will be able to use the stellar.org nginx's ability to redirect paths to redirect a nicer stellar.org URL to the files hosted here.

There's an argument for hosting these files outside this repo, however hosting them here is a trade-off towards simplifying the moving parts that support this.

cc @stellar/devx @fnando

@leighmcculloch leighmcculloch requested review from a team and fnando March 8, 2025 10:50
Copy link
Copy Markdown
Member

@fnando fnando left a comment

Choose a reason for hiding this comment

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

nice!

ps: it's funny how this pr made github unusable. 🫠

@leighmcculloch
Copy link
Copy Markdown
Member Author

@fnando I was debating limiting the files written to the TransactionEnvelope, at least for the moment, so as not to significantly burden the file system with the +457,000 lines. I'm hoping the GH slowness is just because of the size of the PR, and will not continue once merged.

@leighmcculloch leighmcculloch added this pull request to the merge queue Mar 11, 2025
Merged via the queue into main with commit 01f4686 Mar 11, 2025
@leighmcculloch leighmcculloch deleted the add-xdr-json-schema branch March 11, 2025 01:23
leighmcculloch added a commit that referenced this pull request Mar 18, 2025
* Add generated xdr-json schema files

* fix target dependencies order in generate rule

(cherry picked from commit 01f4686)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants