-
Notifications
You must be signed in to change notification settings - Fork 27
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
fix(json schema): manually implement generic types #349
Conversation
093f9ed
to
8fde0c3
Compare
VecM
516ab95
to
66a4913
Compare
@leighmcculloch I updated to use base64 since there doesn't seem to be hex support, but base64 is supported. |
Do you mean that json schemas in general don't support hex, or the lib we're using doesn't? The JSON rendered from the xdr lib is already outputting hex today, not base64. |
JSON schema the spec provides a "format" property for strings. Is hex for historical reasons? We can also allow for both. |
I think |
A similar issue is that strings generated are printable-ASCII escaped strings, not UTF-8 encoded. For example, the following is valid XDR for an ScVal::String:
It contains a four character string where the hex values are for those four characters:
The second character is It decodes to the following JSON:
|
I think the above means the JSON generated can't be completely described by a JSON schema, but maybe that's okay. It can still be described sufficiently for a lot of uses? Applications will just need to figure out somehow that certain fields result in certain types of data? Can we use a non-standard |
Hex is because most binary values in the XDR are more commonly displayed as hex in UIs, things like hashes, or 32-byte IDs. But a reason not to change it is this JSON is in use, so changing it would be breaking and potentially disruptive. It'd be best not to change the output unless there's a big win involved. |
Copied from 66a4913f1bd0de167ff50edd05c93dd958bec0eb Copied from stellar/rs-stellar-xdr#349 Co-authored-by: Willem Wyndham <[email protected]>
Closing as this has been merged into stellar/xdrgen#193. |
* Generate schemars derives in Rust generator * update tsets * move jsonschema behind own feature and add support for custom * Add manual JsonSchema impls Copied from 66a4913f1bd0de167ff50edd05c93dd958bec0eb Copied from stellar/rs-stellar-xdr#349 Co-authored-by: Willem Wyndham <[email protected]> * fix dead code * simplified features * gen for fixed opaque typedefs * fix cas * fix * fix * add type macro * add simple methnod for generating json schema * upd tests * simplified the fns * fix tests * fix * fix * test * fix * defer adding macro that isn't required by this pr --------- Co-authored-by: Willem Wyndham <[email protected]>
This creates a
JsonSchema
impl
forVecM
,BytesM
,Frame
, andStringM
and ensures that they are in-lined.