Skip to content

Commit 9ab27cd

Browse files
committed
update reserved words for php and ruby to include local variable names
in api methods
1 parent 19ff7dc commit 9ab27cd

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ public PhpClientCodegen() {
4747

4848
reservedWords = new HashSet<String>(
4949
Arrays.asList(
50-
"__halt_compiler", "abstract", "and", "array", "as", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends", "final", "for", "foreach", "function", "global", "goto", "if", "implements", "include", "include_once", "instanceof", "insteadof", "interface", "isset", "list", "namespace", "new", "or", "print", "private", "protected", "public", "require", "require_once", "return", "static", "switch", "throw", "trait", "try", "unset", "use", "var", "while", "xor")
50+
// local variables used in api methods (endpoints)
51+
"resourcePath", "method", "httpBody", "queryParams", "headerParams",
52+
"formParams", "_header_accept", "_tempBody",
53+
54+
// PHP reserved words
55+
"__halt_compiler", "abstract", "and", "array", "as", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends", "final", "for", "foreach", "function", "global", "goto", "if", "implements", "include", "include_once", "instanceof", "insteadof", "interface", "isset", "list", "namespace", "new", "or", "print", "private", "protected", "public", "require", "require_once", "return", "static", "switch", "throw", "trait", "try", "unset", "use", "var", "while", "xor")
5156
);
5257

5358
// ref: http://php.net/manual/en/language.types.intro.php

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@ public RubyClientCodegen() {
3838

3939
reservedWords = new HashSet<String>(
4040
Arrays.asList(
41-
"__FILE__", "and", "def", "end", "in", "or", "self", "unless", "__LINE__",
42-
"begin", "defined?", "ensure", "module", "redo", "super", "until", "BEGIN",
43-
"break", "do", "false", "next", "rescue", "then", "when", "END", "case",
44-
"else", "for", "nil", "retry", "true", "while", "alias", "class", "elsif",
45-
"if", "not", "return", "undef", "yield")
41+
// local variable names used in API methods (endpoints)
42+
"path", "query_params", "header_params", "_header_accept", "_header_accept_result",
43+
"_header_content_type", "form_params", "post_body", "auth_names",
44+
// ruby reserved keywords
45+
"__FILE__", "and", "def", "end", "in", "or", "self", "unless", "__LINE__",
46+
"begin", "defined?", "ensure", "module", "redo", "super", "until", "BEGIN",
47+
"break", "do", "false", "next", "rescue", "then", "when", "END", "case",
48+
"else", "for", "nil", "retry", "true", "while", "alias", "class", "elsif",
49+
"if", "not", "return", "undef", "yield")
4650
);
4751

4852
languageSpecificPrimitives.add("int");

samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public function deserialize($data, $class, $httpHeader=null)
226226
$deserialized = $values;
227227
} elseif ($class === '\DateTime') {
228228
$deserialized = new \DateTime($data);
229-
} elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) {
229+
} elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) {
230230
settype($data, $class);
231231
$deserialized = $data;
232232
} elseif ($class === '\SplFileObject') {

samples/client/petstore/ruby/lib/petstore.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
# APIs
1515
require 'petstore/api/user_api'
16-
require 'petstore/api/store_api'
1716
require 'petstore/api/pet_api'
17+
require 'petstore/api/store_api'
1818

1919
module Petstore
2020
class << self

samples/client/petstore/ruby/lib/petstore/configuration.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,20 +157,20 @@ def basic_auth_token
157157
# Returns Auth Settings hash for api client.
158158
def auth_settings
159159
{
160-
'petstore_auth' =>
161-
{
162-
type: 'oauth2',
163-
in: 'header',
164-
key: 'Authorization',
165-
value: "Bearer #{access_token}"
166-
},
167160
'api_key' =>
168161
{
169162
type: 'api_key',
170163
in: 'header',
171164
key: 'api_key',
172165
value: api_key_with_prefix('api_key')
173166
},
167+
'petstore_auth' =>
168+
{
169+
type: 'oauth2',
170+
in: 'header',
171+
key: 'Authorization',
172+
value: "Bearer #{access_token}"
173+
},
174174
}
175175
end
176176
end

0 commit comments

Comments
 (0)