Skip to content

Conversation

ar45
Copy link

@ar45 ar45 commented Aug 3, 2022

This allows one to use and resolve ids in json schema

SELECT json_schema_resolve_refs('{
                "$id": "http://localhost:1234/root",
                "allOf": [{
                    "$ref": "http://localhost:1234/nested.json#foo"
                }],
                "definitions": {
                    "A": {
                        "$id": "nested.json",
                        "definitions": {
                            "B": {
                                "$id": "#foo",
                                "type": "integer"
                            }
                        }
                    }
                }
            }'
     );

Resolves to

{
  "$id": "http://localhost:1234/root",
  "allOf": [
    {
      "$ref": "http://localhost:1234/nested.json#foo",
      "$_resolvedRef": [
        "definitions",
        "A",
        "definitions",
        "B"
      ]
    }
  ],
  "definitions": {
    "A": {
      "$id": "nested.json",
      "definitions": {
        "B": {
          "$id": "#foo",
          "type": "integer"
        }
      }
    }
  }
}
SELECT validate_json_schema(
    json_schema_resolve_refs('{
                "$id": "http://localhost:1234/root",
                "allOf": [{
                    "$ref": "http://localhost:1234/nested.json#foo"
                }],
                "definitions": {
                    "A": {
                        "$id": "nested.json",
                        "definitions": {
                            "B": {
                                "$id": "#foo",
                                "type": "integer"
                            }
                        }
                    }
                }
            }'
     )
);

@ar45 ar45 force-pushed the draft-7-with-errors branch from 3fe00ba to 698446d Compare August 5, 2022 17:12
@ar45 ar45 force-pushed the draft-7-with-errors branch from 698446d to df22f0f Compare August 5, 2022 17:13
@ar45 ar45 mentioned this pull request Nov 7, 2024
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.

1 participant