Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 65 additions & 52 deletions templates/openapi-generator/php/README.mustache
Original file line number Diff line number Diff line change
@@ -1,63 +1,74 @@
# {{packageName}}

[![Packagist](https://img.shields.io/packagist/v/fattureincloud/fattureincloud-php-sdk?color=g)](https://packagist.org/packages/fattureincloud/fattureincloud-php-sdk) ![unit tests](https://github.com/fattureincloud/fattureincloud-php-sdk/actions/workflows/validate.yaml/badge.svg)
{{#appDescriptionWithNewLines}}
{{{.}}}
{{{.}}}
{{/appDescriptionWithNewLines}}

{{#infoUrl}}
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}).
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}).
{{/infoUrl}}

## Installation & Usage

### Requirements

PHP 7.3 and later.
PHP 8.1 and later.

### Composer

To install the bindings via [Composer](https://getcomposer.org/), run the following command:
To install the bindings via [Composer](https://getcomposer.org/), add the following to `composer.json`:

```bash
$ composer require fattureincloud/fattureincloud-php-sdk
```json
{
"repositories": [
{
"type": "vcs",
"url": "https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git"
}
],
"require": {
"{{gitUserId}}/{{gitRepoId}}": "*@dev"
}
}
```

Then run `composer install`

### Manual Installation

There are three options:
- [recommended] download the latest release of the fattureincloud-php-sdk [Phar Archive](https://github.com/fattureincloud/fattureincloud-php-sdk/releases) and simply include it in your project.
Download the files and include `autoload.php`:

```php
require_once('./fattureincloud-php-sdk.phar');
<?php
require_once('/path/to/{{packageName}}/vendor/autoload.php');
```
- download our sdk using [php-download](https://php-download.com/package/fattureincloud/fattureincloud-php-sdk) and simply include it in your project.
- create your own custom autoloader and download all the dependencies (transitive included) as explained [here](https://ehikioya.com/how-to-install-php-packages-without-composer/).

## Getting Started

Please follow the [installation procedure](#installation--usage) and then run the following:

```php
<?php
<?php
require_once(__DIR__ . '/vendor/autoload.php');

{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
{{> php_doc_auth_partial}}
{{> php_doc_auth_partial}}

$apiInstance = new {{invokerPackage}}\Api\{{classname}}(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(){{#hasAuthMethods}},
$config{{/hasAuthMethods}}
);
{{#allParams}}${{paramName}} = {{#isPrimitiveType}}{{{example}}}{{/isPrimitiveType}}{{^isPrimitiveType}}new {{{dataType}}}{{/isPrimitiveType}}; // {{{dataType}}}{{#description}} | {{{.}}}{{/description}}
{{/allParams}}
{{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}}{{#description}} | {{{.}}}{{/description}}
{{/allParams}}

try {
{{#returnType}}$result = {{/returnType}}$apiInstance->{{{operationId}}}({{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}}
print_r($result);{{/returnType}}
} catch (Exception $e) {
print_r($result);{{/returnType}}
} catch (Exception $e) {
echo 'Exception when calling {{classname}}->{{operationId}}: ', $e->getMessage(), PHP_EOL;
}
}
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
```

Expand All @@ -75,40 +86,41 @@ Class | Method | HTTP request | Description
{{/models}}

## Authorization
{{^authMethods}}
All endpoints do not require authorization.
{{/authMethods}}
{{^authMethods}}Endpoints do not require authorization.{{/authMethods}}
{{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}}
{{#authMethods}}
{{#last}} Authentication schemes defined for the API:{{/last}}
### {{{name}}}
{{#isApiKey}}

- **Type**: API key
- **API key parameter name**: {{{keyParamName}}}
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}

{{/isApiKey}}
{{#isBasic}}
{{#isBasicBasic}}

- **Type**: HTTP basic authentication
{{/isBasicBasic}}
{{#isBasicBearer}}

- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}
{{/isBasicBearer}}

{{/isBasic}}
{{#isOAuth}}

- **Type**: `OAuth`
- **Flow**: `{{{flow}}}`
- **Authorization URL**: `{{{authorizationUrl}}}`
- **Scopes**: {{^scopes}}N/A{{/scopes}}
{{#scopes}}
- **{{{scope}}}**: {{{description}}}
{{/scopes}}
{{/isOAuth}}
### {{{name}}}
{{#isApiKey}}

- **Type**: API key
- **API key parameter name**: {{{keyParamName}}}
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}

{{/isApiKey}}
{{#isBasic}}
{{#isBasicBasic}}

- **Type**: HTTP basic authentication
{{/isBasicBasic}}
{{#isBasicBearer}}

- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}
{{/isBasicBearer}}
{{#isHttpSignature}}

- **Type**: HTTP signature authentication
{{/isHttpSignature}}
{{/isBasic}}
{{#isOAuth}}

- **Type**: `OAuth`
- **Flow**: `{{{flow}}}`
- **Authorization URL**: `{{{authorizationUrl}}}`
- **Scopes**: {{^scopes}}N/A{{/scopes}}
{{#scopes}}
- **{{{scope}}}**: {{{description}}}
{{/scopes}}
{{/isOAuth}}

{{/authMethods}}
## Tests
Expand All @@ -135,4 +147,5 @@ This PHP package is automatically generated by the [OpenAPI Generator](https://o
{{^hideGenerationTimestamp}}
- Build date: `{{generatedDate}}`
{{/hideGenerationTimestamp}}
- Generator version: `{{generatorVersion}}`
- Build package: `{{generatorClass}}`
19 changes: 10 additions & 9 deletions templates/openapi-generator/php/api_doc.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# {{invokerPackage}}\{{classname}}{{#description}}
# {{invokerPackage}}\{{classname}}{{#operationTagDescription}}

{{.}}{{/description}}
{{operationTagDescription}}{{/operationTagDescription}}

All URIs are relative to {{basePath}}, except if the operation defines another base path.

Expand Down Expand Up @@ -40,20 +40,21 @@ All URIs are relative to {{basePath}}, except if the operation defines another b
require_once(__DIR__ . '/vendor/autoload.php');

{{> php_doc_auth_partial}}

$apiInstance = new {{invokerPackage}}\Api\{{classname}}(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(){{#hasAuthMethods}},
$config{{/hasAuthMethods}}
);
{{^vendorExtensions.x-group-parameters}}
{{#allParams}}${{paramName}} = {{#isPrimitiveType}}{{{example}}}{{/isPrimitiveType}}{{^isPrimitiveType}}new {{{dataType}}}{{/isPrimitiveType}}; // {{{dataType}}}{{#description}} | {{{.}}}{{/description}}
{{^exts.x-group-parameters}}
{{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}}{{#description}} | {{{.}}}{{/description}}
{{/allParams}}{{#servers}}{{#-first}}
$hostIndex = 0;
$variables = [{{#variables}}
'{{{name}}}' => '{{{default}}}{{^default}}YOUR_VALUE{{/default}}',{{/variables}}
];
{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}
{{/-first}}{{/servers}}{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}
$associative_array = [
{{#allParams}} '{{paramName}}' => {{{example}}}, // {{{dataType}}}{{#description}} | {{{.}}}{{/description}}
{{/allParams}}
Expand All @@ -63,10 +64,10 @@ $associative_array = [
'{{{name}}}' => '{{{default}}}{{^default}}YOUR_VALUE{{/default}}',{{/variables}}
],
{{/-first}}{{/servers}}];
{{/vendorExtensions.x-group-parameters}}
{{/exts.x-group-parameters}}

try {
{{#returnType}}$result = {{/returnType}}$apiInstance->{{{operationId}}}({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}$hostIndex, $variables{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associate_array{{/vendorExtensions.x-group-parameters}});{{#returnType}}
{{#returnType}}$result = {{/returnType}}$apiInstance->{{{operationId}}}({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}$hostIndex, $variables{{/-first}}{{/servers}}{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associate_array{{/exts.x-group-parameters}});{{#returnType}}
print_r($result);{{/returnType}}
} catch (Exception $e) {
echo 'Exception when calling {{classname}}->{{operationId}}: ', $e->getMessage(), PHP_EOL;
Expand All @@ -75,10 +76,10 @@ try {

### Parameters

{{#vendorExtensions.x-group-parameters}}
{{#exts.x-group-parameters}}
Note: the input parameter is an associative array with the keys listed as the parameter names below.

{{/vendorExtensions.x-group-parameters}}
{{/exts.x-group-parameters}}
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}| Name | Type | Description | Notes |
| ------------- | ------------- | ------------- | ------------- |{{/-last}}{{/allParams}}
{{#allParams}}| **{{paramName}}** | {{#isFile}}**{{{dataType}}}**{{/isFile}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{{dataType}}}**](../Model/{{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{.}}]{{/defaultValue}} |
Expand Down
16 changes: 8 additions & 8 deletions templates/openapi-generator/php/composer.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
"rest",
"api"
],
"homepage": "https://www.fattureincloud.it",
"license": "MIT",
"homepage": "{{{artifactUrl}}}",
"license": "{{{licenseName}}}",
"authors": [
{
"name": "Fatture in Cloud API Team",
"homepage": "https://www.fattureincloud.it"
"name": "{{{developerOrganization}}}",
"homepage": "{{{developerOrganizationUrl}}}"
}
],
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.1",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^7.4.5",
"guzzlehttp/psr7": "^2.1.1"
"guzzlehttp/guzzle": "^7.3",
"guzzlehttp/psr7": "^1.7 || ^2.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"phpunit/phpunit": "^8.0 || ^9.0",
"friendsofphp/php-cs-fixer": "^3.5"
},
"autoload": {
Expand Down
Loading