1
|
|
|
<?php |
2
|
|
|
namespace gossi\swagger; |
3
|
|
|
|
4
|
|
|
use gossi\swagger\parts\ConsumesPart; |
5
|
|
|
use gossi\swagger\parts\ExtensionPart; |
6
|
|
|
use gossi\swagger\parts\ExternalDocsPart; |
7
|
|
|
use gossi\swagger\parts\ParametersPart; |
8
|
|
|
use gossi\swagger\parts\ProducesPart; |
9
|
|
|
use gossi\swagger\parts\ResponsesPart; |
10
|
|
|
use gossi\swagger\parts\SchemesPart; |
11
|
|
|
use gossi\swagger\parts\TagsPart; |
12
|
|
|
use phootwork\collection\CollectionUtils; |
13
|
|
|
use phootwork\lang\Arrayable; |
14
|
|
|
|
15
|
|
|
class Operation extends AbstractModel implements Arrayable { |
16
|
|
|
|
17
|
|
|
use ConsumesPart; |
18
|
|
|
use ProducesPart; |
19
|
|
|
use TagsPart; |
20
|
|
|
use ParametersPart; |
21
|
|
|
use ResponsesPart; |
22
|
|
|
use SchemesPart; |
23
|
|
|
use ExternalDocsPart; |
24
|
|
|
use ExtensionPart; |
25
|
|
|
|
26
|
|
|
/** @var string */ |
27
|
|
|
private $summary; |
28
|
|
|
|
29
|
|
|
/** @var string */ |
30
|
|
|
private $description; |
31
|
|
|
|
32
|
|
|
/** @var string */ |
33
|
|
|
private $operationId; |
34
|
|
|
|
35
|
|
|
/** @var boolean */ |
36
|
8 |
|
private $deprecated = false; |
37
|
8 |
|
|
38
|
8 |
|
public function __construct($contents = []) { |
39
|
|
|
$this->parse($contents); |
40
|
8 |
|
} |
41
|
8 |
|
|
42
|
|
|
private function parse($contents = []) { |
43
|
8 |
|
$data = CollectionUtils::toMap($contents); |
44
|
8 |
|
|
45
|
8 |
|
$this->summary = $data->get('summary'); |
46
|
8 |
|
$this->description = $data->get('description'); |
47
|
|
|
$this->operationId = $data->get('operationId'); |
48
|
|
|
$this->deprecated = $data->has('deprecated') && $data->get('deprecated'); |
49
|
8 |
|
|
50
|
8 |
|
// parts |
51
|
8 |
|
$this->parseConsumes($data); |
52
|
8 |
|
$this->parseProduces($data); |
53
|
8 |
|
$this->parseTags($data); |
54
|
8 |
|
$this->parseParameters($data); |
55
|
8 |
|
$this->parseResponses($data); |
56
|
8 |
|
$this->parseSchemes($data); |
57
|
|
|
$this->parseExternalDocs($data); |
58
|
6 |
|
$this->parseExtensions($data); |
59
|
6 |
|
} |
60
|
6 |
|
|
61
|
|
|
public function toArray() { |
62
|
|
|
return $this->export('summary', 'description', 'operationId', 'deprecated', |
63
|
|
|
'consumes', 'produces', 'parameters', 'responses', 'schemes' 'tags', |
|
|
|
|
64
|
|
|
'externalDocs'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* |
69
|
|
|
* @return the string |
70
|
|
|
*/ |
71
|
|
|
public function getSummary() { |
72
|
|
|
return $this->summary; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* |
77
|
|
|
* @param string $summary |
78
|
|
|
* @return $this |
79
|
|
|
*/ |
80
|
|
|
public function setSummary($summary) { |
81
|
|
|
$this->summary = $summary; |
82
|
|
|
return $this; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* |
87
|
|
|
* @return string |
88
|
|
|
*/ |
89
|
|
|
public function getDescription() { |
90
|
|
|
return $this->description; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* |
95
|
|
|
* @param string $description |
96
|
|
|
*/ |
97
|
|
|
public function setDescription($description) { |
98
|
|
|
$this->description = $description; |
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* |
104
|
|
|
* @return string |
105
|
|
|
*/ |
106
|
|
|
public function getOperationId() { |
107
|
|
|
return $this->operationId; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* |
112
|
|
|
* @param string $operationId |
113
|
|
|
* @return $this |
114
|
|
|
*/ |
115
|
|
|
public function setOperationId($operationId) { |
116
|
|
|
$this->operationId = $operationId; |
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* |
122
|
|
|
* @return boolean |
123
|
|
|
*/ |
124
|
|
|
public function getDeprecated() { |
125
|
|
|
return $this->deprecated; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* |
130
|
|
|
* @param boolean $deprecated |
131
|
|
|
* @return $this |
132
|
|
|
*/ |
133
|
|
|
public function setDeprecated($deprecated) { |
134
|
|
|
$this->deprecated = $deprecated; |
135
|
|
|
return $this; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
|
139
|
|
|
} |
140
|
|
|
|