Skip to content

Defs parser is sensitive to declaration order #71

@ngConsulti

Description

@ngConsulti

It would seem that definitions are processed depth-first, rather then breadth-first. As the code is today, dependencies must be defined before their dependents.

This schema works...

{
    "type":"object",
    "title":"Itinerary",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "definitions": {
        "Leg": {
            "type":"object",
            "properties": {
                "Carrier": {
                    "type":"string"
                }
            }
        },
        "Segment": {
            "type":"object",
            "properties":{
                "Legs": {
                    "type":"array",
                    "items":{
                        "$ref":"#/definitions/Leg"
                    }
                }
            }
        },
        "Trip": {
            "type":"object",
            "properties": {
                "Segments": {
                    "type":"array",
                    "items":{
                        "$ref":"#/definitions/Segment"
                    }
                }
            }
        }
    },
    "properties": {
        "Trips": {
            "type":"array",
            "items": {
                "$ref":"#/definitions/Trip"
            }
        }
    }
}

...while this one doesn't. It fails with:
Uncaught Must set ajax option to true to load external url #/definitions/Segment

{
    "type":"object",
    "title":"Itinerary",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "definitions": {
        "Trip": {
            "type":"object",
            "properties": {
                "Segments": {
                    "type":"array",
                    "items":{
                        "$ref":"#/definitions/Segment"
                    }
                }
            }
        },
        "Segment": {
            "type":"object",
            "properties":{
                "Legs": {
                    "type":"array",
                    "items":{
                        "$ref":"#/definitions/Leg"
                    }
                }
            }
        },
        "Leg": {
            "type":"object",
            "properties": {
                "Carrier": {
                    "type":"string"
                }
            }
        }
    },
    "properties": {
        "Trips": {
            "type":"array",
            "items": {
                "$ref":"#/definitions/Trip"
            }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions