|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @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. |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace Swaggest\JsonSchema\SwaggerSchema; |
|
8
|
|
|
|
|
9
|
|
|
use Swaggest\JsonSchema\Constraint\Properties; |
|
10
|
|
|
use Swaggest\JsonSchema\Schema; |
|
|
|
|
|
|
11
|
|
|
use Swaggest\JsonSchema\Structure\ClassStructure; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
class Contact extends ClassStructure { |
|
15
|
|
|
/** @var string The identifying name of the contact person/organization. */ |
|
16
|
|
|
public $name; |
|
17
|
|
|
|
|
18
|
|
|
/** @var string The URL pointing to the contact information. */ |
|
19
|
|
|
public $url; |
|
20
|
|
|
|
|
21
|
|
|
/** @var string The email address of the contact person/organization. */ |
|
22
|
|
|
public $email; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param Properties|static $properties |
|
26
|
|
|
* @param Schema $ownerSchema |
|
27
|
|
|
*/ |
|
28
|
|
|
public static function setUpProperties($properties, Schema $ownerSchema) |
|
29
|
|
|
{ |
|
30
|
|
|
$properties->name = Schema::string(); |
|
31
|
|
|
$properties->name->description = 'The identifying name of the contact person/organization.'; |
|
|
|
|
|
|
32
|
|
|
$properties->url = Schema::string(); |
|
33
|
|
|
$properties->url->description = 'The URL pointing to the contact information.'; |
|
|
|
|
|
|
34
|
|
|
$properties->url->format = 'uri'; |
|
35
|
|
|
$properties->email = Schema::string(); |
|
36
|
|
|
$properties->email->description = 'The email address of the contact person/organization.'; |
|
|
|
|
|
|
37
|
|
|
$properties->email->format = 'email'; |
|
38
|
|
|
$ownerSchema->type = 'object'; |
|
|
|
|
|
|
39
|
|
|
$ownerSchema->additionalProperties = false; |
|
40
|
|
|
$ownerSchema->patternProperties['^x-'] = new Schema(); |
|
41
|
|
|
$ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.'; |
|
|
|
|
|
|
42
|
|
|
$ownerSchema->description = 'Contact information for the owners of the API.'; |
|
|
|
|
|
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
|
Let’s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let’s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: