mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 14:10:56 +00:00
add oauth support for php
This commit is contained in:
parent
2e6199ac3b
commit
67815ed5f2
@ -333,6 +333,9 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
// Note: backslash ("\\") is allowed for e.g. "\\DateTime"
|
// Note: backslash ("\\") is allowed for e.g. "\\DateTime"
|
||||||
name = name.replaceAll("[^\\w\\\\]+", "_");
|
name = name.replaceAll("[^\\w\\\\]+", "_");
|
||||||
|
|
||||||
|
// remove dollar sign
|
||||||
|
name = name.replaceAll("$", "");
|
||||||
|
|
||||||
// model name cannot use reserved keyword
|
// model name cannot use reserved keyword
|
||||||
if (reservedWords.contains(name)) {
|
if (reservedWords.contains(name)) {
|
||||||
escapeReservedWord(name); // e.g. return => _return
|
escapeReservedWord(name); // e.g. return => _return
|
||||||
|
@ -171,7 +171,7 @@ use \{{invokerPackage}}\ObjectSerializer;
|
|||||||
{{#isKeyInHeader}}$headerParams['{{keyParamName}}'] = $apiKey;{{/isKeyInHeader}}{{#isKeyInQuery}}$queryParams['{{keyParamName}}'] = $apiKey;{{/isKeyInQuery}}
|
{{#isKeyInHeader}}$headerParams['{{keyParamName}}'] = $apiKey;{{/isKeyInHeader}}{{#isKeyInQuery}}$queryParams['{{keyParamName}}'] = $apiKey;{{/isKeyInQuery}}
|
||||||
}{{/isApiKey}}
|
}{{/isApiKey}}
|
||||||
{{#isBasic}}$headerParams['Authorization'] = 'Basic ' . base64_encode($this->apiClient->getConfig()->getUsername(). ":" .$this->apiClient->getConfig()->getPassword());{{/isBasic}}
|
{{#isBasic}}$headerParams['Authorization'] = 'Basic ' . base64_encode($this->apiClient->getConfig()->getUsername(). ":" .$this->apiClient->getConfig()->getPassword());{{/isBasic}}
|
||||||
{{#isOAuth}}//TODO support oauth{{/isOAuth}}
|
{{#isOAuth}}$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAuthToken();{{/isOAuth}}
|
||||||
{{/authMethods}}
|
{{/authMethods}}
|
||||||
// make the API Call
|
// make the API Call
|
||||||
try
|
try
|
||||||
|
@ -63,6 +63,13 @@ class Configuration
|
|||||||
*/
|
*/
|
||||||
protected $apiKeyPrefixes = array();
|
protected $apiKeyPrefixes = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Token for OAuth
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $authToken = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Username for HTTP basic authentication
|
* Username for HTTP basic authentication
|
||||||
*
|
*
|
||||||
@ -195,6 +202,29 @@ class Configuration
|
|||||||
return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null;
|
return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the token for OAuth
|
||||||
|
*
|
||||||
|
* @param string $authToken Token for OAuth
|
||||||
|
*
|
||||||
|
* @return Configuration
|
||||||
|
*/
|
||||||
|
public function setAuthToken($authToken)
|
||||||
|
{
|
||||||
|
$this->$authToken = $authToken;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the token for OAuth
|
||||||
|
*
|
||||||
|
* @return string Token for OAuth
|
||||||
|
*/
|
||||||
|
public function getAuthToken()
|
||||||
|
{
|
||||||
|
return $this->authToken;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the username for HTTP basic authentication
|
* Sets the username for HTTP basic authentication
|
||||||
*
|
*
|
||||||
|
@ -136,7 +136,7 @@ class PetApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO support oauth
|
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAuthToken();
|
||||||
|
|
||||||
// make the API Call
|
// make the API Call
|
||||||
try
|
try
|
||||||
@ -201,7 +201,7 @@ class PetApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO support oauth
|
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAuthToken();
|
||||||
|
|
||||||
// make the API Call
|
// make the API Call
|
||||||
try
|
try
|
||||||
@ -265,7 +265,7 @@ class PetApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO support oauth
|
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAuthToken();
|
||||||
|
|
||||||
// make the API Call
|
// make the API Call
|
||||||
try
|
try
|
||||||
@ -341,7 +341,7 @@ class PetApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO support oauth
|
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAuthToken();
|
||||||
|
|
||||||
// make the API Call
|
// make the API Call
|
||||||
try
|
try
|
||||||
@ -527,7 +527,7 @@ class PetApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO support oauth
|
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAuthToken();
|
||||||
|
|
||||||
// make the API Call
|
// make the API Call
|
||||||
try
|
try
|
||||||
@ -603,7 +603,7 @@ class PetApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO support oauth
|
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAuthToken();
|
||||||
|
|
||||||
// make the API Call
|
// make the API Call
|
||||||
try
|
try
|
||||||
@ -695,7 +695,7 @@ class PetApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO support oauth
|
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAuthToken();
|
||||||
|
|
||||||
// make the API Call
|
// make the API Call
|
||||||
try
|
try
|
||||||
|
Loading…
x
Reference in New Issue
Block a user