Skip to content

Commit

Permalink
php template changes for carbon (#596)
Browse files Browse the repository at this point in the history
* php template changes for carbon
- support prefix in headers
- support for useSecurityKeyNameAsPropertyName

* run php integration tests
  • Loading branch information
eddiechayes authored Feb 28, 2024
1 parent fb758b3 commit 448ecf7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ default Map<String, Object> transformAdditionalPropertiesToMap(AdditionalPropert
putIfPresent(map, "useSecurityKeyNameAsPropertyName", true);
putIfPresent(map, "removeDefaultConfigurationParameters", true);
}
if (generator.equals("php") && existingCustomers.stream().noneMatch(packageName::contains)) {
putIfPresent(map, "useSecurityKeyNameAsPropertyName", true);
}
if (additionalProperties.getObjectPropertyNamingConvention() != null) {
putIfPresent(map, "useCamelCase",
additionalProperties.getObjectPropertyNamingConvention().equals("camelCase"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,10 @@ class Configuration
$this->{{setter}}(${{state}});
{{/clientStateWithExamplesSetterGetterCamelCase}}
{{#apiKeyMethods}}
$this->setApiKey("{{keyParamName}}", ${{> api_key_name}});
$this->setApiKey("{{> api_key_name}}", ${{> api_key_name}});
{{#vendorExtensions.x-konfig-prefix}}
$this->setApiKeyPrefix("{{> api_key_name}}", "{{vendorExtensions.x-konfig-prefix}}");
{{/vendorExtensions.x-konfig-prefix}}
{{/apiKeyMethods}}
}

Expand Down Expand Up @@ -598,7 +601,7 @@ class Configuration
if ($prefix === null) {
$keyWithPrefix = $apiKey;
} else {
$keyWithPrefix = $prefix . ' ' . $apiKey;
$keyWithPrefix = $prefix . $apiKey;
}

return $keyWithPrefix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ use {{invokerPackage}}\ObjectSerializer;
{{#authMethods}}
{{#isApiKey}}
// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('{{keyParamName}}');
$apiKey = $this->config->getApiKeyWithPrefix('{{> api_key_name}}');
if ($apiKey !== null) {
{{#isKeyInHeader}}$headers['{{keyParamName}}'] = $apiKey;{{/isKeyInHeader}}{{#isKeyInQuery}}$queryParams['{{keyParamName}}'] = $apiKey;{{/isKeyInQuery}}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{^hasMultipleApiKeys}}apiKey{{/hasMultipleApiKeys}}{{#hasMultipleApiKeys}}{{{keyParamName}}}{{/hasMultipleApiKeys}}
{{#useSecurityKeyNameAsPropertyName}}{{{nameInPascalCase}}}{{/useSecurityKeyNameAsPropertyName}}{{^useSecurityKeyNameAsPropertyName}}{{^hasMultipleApiKeys}}apiKey{{/hasMultipleApiKeys}}{{#hasMultipleApiKeys}}{{{keyParamName}}}{{/hasMultipleApiKeys}}{{/useSecurityKeyNameAsPropertyName}}
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ public function getApiKeyWithPrefix($apiKeyIdentifier)
if ($prefix === null) {
$keyWithPrefix = $apiKey;
} else {
$keyWithPrefix = $prefix . ' ' . $apiKey;
$keyWithPrefix = $prefix . $apiKey;
}

return $keyWithPrefix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public function getApiKeyWithPrefix($apiKeyIdentifier)
if ($prefix === null) {
$keyWithPrefix = $apiKey;
} else {
$keyWithPrefix = $prefix . ' ' . $apiKey;
$keyWithPrefix = $prefix . $apiKey;
}

return $keyWithPrefix;
Expand Down

0 comments on commit 448ecf7

Please sign in to comment.