Skip to content

Commit 4711c51

Browse files
authored
Merge pull request #38 from swaggest/export-references
exporting references, resolves #37
2 parents 1b3946f + ded1df7 commit 4711c51

21 files changed

+391
-69
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"require": {
66
"php": ">=5.4",
77
"phplang/scope-exit": "^1.0",
8-
"swaggest/json-diff": "^3.1.1"
8+
"swaggest/json-diff": "^3.4.2"
99
},
1010
"require-dev": {
1111
"phpunit/phpunit": "4.8.35",

composer.lock

Lines changed: 46 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/swagger-schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,8 @@
15991599
"additionalProperties": false,
16001600
"properties": {
16011601
"$ref": {
1602-
"type": "string"
1602+
"type": "string",
1603+
"format": "uri-reference"
16031604
}
16041605
}
16051606
}

src/Constraint/Properties.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,9 @@ public function getNestedProperties()
9090
{
9191
return $this->nestedProperties;
9292
}
93+
94+
public function isEmpty()
95+
{
96+
return (count($this->__arrayOfData) + count($this->nestedProperties)) === 0;
97+
}
9398
}

src/Context.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ class Context extends MagicMap
2121
/** @var bool Apply default values */
2222
public $applyDefaults = true;
2323

24-
/** @var string */
25-
public $propagateObjectItemClass;
26-
2724
/** @var \SplObjectStorage */
2825
public $circularReferences;
2926

@@ -50,6 +47,7 @@ class Context extends MagicMap
5047

5148
public $version = Schema::VERSION_AUTO;
5249

50+
public $exportedDefinitions = [];
5351
/**
5452
* @param boolean $skipValidation
5553
* @return Context

src/JsonSchema.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Swaggest\JsonSchema;
88

9+
use Swaggest\JsonSchema\Constraint\Format;
910
use Swaggest\JsonSchema\Constraint\Properties;
1011
use Swaggest\JsonSchema\Constraint\Type;
1112
use Swaggest\JsonSchema\Schema as JsonBasicSchema;
@@ -279,6 +280,7 @@ public static function setUpProperties($properties, JsonBasicSchema $ownerSchema
279280
$properties->type->anyOf[1]->uniqueItems = true;
280281
$properties->format = JsonBasicSchema::string();
281282
$properties->ref = JsonBasicSchema::string();
283+
$properties->ref->format = Format::URI_REFERENCE;
282284
$ownerSchema->addPropertyMapping('$ref', self::names()->ref);
283285
$properties->allOf = JsonBasicSchema::arr();
284286
$properties->allOf->items = JsonBasicSchema::schema();
@@ -296,6 +298,7 @@ public static function setUpProperties($properties, JsonBasicSchema $ownerSchema
296298
$ownerSchema->description = 'Core schema meta-schema';
297299
$ownerSchema->default = (object)array (
298300
);
301+
$ownerSchema->setFromRef(false);
299302
// disabled by draft6
300303
/*
301304
$ownerSchema->dependencies = (object)array (

0 commit comments

Comments
 (0)