fix(api): align api names and serialisation#1029
Merged
Merged
Conversation
e0fa92a to
ad215c0
Compare
Adds a custom "canonical JSON" ser/des for use in our API The reason we need this is enforcing correct formatting with #[serde(with ...)] and #[serde(rename_all = "camelCase")] was error prone and oftentimes required duplicate structures to prevent these attributes from interfereing with other ser/des targets (i.e the toml config) NOTE: claude produced this version of the code, I still need to more thoroughly review it.
3 tasks
JesseTheRobot
added a commit
that referenced
this pull request
Dec 10, 2025
* fix(api): align api names and serialisation * feat: custom serde serializer/deserializer impl Adds a custom "canonical JSON" ser/des for use in our API The reason we need this is enforcing correct formatting with #[serde(with ...)] and #[serde(rename_all = "camelCase")] was error prone and oftentimes required duplicate structures to prevent these attributes from interfereing with other ser/des targets (i.e the toml config) NOTE: claude produced this version of the code, I still need to more thoroughly review it. * feat: add custom ApiErrors, convert block_index_route * wip: fixes * wip: tweaks * wip: fixes * feat: add Canonical serialization wrapper for `/network/config` * chore: dead code cleanup * chore: add doc comment to canonical --------- Co-authored-by: JesseTheRobot <jesse.cruz.wright@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the changes
Aligns Public API routes to use canonical formatting (e.g /chunk/data_root -> /chunk/data-root) (private/gossip API is untouched)
Additionally changes struct serialisation to be "canonical" - camelCase formatting, numeric types >=u64 are serialized as strings (due to JS numeric constraints), and changes all use of plain text responses (errors or success) to use JSON instead so we can easily extend them in the future.
NOTE: there is a large custom serializer in types/canonical.rs that is used to serialize the ConsensusConfig using the rules outlined above. it's only used there as we also deserialize this structure from the config toml, and attributes to change it to use camelCase will cause snake_case toml entries to fail.
Related Issue(s)
Please link to the issue(s) that will be closed with this PR.
Checklist
Additional Context
Add any other context about the pull request here.