Skip to content

Commit 9efef02

Browse files
committed
formate the module.mustache
1 parent df1d36c commit 9efef02

File tree

19 files changed

+68
-348
lines changed

19 files changed

+68
-348
lines changed

modules/swagger-codegen/src/main/resources/php/model.mustache

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,18 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
163163
public function list_invalid_properties()
164164
{
165165
$invalid_properties = array();
166-
{{#vars}}{{#required}}
166+
{{#vars}}
167+
{{#required}}
167168
if ($this->container['{{name}}'] === null) {
168169
$invalid_properties[] = "'${{name}}' can't be null";
169-
}{{/required}}
170-
{{#isEnum}}$allowed_values = array({{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}});
170+
}
171+
{{/required}}
172+
{{#isEnum}}
173+
$allowed_values = array({{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}});
171174
if (!in_array($this->container['{{name}}'], $allowed_values))) {
172175
$invalid_properties[] = "invalid value for '${{name}}', must be one of #{allowed_values}.";
173-
}{{/isEnum}}
176+
}
177+
{{/isEnum}}
174178
{{#hasValidation}}
175179
{{#maxLength}}
176180
if (strlen($this->container['{{name}}']) > {{maxLength}}) {
@@ -196,7 +200,9 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
196200
if (!preg_match("{{pattern}}", $this->container['{{name}}'])) {
197201
$invalid_properties[] = "invalid value for '${{name}}', must be conform to the pattern {{pattern}}.";
198202
}
199-
{{/pattern}}{{/hasValidation}}{{/vars}}
203+
{{/pattern}}
204+
{{/hasValidation}}
205+
{{/vars}}
200206
return $invalid_properties;
201207
}
202208

@@ -208,11 +214,13 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
208214
*/
209215
public function valid()
210216
{
211-
{{#vars}}{{#required}}
217+
{{#vars}}
218+
{{#required}}
212219
if ($this->container['{{name}}'] === null) {
213220
return false;
214221
}{{/required}}
215-
{{#isEnum}}$allowed_values = array({{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}});
222+
{{#isEnum}}
223+
$allowed_values = array({{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}});
216224
if (!in_array($this->container['{{name}}'], $allowed_values))) {
217225
return false;
218226
}{{/isEnum}}
@@ -241,7 +249,9 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
241249
if (!preg_match("{{pattern}}", $this->container['{{name}}'])) {
242250
return false;
243251
}
244-
{{/pattern}}{{/hasValidation}}{{/vars}}
252+
{{/pattern}}
253+
{{/hasValidation}}
254+
{{/vars}}
245255
return true;
246256
}
247257

@@ -263,11 +273,12 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
263273
*/
264274
public function {{setter}}(${{name}})
265275
{
266-
{{#isEnum}}$allowed_values = array({{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}});
276+
{{#isEnum}}
277+
$allowed_values = array({{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}});
267278
if (!in_array(${{{name}}}, $allowed_values)) {
268279
throw new \InvalidArgumentException("Invalid value for '{{name}}', must be one of {{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}");
269-
}{{/isEnum}}
270-
280+
}
281+
{{/isEnum}}
271282
{{#hasValidation}}
272283
{{#maxLength}}
273284
if (strlen(${{name}}) > {{maxLength}}) {
@@ -292,7 +303,8 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
292303
if (!preg_match("{{pattern}}", ${{name}})) {
293304
throw new \InvalidArgumentException('invalid value for ${{name}} when calling {{classname}}.{{operationId}}, must be conform to the pattern {{pattern}}.');
294305
}
295-
{{/pattern}}{{/hasValidation}}
306+
{{/pattern}}
307+
{{/hasValidation}}
296308
$this->container['{{name}}'] = ${{name}};
297309

298310
return $this;

samples/client/petstore/php/SwaggerClient-php/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This PHP package is automatically generated by the [Swagger Codegen](https://git
55

66
- API version: 1.0.0
77
- Package version: 1.0.0
8-
- Build date: 2016-05-07T07:50:05.452Z
8+
- Build date: 2016-05-07T10:11:34.658Z
99
- Build package: class io.swagger.codegen.languages.PhpClientCodegen
1010

1111
## Requirements

samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,9 @@ public function __construct(array $data = null)
142142
public function list_invalid_properties()
143143
{
144144
$invalid_properties = array();
145-
146145
if ($this->container['class_name'] === null) {
147146
$invalid_properties[] = "'$class_name' can't be null";
148147
}
149-
150-
151148
return $invalid_properties;
152149
}
153150

@@ -159,11 +156,9 @@ public function list_invalid_properties()
159156
*/
160157
public function valid()
161158
{
162-
163159
if ($this->container['class_name'] === null) {
164160
return false;
165161
}
166-
167162

168163
return true;
169164
}
@@ -185,9 +180,6 @@ public function getClassName()
185180
*/
186181
public function setClassName($class_name)
187182
{
188-
189-
190-
191183
$this->container['class_name'] = $class_name;
192184

193185
return $this;

samples/client/petstore/php/SwaggerClient-php/lib/Model/AnimalFarm.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ public function __construct(array $data = null)
130130
public function list_invalid_properties()
131131
{
132132
$invalid_properties = array();
133-
134133
return $invalid_properties;
135134
}
136135

@@ -142,7 +141,6 @@ public function list_invalid_properties()
142141
*/
143142
public function valid()
144143
{
145-
146144
return true;
147145
}
148146

samples/client/petstore/php/SwaggerClient-php/lib/Model/ApiResponse.php

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,6 @@ public function __construct(array $data = null)
165165
public function list_invalid_properties()
166166
{
167167
$invalid_properties = array();
168-
169-
170-
171-
172-
173-
174-
175168
return $invalid_properties;
176169
}
177170

@@ -183,12 +176,11 @@ public function list_invalid_properties()
183176
*/
184177
public function valid()
185178
{
186-
187-
188179

189-
190180

191-
181+
182+
183+
192184

193185
return true;
194186
}
@@ -210,9 +202,6 @@ public function getCode()
210202
*/
211203
public function setCode($code)
212204
{
213-
214-
215-
216205
$this->container['code'] = $code;
217206

218207
return $this;
@@ -233,9 +222,6 @@ public function getType()
233222
*/
234223
public function setType($type)
235224
{
236-
237-
238-
239225
$this->container['type'] = $type;
240226

241227
return $this;
@@ -256,9 +242,6 @@ public function getMessage()
256242
*/
257243
public function setMessage($message)
258244
{
259-
260-
261-
262245
$this->container['message'] = $message;
263246

264247
return $this;

samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ public function __construct(array $data = null)
139139
public function list_invalid_properties()
140140
{
141141
$invalid_properties = array();
142-
143-
144-
145142
return $invalid_properties;
146143
}
147144

@@ -153,8 +150,7 @@ public function list_invalid_properties()
153150
*/
154151
public function valid()
155152
{
156-
157-
153+
158154

159155
return true;
160156
}
@@ -176,9 +172,6 @@ public function getDeclawed()
176172
*/
177173
public function setDeclawed($declawed)
178174
{
179-
180-
181-
182175
$this->container['declawed'] = $declawed;
183176

184177
return $this;

samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ public function __construct(array $data = null)
152152
public function list_invalid_properties()
153153
{
154154
$invalid_properties = array();
155-
156-
157-
158-
159-
160155
return $invalid_properties;
161156
}
162157

@@ -168,10 +163,9 @@ public function list_invalid_properties()
168163
*/
169164
public function valid()
170165
{
171-
172-
173166

174-
167+
168+
175169

176170
return true;
177171
}
@@ -193,9 +187,6 @@ public function getId()
193187
*/
194188
public function setId($id)
195189
{
196-
197-
198-
199190
$this->container['id'] = $id;
200191

201192
return $this;
@@ -216,9 +207,6 @@ public function getName()
216207
*/
217208
public function setName($name)
218209
{
219-
220-
221-
222210
$this->container['name'] = $name;
223211

224212
return $this;

samples/client/petstore/php/SwaggerClient-php/lib/Model/Dog.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ public function __construct(array $data = null)
139139
public function list_invalid_properties()
140140
{
141141
$invalid_properties = array();
142-
143-
144-
145142
return $invalid_properties;
146143
}
147144

@@ -153,8 +150,7 @@ public function list_invalid_properties()
153150
*/
154151
public function valid()
155152
{
156-
157-
153+
158154

159155
return true;
160156
}
@@ -176,9 +172,6 @@ public function getBreed()
176172
*/
177173
public function setBreed($breed)
178174
{
179-
180-
181-
182175
$this->container['breed'] = $breed;
183176

184177
return $this;

samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumClass.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ public function __construct(array $data = null)
130130
public function list_invalid_properties()
131131
{
132132
$invalid_properties = array();
133-
134133
return $invalid_properties;
135134
}
136135

@@ -142,7 +141,6 @@ public function list_invalid_properties()
142141
*/
143142
public function valid()
144143
{
145-
146144
return true;
147145
}
148146

samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumTest.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,22 +204,18 @@ public function __construct(array $data = null)
204204
public function list_invalid_properties()
205205
{
206206
$invalid_properties = array();
207-
208207
$allowed_values = array("UPPER", "lower");
209208
if (!in_array($this->container['enum_string'], $allowed_values))) {
210209
$invalid_properties[] = "invalid value for '$enum_string', must be one of #{allowed_values}.";
211210
}
212-
213211
$allowed_values = array("1", "-1");
214212
if (!in_array($this->container['enum_integer'], $allowed_values))) {
215213
$invalid_properties[] = "invalid value for '$enum_integer', must be one of #{allowed_values}.";
216214
}
217-
218215
$allowed_values = array("1.1", "-1.2");
219216
if (!in_array($this->container['enum_number'], $allowed_values))) {
220217
$invalid_properties[] = "invalid value for '$enum_number', must be one of #{allowed_values}.";
221218
}
222-
223219
return $invalid_properties;
224220
}
225221

@@ -231,7 +227,7 @@ public function list_invalid_properties()
231227
*/
232228
public function valid()
233229
{
234-
230+
235231
$allowed_values = array("UPPER", "lower");
236232
if (!in_array($this->container['enum_string'], $allowed_values))) {
237233
return false;
@@ -246,7 +242,6 @@ public function valid()
246242
if (!in_array($this->container['enum_number'], $allowed_values))) {
247243
return false;
248244
}
249-
250245
return true;
251246
}
252247

@@ -271,8 +266,6 @@ public function setEnumString($enum_string)
271266
if (!in_array($enum_string, $allowed_values)) {
272267
throw new \InvalidArgumentException("Invalid value for 'enum_string', must be one of 'UPPER', 'lower'");
273268
}
274-
275-
276269
$this->container['enum_string'] = $enum_string;
277270

278271
return $this;
@@ -297,8 +290,6 @@ public function setEnumInteger($enum_integer)
297290
if (!in_array($enum_integer, $allowed_values)) {
298291
throw new \InvalidArgumentException("Invalid value for 'enum_integer', must be one of '1', '-1'");
299292
}
300-
301-
302293
$this->container['enum_integer'] = $enum_integer;
303294

304295
return $this;
@@ -323,8 +314,6 @@ public function setEnumNumber($enum_number)
323314
if (!in_array($enum_number, $allowed_values)) {
324315
throw new \InvalidArgumentException("Invalid value for 'enum_number', must be one of '1.1', '-1.2'");
325316
}
326-
327-
328317
$this->container['enum_number'] = $enum_number;
329318

330319
return $this;

0 commit comments

Comments
 (0)