|
1
|
|
|
<?php |
|
2
|
|
|
namespace gossi\swagger; |
|
3
|
|
|
|
|
4
|
|
|
use gossi\swagger\parts\DescriptionPart; |
|
5
|
|
|
use gossi\swagger\parts\ExtensionPart; |
|
6
|
|
|
use gossi\swagger\parts\ItemsPart; |
|
7
|
|
|
use gossi\swagger\parts\RefPart; |
|
8
|
|
|
use gossi\swagger\parts\RequiredPart; |
|
9
|
|
|
use gossi\swagger\parts\SchemaPart; |
|
10
|
|
|
use gossi\swagger\parts\TypePart; |
|
11
|
|
|
use phootwork\collection\CollectionUtils; |
|
12
|
|
|
use phootwork\lang\Arrayable; |
|
13
|
|
|
|
|
14
|
|
|
class Parameter extends AbstractModel implements Arrayable { |
|
15
|
|
|
|
|
16
|
|
|
use RefPart; |
|
17
|
|
|
use DescriptionPart; |
|
18
|
|
|
use SchemaPart; |
|
19
|
|
|
use TypePart; |
|
20
|
|
|
use ItemsPart; |
|
21
|
|
|
use RequiredPart; |
|
22
|
|
|
use ExtensionPart; |
|
23
|
|
|
|
|
24
|
|
|
/** @var string */ |
|
25
|
|
|
private $name; |
|
26
|
|
|
|
|
27
|
|
|
/** @var string */ |
|
28
|
|
|
private $in; |
|
29
|
|
|
|
|
30
|
|
|
/** @var bool */ |
|
31
|
|
|
private $allowEmptyValue = false; |
|
32
|
|
|
|
|
33
|
5 |
|
public function __construct($contents = []) { |
|
34
|
5 |
|
$this->parse($contents); |
|
35
|
5 |
|
} |
|
36
|
|
|
|
|
37
|
5 |
|
private function parse($contents = []) { |
|
38
|
5 |
|
$data = CollectionUtils::toMap($contents); |
|
39
|
|
|
|
|
40
|
5 |
|
$this->name = $data->get('name'); |
|
41
|
5 |
|
$this->in = $data->get('in'); |
|
42
|
5 |
|
$this->allowEmptyValue = $data->has('allowEmptyValue') && $data->get('allowEmptyValue'); |
|
43
|
|
|
|
|
44
|
|
|
// parts |
|
45
|
5 |
|
$this->parseRef($data); |
|
46
|
5 |
|
$this->parseDescription($data); |
|
47
|
5 |
|
$this->parseSchema($data); |
|
48
|
5 |
|
$this->parseRequired($data); |
|
49
|
5 |
|
$this->parseType($data); |
|
50
|
5 |
|
$this->parseItems($data); |
|
51
|
5 |
|
$this->parseExtensions($data); |
|
52
|
5 |
|
} |
|
53
|
|
|
|
|
54
|
5 |
|
public function toArray() { |
|
55
|
5 |
|
return $this->export('name', 'in', 'allowEmptyValue', 'required', 'description', 'schema', |
|
56
|
5 |
|
$this->getTypeExportFields(), 'items'); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* |
|
61
|
|
|
* @return string |
|
62
|
|
|
*/ |
|
63
|
1 |
|
public function getName() { |
|
64
|
1 |
|
return $this->name; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* |
|
69
|
|
|
* @param string $name |
|
70
|
|
|
*/ |
|
71
|
1 |
|
public function setName($name) { |
|
72
|
1 |
|
$this->name = $name; |
|
73
|
1 |
|
return $this; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* |
|
78
|
|
|
* @return string |
|
79
|
|
|
*/ |
|
80
|
1 |
|
public function getIn() { |
|
81
|
1 |
|
return $this->in; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* |
|
86
|
|
|
* @param string $in |
|
87
|
|
|
*/ |
|
88
|
1 |
|
public function setIn($in) { |
|
89
|
1 |
|
$this->in = $in; |
|
90
|
1 |
|
return $this; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* |
|
95
|
|
|
* @return bool |
|
96
|
|
|
*/ |
|
97
|
|
|
public function getAllowEmptyValue() { |
|
98
|
|
|
return $this->allowEmptyValue; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Sets the ability to pass empty-valued parameters. This is valid only for either `query` or |
|
103
|
|
|
* `formData` parameters and allows you to send a parameter with a name only or an empty value. |
|
104
|
|
|
* Default value is `false`. |
|
105
|
|
|
* |
|
106
|
|
|
* @param bool $allowEmptyValue |
|
107
|
|
|
*/ |
|
108
|
|
|
public function setAllowEmptyValue($allowEmptyValue) { |
|
109
|
|
|
$this->allowEmptyValue = $allowEmptyValue; |
|
110
|
|
|
return $this; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
} |
|
114
|
|
|
|