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\RequiredPart; |
8
|
|
|
use gossi\swagger\parts\TypePart; |
9
|
|
|
use phootwork\collection\CollectionUtils; |
10
|
|
|
use gossi\swagger\parts\SchemaPart; |
11
|
|
|
use gossi\swagger\parts\RefPart; |
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 boolean */ |
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
|
|
|
|
45
|
|
|
// parts |
46
|
5 |
|
$this->parseRef($data); |
47
|
5 |
|
$this->parseDescription($data); |
48
|
5 |
|
$this->parseSchema($data); |
49
|
5 |
|
$this->parseRequired($data); |
50
|
5 |
|
$this->parseType($data); |
51
|
5 |
|
$this->parseItems($data); |
52
|
5 |
|
$this->parseExtensions($data); |
53
|
5 |
|
} |
54
|
|
|
|
55
|
4 |
|
public function toArray() { |
56
|
4 |
|
return $this->export('name', 'in', 'allowEmptyValue', 'required', 'description', 'schema', |
57
|
4 |
|
$this->getTypeExportFields(), 'items'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* |
62
|
|
|
* @return string |
63
|
|
|
*/ |
64
|
1 |
|
public function getName() { |
65
|
1 |
|
return $this->name; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* |
70
|
|
|
* @param string $name |
71
|
|
|
*/ |
72
|
1 |
|
public function setName($name) { |
73
|
1 |
|
$this->name = $name; |
74
|
1 |
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* |
79
|
|
|
* @return string |
80
|
|
|
*/ |
81
|
1 |
|
public function getIn() { |
82
|
1 |
|
return $this->in; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* |
87
|
|
|
* @param string $in |
88
|
|
|
*/ |
89
|
1 |
|
public function setIn($in) { |
90
|
1 |
|
$this->in = $in; |
91
|
1 |
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* |
96
|
|
|
* @return boolean |
97
|
|
|
*/ |
98
|
|
|
public function getAllowEmptyValue() { |
99
|
|
|
return $this->allowEmptyValue; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Sets the ability to pass empty-valued parameters. This is valid only for either `query` or |
104
|
|
|
* `formData` parameters and allows you to send a parameter with a name only or an empty value. |
105
|
|
|
* Default value is `false`. |
106
|
|
|
* |
107
|
|
|
* @param boolean $allowEmptyValue |
108
|
|
|
*/ |
109
|
|
|
public function setAllowEmptyValue($allowEmptyValue) { |
110
|
|
|
$this->allowEmptyValue = $allowEmptyValue; |
111
|
|
|
return $this; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
} |