Skip to content

Commit 0dded8b

Browse files
committed
generating fresh schemas
1 parent 4703147 commit 0dded8b

29 files changed

+487
-1063
lines changed

src/JsonSchema.php

Lines changed: 37 additions & 617 deletions
Large diffs are not rendered by default.

src/Schema.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,12 @@ public function process($data, Context $options, $path = '#', $result = null)
346346
if ($import) {
347347
try {
348348
while (
349-
isset($data->{'$ref'})
350-
&& is_string($data->{'$ref'})
351-
&& !isset($this->properties['$ref'])
349+
isset($data->{self::REF})
350+
&& is_string($data->{self::REF})
351+
&& !isset($this->properties[self::REF])
352352
) {
353-
$refString = $data->{'$ref'};
353+
$refString = $data->{self::REF};
354+
// TODO consider process # by reference here ?
354355
$preRefScope = $options->refResolver->getResolutionScope();
355356
/** @noinspection PhpUnusedLocalVariableInspection */
356357
$deferRefScope = new ScopeExit(function () use ($preRefScope, $options) {
@@ -427,8 +428,8 @@ public function process($data, Context $options, $path = '#', $result = null)
427428
}
428429

429430
$found = false;
430-
if (isset($this->dependencies[$key])) {
431-
$dependencies = $this->dependencies[$key];
431+
if (isset($this->dependencies->$key)) {
432+
$dependencies = $this->dependencies->$key;
432433
if ($dependencies instanceof Schema) {
433434
$dependencies->process($data, $options, $path . '->dependencies:' . $key);
434435
} else {

src/Structure/ClassStructure.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static function schema()
2222
$schema = new ClassSchema();
2323
$properties = new Properties();
2424
$schema->properties = $properties;
25-
$schema->objectItemClass = get_called_class();
25+
$schema->objectItemClass = $className;
2626
static::setUpProperties($properties, $schema);
2727
}
2828

src/SwaggerSchema/ApiKeySecurity.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
33
* @file ATTENTION!!! The code below was carefully crafted by a mean machine.
4-
* Please consider to NOT put any emotional human-generated modifications as AI will throw them away with no mercy.
4+
* Please consider to NOT put any emotional human-generated modifications as the splendid AI will throw them away with no mercy.
55
*/
66

77
namespace Swaggest\JsonSchema\SwaggerSchema;
88

99
use Swaggest\JsonSchema\Constraint\Properties;
10-
use Swaggest\JsonSchema\Schema as JsonBasicSchema;
10+
use Swaggest\JsonSchema\Schema;
1111
use Swaggest\JsonSchema\Structure\ClassStructure;
1212

1313

@@ -26,24 +26,24 @@ class ApiKeySecurity extends ClassStructure {
2626

2727
/**
2828
* @param Properties|static $properties
29-
* @param JsonBasicSchema $ownerSchema
29+
* @param Schema $ownerSchema
3030
*/
31-
public static function setUpProperties($properties, JsonBasicSchema $ownerSchema)
31+
public static function setUpProperties($properties, Schema $ownerSchema)
3232
{
33-
$properties->type = JsonBasicSchema::string();
33+
$properties->type = Schema::string();
3434
$properties->type->enum = array (
3535
0 => 'apiKey',
3636
);
37-
$properties->name = JsonBasicSchema::string();
38-
$properties->in = JsonBasicSchema::string();
37+
$properties->name = Schema::string();
38+
$properties->in = Schema::string();
3939
$properties->in->enum = array (
4040
0 => 'header',
4141
1 => 'query',
4242
);
43-
$properties->description = JsonBasicSchema::string();
43+
$properties->description = Schema::string();
4444
$ownerSchema->type = 'object';
4545
$ownerSchema->additionalProperties = false;
46-
$ownerSchema->patternProperties['^x-'] = new JsonBasicSchema();
46+
$ownerSchema->patternProperties['^x-'] = new Schema();
4747
$ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.';
4848
$ownerSchema->required = array (
4949
0 => 'type',

src/SwaggerSchema/BasicAuthenticationSecurity.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
33
* @file ATTENTION!!! The code below was carefully crafted by a mean machine.
4-
* Please consider to NOT put any emotional human-generated modifications as AI will throw them away with no mercy.
4+
* Please consider to NOT put any emotional human-generated modifications as the splendid AI will throw them away with no mercy.
55
*/
66

77
namespace Swaggest\JsonSchema\SwaggerSchema;
88

99
use Swaggest\JsonSchema\Constraint\Properties;
10-
use Swaggest\JsonSchema\Schema as JsonBasicSchema;
10+
use Swaggest\JsonSchema\Schema;
1111
use Swaggest\JsonSchema\Structure\ClassStructure;
1212

1313

@@ -20,18 +20,18 @@ class BasicAuthenticationSecurity extends ClassStructure {
2020

2121
/**
2222
* @param Properties|static $properties
23-
* @param JsonBasicSchema $ownerSchema
23+
* @param Schema $ownerSchema
2424
*/
25-
public static function setUpProperties($properties, JsonBasicSchema $ownerSchema)
25+
public static function setUpProperties($properties, Schema $ownerSchema)
2626
{
27-
$properties->type = JsonBasicSchema::string();
27+
$properties->type = Schema::string();
2828
$properties->type->enum = array (
2929
0 => 'basic',
3030
);
31-
$properties->description = JsonBasicSchema::string();
31+
$properties->description = Schema::string();
3232
$ownerSchema->type = 'object';
3333
$ownerSchema->additionalProperties = false;
34-
$ownerSchema->patternProperties['^x-'] = new JsonBasicSchema();
34+
$ownerSchema->patternProperties['^x-'] = new Schema();
3535
$ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.';
3636
$ownerSchema->required = array (
3737
0 => 'type',

src/SwaggerSchema/BodyParameter.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
33
* @file ATTENTION!!! The code below was carefully crafted by a mean machine.
4-
* Please consider to NOT put any emotional human-generated modifications as AI will throw them away with no mercy.
4+
* Please consider to NOT put any emotional human-generated modifications as the splendid AI will throw them away with no mercy.
55
*/
66

77
namespace Swaggest\JsonSchema\SwaggerSchema;
88

99
use Swaggest\JsonSchema\Constraint\Properties;
10-
use Swaggest\JsonSchema\Schema as JsonBasicSchema;
10+
use Swaggest\JsonSchema\Schema as Schema1;
1111
use Swaggest\JsonSchema\Structure\ClassStructure;
1212

1313

@@ -29,26 +29,26 @@ class BodyParameter extends ClassStructure {
2929

3030
/**
3131
* @param Properties|static $properties
32-
* @param JsonBasicSchema $ownerSchema
32+
* @param Schema1 $ownerSchema
3333
*/
34-
public static function setUpProperties($properties, JsonBasicSchema $ownerSchema)
34+
public static function setUpProperties($properties, Schema1 $ownerSchema)
3535
{
36-
$properties->description = JsonBasicSchema::string();
36+
$properties->description = Schema1::string();
3737
$properties->description->description = 'A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed.';
38-
$properties->name = JsonBasicSchema::string();
38+
$properties->name = Schema1::string();
3939
$properties->name->description = 'The name of the parameter.';
40-
$properties->in = JsonBasicSchema::string();
40+
$properties->in = Schema1::string();
4141
$properties->in->description = 'Determines the location of the parameter.';
4242
$properties->in->enum = array (
4343
0 => 'body',
4444
);
45-
$properties->required = JsonBasicSchema::boolean();
45+
$properties->required = Schema1::boolean();
4646
$properties->required->description = 'Determines whether or not this parameter is required or optional.';
4747
$properties->required->default = false;
4848
$properties->schema = Schema::schema();
4949
$ownerSchema->type = 'object';
5050
$ownerSchema->additionalProperties = false;
51-
$ownerSchema->patternProperties['^x-'] = new JsonBasicSchema();
51+
$ownerSchema->patternProperties['^x-'] = new Schema1();
5252
$ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.';
5353
$ownerSchema->required = array (
5454
0 => 'name',

src/SwaggerSchema/Contact.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
33
* @file ATTENTION!!! The code below was carefully crafted by a mean machine.
4-
* Please consider to NOT put any emotional human-generated modifications as AI will throw them away with no mercy.
4+
* Please consider to NOT put any emotional human-generated modifications as the splendid AI will throw them away with no mercy.
55
*/
66

77
namespace Swaggest\JsonSchema\SwaggerSchema;
88

99
use Swaggest\JsonSchema\Constraint\Properties;
10-
use Swaggest\JsonSchema\Schema as JsonBasicSchema;
10+
use Swaggest\JsonSchema\Schema;
1111
use Swaggest\JsonSchema\Structure\ClassStructure;
1212

1313

@@ -23,21 +23,21 @@ class Contact extends ClassStructure {
2323

2424
/**
2525
* @param Properties|static $properties
26-
* @param JsonBasicSchema $ownerSchema
26+
* @param Schema $ownerSchema
2727
*/
28-
public static function setUpProperties($properties, JsonBasicSchema $ownerSchema)
28+
public static function setUpProperties($properties, Schema $ownerSchema)
2929
{
30-
$properties->name = JsonBasicSchema::string();
30+
$properties->name = Schema::string();
3131
$properties->name->description = 'The identifying name of the contact person/organization.';
32-
$properties->url = JsonBasicSchema::string();
32+
$properties->url = Schema::string();
3333
$properties->url->description = 'The URL pointing to the contact information.';
3434
$properties->url->format = 'uri';
35-
$properties->email = JsonBasicSchema::string();
35+
$properties->email = Schema::string();
3636
$properties->email->description = 'The email address of the contact person/organization.';
3737
$properties->email->format = 'email';
3838
$ownerSchema->type = 'object';
3939
$ownerSchema->additionalProperties = false;
40-
$ownerSchema->patternProperties['^x-'] = new JsonBasicSchema();
40+
$ownerSchema->patternProperties['^x-'] = new Schema();
4141
$ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.';
4242
$ownerSchema->description = 'Contact information for the owners of the API.';
4343
}

src/SwaggerSchema/ExternalDocs.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
33
* @file ATTENTION!!! The code below was carefully crafted by a mean machine.
4-
* Please consider to NOT put any emotional human-generated modifications as AI will throw them away with no mercy.
4+
* Please consider to NOT put any emotional human-generated modifications as the splendid AI will throw them away with no mercy.
55
*/
66

77
namespace Swaggest\JsonSchema\SwaggerSchema;
88

99
use Swaggest\JsonSchema\Constraint\Properties;
10-
use Swaggest\JsonSchema\Schema as JsonBasicSchema;
10+
use Swaggest\JsonSchema\Schema;
1111
use Swaggest\JsonSchema\Structure\ClassStructure;
1212

1313

@@ -20,16 +20,16 @@ class ExternalDocs extends ClassStructure {
2020

2121
/**
2222
* @param Properties|static $properties
23-
* @param JsonBasicSchema $ownerSchema
23+
* @param Schema $ownerSchema
2424
*/
25-
public static function setUpProperties($properties, JsonBasicSchema $ownerSchema)
25+
public static function setUpProperties($properties, Schema $ownerSchema)
2626
{
27-
$properties->description = JsonBasicSchema::string();
28-
$properties->url = JsonBasicSchema::string();
27+
$properties->description = Schema::string();
28+
$properties->url = Schema::string();
2929
$properties->url->format = 'uri';
3030
$ownerSchema->type = 'object';
3131
$ownerSchema->additionalProperties = false;
32-
$ownerSchema->patternProperties['^x-'] = new JsonBasicSchema();
32+
$ownerSchema->patternProperties['^x-'] = new Schema();
3333
$ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.';
3434
$ownerSchema->description = 'information about external documentation';
3535
$ownerSchema->required = array (

src/SwaggerSchema/FileSchema.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
33
* @file ATTENTION!!! The code below was carefully crafted by a mean machine.
4-
* Please consider to NOT put any emotional human-generated modifications as AI will throw them away with no mercy.
4+
* Please consider to NOT put any emotional human-generated modifications as the splendid AI will throw them away with no mercy.
55
*/
66

77
namespace Swaggest\JsonSchema\SwaggerSchema;
88

99
use Swaggest\JsonSchema\Constraint\Properties;
10-
use Swaggest\JsonSchema\Schema as JsonBasicSchema;
10+
use Swaggest\JsonSchema\Schema;
1111
use Swaggest\JsonSchema\Structure\ClassStructure;
1212

1313

@@ -39,29 +39,29 @@ class FileSchema extends ClassStructure {
3939

4040
/**
4141
* @param Properties|static $properties
42-
* @param JsonBasicSchema $ownerSchema
42+
* @param Schema $ownerSchema
4343
*/
44-
public static function setUpProperties($properties, JsonBasicSchema $ownerSchema)
44+
public static function setUpProperties($properties, Schema $ownerSchema)
4545
{
46-
$properties->format = JsonBasicSchema::string();
47-
$properties->title = JsonBasicSchema::string();
48-
$properties->description = JsonBasicSchema::string();
49-
$properties->default = new JsonBasicSchema();
50-
$properties->required = JsonBasicSchema::arr();
51-
$properties->required->items = JsonBasicSchema::string();
46+
$properties->format = Schema::string();
47+
$properties->title = Schema::string();
48+
$properties->description = Schema::string();
49+
$properties->default = new Schema();
50+
$properties->required = Schema::arr();
51+
$properties->required->items = Schema::string();
5252
$properties->required->minItems = 1;
5353
$properties->required->uniqueItems = true;
54-
$properties->type = JsonBasicSchema::string();
54+
$properties->type = Schema::string();
5555
$properties->type->enum = array (
5656
0 => 'file',
5757
);
58-
$properties->readOnly = JsonBasicSchema::boolean();
58+
$properties->readOnly = Schema::boolean();
5959
$properties->readOnly->default = false;
6060
$properties->externalDocs = ExternalDocs::schema();
61-
$properties->example = new JsonBasicSchema();
61+
$properties->example = new Schema();
6262
$ownerSchema->type = 'object';
6363
$ownerSchema->additionalProperties = false;
64-
$ownerSchema->patternProperties['^x-'] = new JsonBasicSchema();
64+
$ownerSchema->patternProperties['^x-'] = new Schema();
6565
$ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.';
6666
$ownerSchema->description = 'A deterministic version of a JSON Schema object.';
6767
$ownerSchema->required = array (

0 commit comments

Comments
 (0)