Skip to content

OpenRPC schema validation #588

Discussion options

You must be logged in to vote

My (basic, no production code) solution was just building a new schema.
It just takes all parameters and moves them to "properties" and moves all schemas to "$defs". It also changes the path of all references from the OpenRPC root "#/components/schemas/" to the valid schema root "#/$defs/".

static void ReplaceReferences(ojson& param_schema, const std::string& to_replace, const std::string& replacement)
{
    if (not param_schema.is_object())
        return; // base case
    
    for (auto& member : param_schema.object_range())
    {
        if (member.key() == "$ref")
        {
            std::string reference{ member.value().as_string() };
            size_t pos = reference.find(to_repl…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@lschrafstetter-qs
Comment options

@lschrafstetter-qs
Comment options

Answer selected by lschrafstetter-qs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants