Skip to content

Commit

Permalink
Refactored the circular-extended tests to use external $refs rather…
Browse files Browse the repository at this point in the history
… than just internal ones. This tests a few edge cases that weren't covered before
  • Loading branch information
JamesMessinger committed Jan 4, 2016
1 parent cac28c6 commit ca9b322
Show file tree
Hide file tree
Showing 16 changed files with 480 additions and 481 deletions.
30 changes: 2 additions & 28 deletions tests/specs/circular-extended/circular-extended-ancestor.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,6 @@
definitions:
person:
title: person
properties:
name:
type: string
spouse:
$ref: "#/definitions/person"
description: >
This JSON Reference has additional properties (other than $ref).
This creates a new type that extends "person".
pet:
$ref: '#/definitions/pet'
description: >
This JSON Reference has additional properties (other than $ref).
This creates a new type that extends "pet".
$ref: definitions/person-with-spouse.yaml

pet:
title: pet
type: object
properties:
name:
type: string
age:
type: number
species:
type: string
enum:
- cat
- dog
- bird
- fish
$ref: definitions/pet.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,9 @@
definitions:
parent:
title: parent
properties:
name:
type: string
child:
$ref: '#/definitions/child'
description: >
This JSON Reference has additional properties (other than $ref).
This creates a new type that extends "child".
$ref: definitions/parent-with-child.yaml

child:
title: child
properties:
name:
type: string
pet:
$ref: '#/definitions/pet'
description: >
This JSON Reference has additional properties (other than $ref).
This creates a new type that extends "pet".
children:
description: children
type: array
items:
$ref: '#/definitions/child'
description: >
This JSON Reference has additional properties (other than $ref).
This creates a new type that extends "child".
$ref: definitions/child-with-children.yaml

pet:
title: pet
type: object
properties:
name:
type: string
age:
type: number
species:
type: string
enum:
- cat
- dog
- bird
- fish
$ref: definitions/pet.yaml
44 changes: 3 additions & 41 deletions tests/specs/circular-extended/circular-extended-indirect.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,9 @@
definitions:
parent:
title: parent
properties:
name:
type: string
children:
type: array
items:
$ref: "#/definitions/child"
description: >
This JSON Reference has additional properties (other than $ref).
This creates a new type that extends "child".
$ref: definitions/parent-with-children.yaml

child:
title: child
properties:
name:
type: string
pet:
$ref: '#/definitions/pet'
description: >
This JSON Reference has additional properties (other than $ref).
This creates a new type that extends "pet".
parents:
type: array
items:
$ref: "#/definitions/parent"
description: >
This JSON Reference has additional properties (other than $ref).
This creates a new type that extends "parent".
$ref: definitions/child-with-parents.yaml

pet:
title: pet
type: object
properties:
name:
type: string
age:
type: number
species:
type: string
enum:
- cat
- dog
- bird
- fish
$ref: definitions/pet.yaml
7 changes: 1 addition & 6 deletions tests/specs/circular-extended/circular-extended-self.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
definitions:
thing:
title: thing
$ref: "#/definitions/thing"
description: >
This JSON Reference has additional properties (other than $ref).
Normally, this creates a new type that extends the referenced type,
but since this reference points to ITSELF, it doesn't do that.
$ref: "definitions/thing.yaml"
139 changes: 139 additions & 0 deletions tests/specs/circular-extended/circular-extended.bundled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
helper.bundled.circularExtended =
{
"self": {
"definitions": {
"thing": {
"title": "thing",
"$ref": "#/definitions/thing",
"description": "This JSON Reference has additional properties (other than $ref). Normally, this creates a new type that extends the referenced type, but since this reference points to ITSELF, it doesn't do that.\n",
}
}
},

pet: {
"title": "pet",
"type": "object",
"properties": {
"age": {
type: "number"
},
"name": {
type: "string"
},
"species": {
"type": "string",
"enum": [
"cat",
"dog",
"bird",
"fish"
],
},
},
},

ancestor: {
"definitions": {
"person": {
"title": "person",
"properties": {
"spouse": {
"$ref": "#/definitions/person",
"description": "This JSON Reference has additional properties (other than $ref). This creates a new type that extends \"person\".\n",
},
"pet": {
$ref: "#/definitions/pet",
"description": "This JSON Reference has additional properties (other than $ref). This creates a new type that extends \"pet\".\n"
},
"name": {
"type": "string"
}
}
},
"pet": null
}
},

indirect: {
"definitions": {
"parent": {
"title": "parent",
"properties": {
"name": {
"type": "string"
},
"children": {
"items": {
"$ref": "#/definitions/child",
"description": "This JSON Reference has additional properties (other than $ref). This creates a new type that extends \"child\".\n",
},
"type": "array"
}
}
},
"child": {
"title": "child",
"properties": {
"parents": {
"items": {
"$ref": "#/definitions/parent",
"description": "This JSON Reference has additional properties (other than $ref). This creates a new type that extends \"parent\".\n",
},
"type": "array"
},
"pet": {
"$ref": "#/definitions/pet",
"description": "This JSON Reference has additional properties (other than $ref). This creates a new type that extends \"pet\".\n",
},
"name": {
"type": "string"
}
}
},
"pet": null
}
},

indirectAncestor: {
"definitions": {
"pet": null,
"parent": {
"title": "parent",
"properties": {
"name": {
"type": "string"
},
"child": {
"$ref": "#/definitions/child",
"description": "This JSON Reference has additional properties (other than $ref). This creates a new type that extends \"child\".\n",
}
},
},
"child": {
"title": "child",
"properties": {
"pet": {
"$ref": "#/definitions/pet",
"description": "This JSON Reference has additional properties (other than $ref). This creates a new type that extends \"pet\".\n",
},
"name": {
"type": "string"
},
"children": {
"items": {
"$ref": "#/definitions/child",
"description": "This JSON Reference has additional properties (other than $ref). This creates a new type that extends \"child\".\n",
},
"type": "array",
"description": "children"
}
},
}
}
}
};

helper.bundled.circularExtended.ancestor.definitions.pet =
helper.bundled.circularExtended.indirect.definitions.pet =
helper.bundled.circularExtended.indirectAncestor.definitions.pet =
helper.bundled.circularExtended.pet;
Loading

0 comments on commit ca9b322

Please sign in to comment.