Skip to content

Commit c00a439

Browse files
jfastnachtwing328
authored andcommitted
[PHP] Username checks #1408 (#1892)
* Reverted path changes. Removed additional files in php petstore-security-test folder. Generated new samples. * Batch and Shell scripts modified to use the same specification files for sample generation. Sample files generated. * Input file path in PHP client batch file equalized with the input path in the shell script file. Samples generated. * Added a missing bracket in the PHP client mustache template. * AbstractPhpCodegen apiDocPath and modelDocPath creation adjusted to always use slash instead of system seperator, since the values will just be used in Markdown files. * Unnecessary samples removed. * Fixed unnecessary diversions between Windows and Linux/Mac paths in PHP codegen. * New samples generated after rebase. * Fixed a sample in TypeScript Angular v2 which caused CI to break.
1 parent 8a0248e commit c00a439

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2950
-3649
lines changed

bin/openapi3/security/php-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ fi
3333

3434
# if you've executed sbt assembly previously it will use that instead.
3535
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
36-
ags="generate -t modules/openapi-generator/src/main/resources/php -i modules/openapi-generator/src/test/resources/3_0/petstore-security-test.yaml -g php -o samples/client/petstore-security-test/php $@"
36+
ags="generate -t modules/openapi-generator/src/main/resources/php -i modules/openapi-generator/src/test/resources/3_0/petstore-security-test.yaml -g php -o samples/openapi3/client/petstore-security-test/php/OpenAPIClient-php $@"
3737

3838
java $JAVA_OPTS -jar $executable $ags
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
2+
3+
If Not Exist %executable% (
4+
mvn clean package
5+
)
6+
7+
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
8+
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore-security-test.yaml -g php -o samples\openapi3\client\petstore-security-test\php\OpenAPIClient-php
9+
10+
java %JAVA_OPTS% -jar %executable% %ags%

bin/openapi3/windows/php-petstore.bat

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
2+
3+
If Not Exist %executable% (
4+
mvn clean package
5+
)
6+
7+
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
8+
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore-with-fake-endpoints-models-for-testing.yaml -g php -o samples\openapi3\client\petstore\php\OpenAPIClient-php
9+
10+
java %JAVA_OPTS% -jar %executable% %ags%

bin/security/windows/php-petstore.bat

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
2+
3+
If Not Exist %executable% (
4+
mvn clean package
5+
)
6+
7+
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
8+
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-security-test.yaml -g php -o samples\client\petstore-security-test\php\OpenAPIClient-php
9+
10+
java %JAVA_OPTS% -jar %executable% %ags%

bin/windows/php-petstore.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ If Not Exist %executable% (
55
)
66

77
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
8-
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g php -o samples\client\petstore\php\OpenAPIClient-php
8+
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g php -o samples\client\petstore\php\OpenAPIClient-php
99

1010
java %JAVA_OPTS% -jar %executable% %ags%

modules/openapi-generator/src/main/resources/php/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ use {{invokerPackage}}\ObjectSerializer;
581581
{{#isBasic}}
582582
{{^isBasicBearer}}
583583
// this endpoint requires HTTP basic authentication
584-
if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) {
584+
if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) {
585585
$headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword());
586586
}
587587
{{/isBasicBearer}}

samples/client/petstore-security-test/php/.gitignore

Lines changed: 0 additions & 8 deletions
This file was deleted.

samples/client/petstore-security-test/php/.openapi-generator-ignore

Lines changed: 0 additions & 23 deletions
This file was deleted.

samples/client/petstore-security-test/php/.php_cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

samples/client/petstore-security-test/php/.travis.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

samples/client/petstore-security-test/php/LICENSE

Lines changed: 0 additions & 201 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.4-SNAPSHOT
1+
4.0.0-SNAPSHOT

samples/client/petstore-security-test/php/OpenAPIClient-php/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,17 @@ Please follow the [installation procedure](#installation--usage) and then run th
5656
<?php
5757
require_once(__DIR__ . '/vendor/autoload.php');
5858

59+
60+
5961
$apiInstance = new OpenAPI\Client\Api\FakeApi(
6062
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
6163
// This is optional, `GuzzleHttp\Client` will be used as default.
6264
new GuzzleHttp\Client()
6365
);
64-
$unknown_base_type = new \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE(); // \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE |
66+
$test_code_inject____end____rn_n_r = 'test_code_inject____end____rn_n_r_example'; // string | To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r
6567

6668
try {
67-
$apiInstance->testCodeInjectEndRnNR($unknown_base_type);
69+
$apiInstance->testCodeInjectEndRnNR($test_code_inject____end____rn_n_r);
6870
} catch (Exception $e) {
6971
echo 'Exception when calling FakeApi->testCodeInjectEndRnNR: ', $e->getMessage(), PHP_EOL;
7072
}
@@ -95,14 +97,15 @@ Class | Method | HTTP request | Description
9597
- **API key parameter name**: api_key */ ' " =end -- \r\n \n \r
9698
- **Location**: HTTP header
9799

100+
98101
## petstore_auth
99102

100103
- **Type**: OAuth
101104
- **Flow**: implicit
102105
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
103106
- **Scopes**:
104-
- **write:pets**: modify pets in your account *_/ ' \" =end -- \\r\\n \\n \\r
105-
- **read:pets**: read your pets *_/ ' \" =end -- \\r\\n \\n \\r
107+
- **write:pets**: modify pets in your account *_/ ' \" =end -- \\r\\n \\n \\r
108+
- **read:pets**: read your pets *_/ ' \" =end -- \\r\\n \\n \\r
106109

107110

108111
## Author

samples/client/petstore-security-test/php/OpenAPIClient-php/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
"keywords": [
55
"openapitools",
66
"openapi-generator",
7+
"openapi",
78
"php",
89
"sdk",
910
"rest",
1011
"api"
1112
],
12-
"homepage": "http://openapi-generator.tech",
13+
"homepage": "https://openapi-generator.tech",
1314
"license": "proprietary",
1415
"authors": [
1516
{

0 commit comments

Comments
 (0)