Skip to content

Commit e9d508a

Browse files
authored
Merge pull request #1157 from swagger-api/SaloEater-PHP_beautify_templates
Salo eater php beautify templates
2 parents aae2a45 + ab6ac92 commit e9d508a

File tree

2 files changed

+43
-20
lines changed

2 files changed

+43
-20
lines changed

src/main/resources/handlebars/php/model_enum.mustache

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@ class {{classname}}
33
/**
44
* Possible values of this enum
55
*/
6-
{{#allowableValues}}{{#enumVars}}const {{{name}}} = {{{value}}};
7-
{{/enumVars}}{{/allowableValues}}
6+
{{#allowableValues}}
7+
{{#enumVars}}
8+
const {{{name}}} = {{{value}}};
9+
{{/enumVars}}
10+
{{/allowableValues}}
811
/**
912
* Gets allowable values of the enum
1013
* @return string[]
1114
*/
1215
public static function getAllowableEnumValues()
1316
{
1417
return [
15-
{{#allowableValues}}{{#enumVars}}self::{{{name}}},{{^@last}}
16-
{{/@last}}{{/enumVars}}{{/allowableValues}}
18+
{{#allowableValues}}
19+
{{#enumVars}}
20+
self::{{{name}}}{{#hasMore}},{{/hasMore}}
21+
{{/enumVars}}
22+
{{/allowableValues}}
1723
];
1824
}
1925
}

src/main/resources/handlebars/php/model_generic.mustache

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa
1515
* @var string[]
1616
*/
1717
protected static $swaggerTypes = [
18-
{{#vars}}'{{name}}' => '{{{datatype}}}'{{#hasMore}},
19-
{{/hasMore}}{{/vars}}
18+
{{#vars}}
19+
'{{name}}' => '{{{datatype}}}'{{#hasMore}},{{/hasMore}}
20+
{{/vars}}
2021
];
2122

2223
/**
@@ -25,8 +26,9 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa
2526
* @var string[]
2627
*/
2728
protected static $swaggerFormats = [
28-
{{#vars}}'{{name}}' => {{#dataFormat}}'{{{dataFormat}}}'{{/dataFormat}}{{^dataFormat}}null{{/dataFormat}}{{#hasMore}},
29-
{{/hasMore}}{{/vars}}
29+
{{#vars}}
30+
'{{name}}' => {{#dataFormat}}'{{{dataFormat}}}'{{/dataFormat}}{{^dataFormat}}null{{/dataFormat}}{{#hasMore}},{{/hasMore}}
31+
{{/vars}}
3032
];
3133

3234
/**
@@ -56,8 +58,9 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa
5658
* @var string[]
5759
*/
5860
protected static $attributeMap = [
59-
{{#vars}}'{{name}}' => '{{baseName}}'{{#hasMore}},
60-
{{/hasMore}}{{/vars}}
61+
{{#vars}}
62+
'{{name}}' => '{{baseName}}'{{#hasMore}},{{/hasMore}}
63+
{{/vars}}
6164
];
6265

6366
/**
@@ -66,8 +69,9 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa
6669
* @var string[]
6770
*/
6871
protected static $setters = [
69-
{{#vars}}'{{name}}' => '{{setter}}'{{#hasMore}},
70-
{{/hasMore}}{{/vars}}
72+
{{#vars}}
73+
'{{name}}' => '{{setter}}'{{#hasMore}},{{/hasMore}}
74+
{{/vars}}
7175
];
7276

7377
/**
@@ -76,8 +80,9 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa
7680
* @var string[]
7781
*/
7882
protected static $getters = [
79-
{{#vars}}'{{name}}' => '{{getter}}'{{#hasMore}},
80-
{{/hasMore}}{{/vars}}
83+
{{#vars}}
84+
'{{name}}' => '{{getter}}'{{#hasMore}},{{/hasMore}}
85+
{{/vars}}
8186
];
8287

8388
/**
@@ -121,10 +126,18 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa
121126
return self::$swaggerModelName;
122127
}
123128

124-
{{#vars}}{{#isEnum}}{{#allowableValues}}{{#enumVars}}const {{enumName}}_{{{name}}} = {{{value}}};
125-
{{/enumVars}}{{/allowableValues}}{{/isEnum}}{{/vars}}
129+
{{#vars}}
130+
{{#isEnum}}
131+
{{#allowableValues}}
132+
{{#enumVars}}
133+
const {{enumName}}_{{{name}}} = {{{value}}};
134+
{{/enumVars}}
135+
{{/allowableValues}}
136+
{{/isEnum}}
137+
{{/vars}}
126138

127-
{{#vars}}{{#isEnum}}
139+
{{#vars}}
140+
{{#isEnum}}
128141
/**
129142
* Gets allowable values of the enum
130143
*
@@ -133,11 +146,15 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa
133146
public function {{getter}}AllowableValues()
134147
{
135148
return [
136-
{{#allowableValues}}{{#enumVars}}self::{{enumName}}_{{{name}}},{{^@last}}
137-
{{/@last}}{{/enumVars}}{{/allowableValues}}
149+
{{#allowableValues}}
150+
{{#enumVars}}
151+
self::{{enumName}}_{{{name}}}{{#hasMore}},{{/hasMore}}
152+
{{/enumVars}}
153+
{{/allowableValues}}
138154
];
139155
}
140-
{{/isEnum}}{{/vars}}
156+
{{/isEnum}}
157+
{{/vars}}
141158

142159
{{^parentSchema}}
143160
/**

0 commit comments

Comments
 (0)