|
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 Info extends ClassStructure { |
|
15
|
|
|
/** @var string A unique and precise title of the API. */ |
|
16
|
|
|
public $title; |
|
17
|
|
|
|
|
18
|
|
|
/** @var string A semantic version number of the API. */ |
|
19
|
|
|
public $version; |
|
20
|
|
|
|
|
21
|
|
|
/** @var string A longer description of the API. Should be different from the title. GitHub Flavored Markdown is allowed. */ |
|
22
|
|
|
public $description; |
|
23
|
|
|
|
|
24
|
|
|
/** @var string The terms of service for the API. */ |
|
25
|
|
|
public $termsOfService; |
|
26
|
|
|
|
|
27
|
|
|
/** @var Contact Contact information for the owners of the API. */ |
|
28
|
|
|
public $contact; |
|
29
|
|
|
|
|
30
|
|
|
/** @var License */ |
|
31
|
|
|
public $license; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param Properties|static $properties |
|
35
|
|
|
* @param Schema $ownerSchema |
|
36
|
|
|
*/ |
|
37
|
|
|
public static function setUpProperties($properties, Schema $ownerSchema) |
|
38
|
|
|
{ |
|
39
|
|
|
$properties->title = Schema::string(); |
|
40
|
|
|
$properties->title->description = 'A unique and precise title of the API.'; |
|
|
|
|
|
|
41
|
|
|
$properties->version = Schema::string(); |
|
42
|
|
|
$properties->version->description = 'A semantic version number of the API.'; |
|
|
|
|
|
|
43
|
|
|
$properties->description = Schema::string(); |
|
44
|
|
|
$properties->description->description = 'A longer description of the API. Should be different from the title. GitHub Flavored Markdown is allowed.'; |
|
|
|
|
|
|
45
|
|
|
$properties->termsOfService = Schema::string(); |
|
46
|
|
|
$properties->termsOfService->description = 'The terms of service for the API.'; |
|
|
|
|
|
|
47
|
|
|
$properties->contact = Contact::schema(); |
|
48
|
|
|
$properties->license = License::schema(); |
|
49
|
|
|
$ownerSchema->type = 'object'; |
|
|
|
|
|
|
50
|
|
|
$ownerSchema->additionalProperties = false; |
|
51
|
|
|
$ownerSchema->patternProperties['^x-'] = new Schema(); |
|
52
|
|
|
$ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.'; |
|
|
|
|
|
|
53
|
|
|
$ownerSchema->description = 'General information about the API.'; |
|
|
|
|
|
|
54
|
|
|
$ownerSchema->required = array ( |
|
55
|
|
|
0 => 'version', |
|
56
|
|
|
1 => 'title', |
|
57
|
|
|
); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
|
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: