You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{#pathParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
25
+
{{/pathParams}} *
26
+
* @return Http response
27
+
*/
28
+
public function {{operationId}}({{#pathParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/pathParams}})
29
+
{
30
+
$input = Request::all();
31
+
32
+
//path params validation
33
+
{{#pathParams}}
34
+
{{#hasValidation}}
35
+
{{#maxLength}}
36
+
if (strlen(${{paramName}}]) > {{maxLength}}) {
37
+
throw new \InvalidArgumentException('invalid length for ${{paramName}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.');
38
+
}
39
+
{{/maxLength}}
40
+
{{#minLength}}
41
+
if (strlen(${{paramName}}]) < {{minLength}}) {
42
+
throw new \InvalidArgumentException('invalid length for ${{paramName}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.');
43
+
}
44
+
{{/minLength}}
45
+
{{#maximum}}
46
+
if (${{paramName}}] > {{maximum}}) {
47
+
throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maximum}}.');
48
+
}
49
+
{{/maximum}}
50
+
{{#minimum}}
51
+
if (${{paramName}}] < {{minimum}}) {
52
+
throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minimum}}.');
53
+
}
54
+
{{/minimum}}
55
+
{{#pattern}}
56
+
if (!preg_match("{{pattern}}", ${{paramName}}])) {
57
+
throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must conform to the pattern {{pattern}}.');
58
+
}
59
+
{{/pattern}}
60
+
{{/hasValidation}}
61
+
{{/pathParams}}
62
+
63
+
64
+
//not path params validation
65
+
{{#allParams}}
66
+
{{^pathParams}}
67
+
{{#required}}
68
+
if (!isset($input['{{paramName}}'])) {
69
+
throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{operationId}}');
70
+
}
71
+
{{/required}}
72
+
{{#hasValidation}}
73
+
{{#maxLength}}
74
+
if (strlen($input['{{paramName}}']) > {{maxLength}}) {
75
+
throw new \InvalidArgumentException('invalid length for ${{paramName}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.');
76
+
}
77
+
{{/maxLength}}
78
+
{{#minLength}}
79
+
if (strlen($input['{{paramName}}']) < {{minLength}}) {
80
+
throw new \InvalidArgumentException('invalid length for ${{paramName}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.');
81
+
}
82
+
{{/minLength}}
83
+
{{#maximum}}
84
+
if ($input['{{paramName}}'] > {{maximum}}) {
85
+
throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maximum}}.');
86
+
}
87
+
{{/maximum}}
88
+
{{#minimum}}
89
+
if ($input['{{paramName}}'] < {{minimum}}) {
90
+
throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minimum}}.');
91
+
}
92
+
{{/minimum}}
93
+
{{#pattern}}
94
+
if (!preg_match("{{pattern}}", $input['{{paramName}}'])) {
95
+
throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must conform to the pattern {{pattern}}.');
96
+
}
97
+
{{/pattern}}
98
+
{{/hasValidation}}
99
+
${{paramName}} = $input['{{paramName}}'];
100
+
101
+
{{/pathParams}}
102
+
{{/allParams}}
103
+
104
+
return response('How about implementing {{nickname}} as a {{httpMethod}} method ?');
0 commit comments