-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
234 changed files
with
50,869 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
generatorName: php | ||
outputDir: samples/client/petstore/php-nextgen/OpenAPIClient-php | ||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml | ||
templateDir: modules/openapi-generator/src/main/resources/php-nextgen |
114 changes: 114 additions & 0 deletions
114
...i-generator/src/main/java/org/openapitools/codegen/languages/PhpNextgenClientCodegen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) | ||
* Copyright 2018 SmartBear Software | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.openapitools.codegen.languages; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.openapitools.codegen.CliOption; | ||
import org.openapitools.codegen.CodegenConstants; | ||
import org.openapitools.codegen.CodegenType; | ||
import org.openapitools.codegen.SupportingFile; | ||
import org.openapitools.codegen.meta.features.*; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.EnumSet; | ||
import java.util.List; | ||
|
||
public class PhpNextgenClientCodegen extends AbstractPhpCodegen { | ||
@SuppressWarnings("hiding") | ||
private final Logger LOGGER = LoggerFactory.getLogger(PhpNextgenClientCodegen.class); | ||
|
||
public PhpNextgenClientCodegen() { | ||
super(); | ||
|
||
modifyFeatureSet(features -> features | ||
.includeDocumentationFeatures(DocumentationFeature.Readme) | ||
.wireFormatFeatures(EnumSet.of(WireFormatFeature.JSON, WireFormatFeature.XML)) | ||
.securityFeatures(EnumSet.noneOf(SecurityFeature.class)) | ||
.excludeGlobalFeatures( | ||
GlobalFeature.XMLStructureDefinitions, | ||
GlobalFeature.Callbacks, | ||
GlobalFeature.LinkObjects, | ||
GlobalFeature.ParameterStyling | ||
) | ||
.excludeSchemaSupportFeatures( | ||
SchemaSupportFeature.Polymorphism | ||
) | ||
); | ||
|
||
// clear import mapping (from default generator) as php does not use it | ||
// at the moment | ||
importMapping.clear(); | ||
|
||
setInvokerPackage("OpenAPI\\Client"); | ||
setApiPackage(getInvokerPackage() + "\\" + apiDirName); | ||
setModelPackage(getInvokerPackage() + "\\" + modelDirName); | ||
setPackageName("OpenAPIClient-php"); | ||
supportsInheritance = true; | ||
setOutputDir("generated-code" + File.separator + "php"); | ||
modelTestTemplateFiles.put("model_test.mustache", ".php"); | ||
embeddedTemplateDir = templateDir = "php-nextgen"; | ||
|
||
// default HIDE_GENERATION_TIMESTAMP to true | ||
hideGenerationTimestamp = Boolean.TRUE; | ||
|
||
// provide primitives to mustache template | ||
List sortedLanguageSpecificPrimitives = new ArrayList(languageSpecificPrimitives); | ||
Collections.sort(sortedLanguageSpecificPrimitives); | ||
String primitives = "'" + StringUtils.join(sortedLanguageSpecificPrimitives, "', '") + "'"; | ||
additionalProperties.put("primitives", primitives); | ||
|
||
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.ALLOW_UNICODE_IDENTIFIERS_DESC) | ||
.defaultValue(Boolean.TRUE.toString())); | ||
} | ||
|
||
@Override | ||
public CodegenType getTag() { | ||
return CodegenType.CLIENT; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "php-nextgen"; | ||
} | ||
|
||
@Override | ||
public String getHelp() { | ||
return "Generates a PHP client library (beta)."; | ||
} | ||
|
||
@Override | ||
public void processOpts() { | ||
super.processOpts(); | ||
|
||
supportingFiles.add(new SupportingFile("ApiException.mustache", toSrcPath(invokerPackage, srcBasePath), "ApiException.php")); | ||
supportingFiles.add(new SupportingFile("Configuration.mustache", toSrcPath(invokerPackage, srcBasePath), "Configuration.php")); | ||
supportingFiles.add(new SupportingFile("ObjectSerializer.mustache", toSrcPath(invokerPackage, srcBasePath), "ObjectSerializer.php")); | ||
supportingFiles.add(new SupportingFile("ModelInterface.mustache", toSrcPath(modelPackage, srcBasePath), "ModelInterface.php")); | ||
supportingFiles.add(new SupportingFile("HeaderSelector.mustache", toSrcPath(invokerPackage, srcBasePath), "HeaderSelector.php")); | ||
supportingFiles.add(new SupportingFile("composer.mustache", "", "composer.json")); | ||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); | ||
supportingFiles.add(new SupportingFile("phpunit.xml.mustache", "", "phpunit.xml.dist")); | ||
supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml")); | ||
supportingFiles.add(new SupportingFile(".php-cs-fixer.dist.php", "", ".php-cs-fixer.dist.php")); | ||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
modules/openapi-generator/src/main/resources/php-nextgen/.php-cs-fixer.dist.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/** | ||
* @generated | ||
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/HEAD/doc/config.rst | ||
*/ | ||
$finder = PhpCsFixer\Finder::create() | ||
->in(__DIR__) | ||
->exclude('vendor') | ||
->exclude('test') | ||
->exclude('tests') | ||
; | ||
|
||
$config = new PhpCsFixer\Config(); | ||
return $config->setRules([ | ||
'@PSR12' => true, | ||
'phpdoc_order' => true, | ||
'array_syntax' => [ 'syntax' => 'short' ], | ||
'strict_comparison' => true, | ||
'strict_param' => true, | ||
'no_trailing_whitespace' => false, | ||
'no_trailing_whitespace_in_comment' => false, | ||
'braces' => false, | ||
'single_blank_line_at_eof' => false, | ||
'blank_line_after_namespace' => false, | ||
'no_leading_import_slash' => false, | ||
]) | ||
->setFinder($finder) | ||
; |
8 changes: 8 additions & 0 deletions
8
modules/openapi-generator/src/main/resources/php-nextgen/.travis.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
language: php | ||
# Bionic environment has preinstalled PHP from 7.1 to 7.4 | ||
# https://docs.travis-ci.com/user/reference/bionic/#php-support | ||
dist: bionic | ||
php: | ||
- 7.4 | ||
before_install: "composer install" | ||
script: "vendor/bin/phpunit" |
110 changes: 110 additions & 0 deletions
110
modules/openapi-generator/src/main/resources/php-nextgen/ApiException.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php | ||
/** | ||
* ApiException | ||
* PHP version 7.4 | ||
* | ||
* @category Class | ||
* @package {{invokerPackage}} | ||
* @author OpenAPI Generator team | ||
* @link https://openapi-generator.tech | ||
*/ | ||
|
||
{{>partial_header}} | ||
/** | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
namespace {{invokerPackage}}; | ||
|
||
use \Exception; | ||
|
||
/** | ||
* ApiException Class Doc Comment | ||
* | ||
* @category Class | ||
* @package {{invokerPackage}} | ||
* @author OpenAPI Generator team | ||
* @link https://openapi-generator.tech | ||
*/ | ||
class ApiException extends Exception | ||
{ | ||
/** | ||
* The HTTP body of the server response either as Json or string. | ||
* | ||
* @var \stdClass|string|null | ||
*/ | ||
protected $responseBody; | ||
/** | ||
* The HTTP header of the server response. | ||
* | ||
* @var string[]|null | ||
*/ | ||
protected $responseHeaders; | ||
/** | ||
* The deserialized response object | ||
* | ||
* @var \stdClass|string|null | ||
*/ | ||
protected $responseObject; | ||
/** | ||
* Constructor | ||
* | ||
* @param string $message Error message | ||
* @param int $code HTTP status code | ||
* @param string[]|null $responseHeaders HTTP response header | ||
* @param \stdClass|string|null $responseBody HTTP decoded body of the server response either as \stdClass or string | ||
*/ | ||
public function __construct($message = "", $code = 0, $responseHeaders = [], $responseBody = null) | ||
{ | ||
parent::__construct($message, $code); | ||
$this->responseHeaders = $responseHeaders; | ||
$this->responseBody = $responseBody; | ||
} | ||
|
||
/** | ||
* Gets the HTTP response header | ||
* | ||
* @return string[]|null HTTP response header | ||
*/ | ||
public function getResponseHeaders() | ||
{ | ||
return $this->responseHeaders; | ||
} | ||
|
||
/** | ||
* Gets the HTTP body of the server response either as Json or string | ||
* | ||
* @return \stdClass|string|null HTTP body of the server response either as \stdClass or string | ||
*/ | ||
public function getResponseBody() | ||
{ | ||
return $this->responseBody; | ||
} | ||
|
||
/** | ||
* Sets the deserialized response object (during deserialization) | ||
* | ||
* @param mixed $obj Deserialized response object | ||
* | ||
* @return void | ||
*/ | ||
public function setResponseObject($obj) | ||
{ | ||
$this->responseObject = $obj; | ||
} | ||
|
||
/** | ||
* Gets the deserialized response object (during deserialization) | ||
* | ||
* @return mixed the deserialized response object | ||
*/ | ||
public function getResponseObject() | ||
{ | ||
return $this->responseObject; | ||
} | ||
} |
Oops, something went wrong.