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
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public class CodegenConfigurator implements Serializable {
private Set<String> languageSpecificPrimitives = new HashSet<String>();
private Map<String, String> reservedWordMappings = new HashMap<String, String>();

private String gitUserId = "GIT_USER_ID";
private String gitRepoId = "GIT_REPO_ID";
private String gitUserId = "git_user_id";
private String gitRepoId = "git_repo_id";
private String gitRepoBaseURL = "GIT_REPO_BASE_URL";
private String releaseNote = "Minor update";
private String httpUserAgent;
Expand Down
20 changes: 14 additions & 6 deletions modules/swagger-codegen/src/main/resources/php/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace {{apiPackage}};
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Exception\TransferException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
Expand Down Expand Up @@ -138,6 +139,13 @@ use {{invokerPackage}}\ObjectSerializer;
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
} catch (TransferException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
null,
null
);
}

$statusCode = $response->getStatusCode();
Expand All @@ -162,7 +170,7 @@ use {{invokerPackage}}\ObjectSerializer;
} else {
$content = $responseBody->getContents();
if ($returnType !== 'string') {
$content = json_decode($content);
$content = \GuzzleHttp\Utils::jsonDecode($content);
}
}

Expand Down Expand Up @@ -253,7 +261,7 @@ use {{invokerPackage}}\ObjectSerializer;
} else {
$content = $responseBody->getContents();
if ($returnType !== 'string') {
$content = json_decode($content);
$content = \GuzzleHttp\Utils::jsonDecode($content);
}
}

Expand Down Expand Up @@ -396,7 +404,7 @@ use {{invokerPackage}}\ObjectSerializer;
if (${{paramName}} !== null) {
{{#isFile}}
$multipart = true;
$formParams['{{baseName}}'] = \GuzzleHttp\Psr7\try_fopen(ObjectSerializer::toFormValue(${{paramName}}), 'rb');
$formParams['{{baseName}}'] = \GuzzleHttp\Psr7\Utils::TryFopen(ObjectSerializer::toFormValue(${{paramName}}), 'rb');
{{/isFile}}
{{^isFile}}
$formParams['{{baseName}}'] = ObjectSerializer::toFormValue(${{paramName}});
Expand Down Expand Up @@ -430,11 +438,11 @@ use {{invokerPackage}}\ObjectSerializer;
if($headers['Content-Type'] === 'application/json') {
// \stdClass has no __toString(), so we should encode it manually
if ($httpBody instanceof \stdClass) {
$httpBody = \GuzzleHttp\json_encode($httpBody);
$httpBody = \GuzzleHttp\Utils::jsonEncode($httpBody);
}
// array has no __toString(), so we should encode it manually
if(is_array($httpBody)) {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($httpBody));
}
}
} elseif (count($formParams) > 0) {
Expand All @@ -450,7 +458,7 @@ use {{invokerPackage}}\ObjectSerializer;
$httpBody = new MultipartStream($multipartContents);

} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);

} else {
// for HTTP post (form)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^6.2"
"guzzlehttp/guzzle": "^7.3"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ info:
license:
name: Apache-2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
host: petstore.swagger.io:80
host: petstore.swagger.io
basePath: /v2
tags:
- name: pet
Expand All @@ -25,6 +25,7 @@ tags:
description: Find out more about our store
url: 'http://swagger.io'
schemes:
- https
- http
paths:
/pet:
Expand Down
82 changes: 67 additions & 15 deletions samples/client/petstore/php/SwaggerClient-php/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SwaggerClient-php
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\

This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:

Expand All @@ -20,11 +20,11 @@ To install the bindings via [Composer](http://getcomposer.org/), add the followi
"repositories": [
{
"type": "git",
"url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
"url": "https://github.com/git_user_id/git_repo_id.git"
}
],
"require": {
"GIT_USER_ID/GIT_REPO_ID": "*@dev"
"git_user_id/git_repo_id": "*@dev"
}
}
```
Expand Down Expand Up @@ -56,32 +56,41 @@ Please follow the [installation procedure](#installation--usage) and then run th
<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: petstore_auth
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');

$apiInstance = new Swagger\Client\Api\PetApi(
$apiInstance = new Swagger\Client\Api\AnotherFakeApi(
// 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(),
$config
new GuzzleHttp\Client()
);
$body = new \Swagger\Client\Model\Pet(); // \Swagger\Client\Model\Pet | Pet object that needs to be added to the store
$body = new \Swagger\Client\Model\Client(); // \Swagger\Client\Model\Client | client model

try {
$apiInstance->addPet($body);
$result = $apiInstance->testSpecialTags($body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling PetApi->addPet: ', $e->getMessage(), PHP_EOL;
echo 'Exception when calling AnotherFakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL;
}

?>
```

## Documentation for API Endpoints

All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *https://petstore.swagger.io/v2*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AnotherFakeApi* | [**testSpecialTags**](docs/Api/AnotherFakeApi.md#testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/Api/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/Api/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite |
*FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number |
*FakeApi* | [**fakeOuterStringSerialize**](docs/Api/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string |
*FakeApi* | [**testBodyWithQueryParams**](docs/Api/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params |
*FakeApi* | [**testClientModel**](docs/Api/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \&quot;client\&quot; model
*FakeApi* | [**testEndpointParameters**](docs/Api/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*FakeApi* | [**testEnumParameters**](docs/Api/FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters
*FakeApi* | [**testInlineAdditionalProperties**](docs/Api/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
*FakeApi* | [**testJsonFormData**](docs/Api/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data
*FakeClassnameTags123Api* | [**testClassname**](docs/Api/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case
*PetApi* | [**addPet**](docs/Api/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
*PetApi* | [**deletePet**](docs/Api/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
*PetApi* | [**findPetsByStatus**](docs/Api/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
Expand All @@ -90,9 +99,9 @@ Class | Method | HTTP request | Description
*PetApi* | [**updatePet**](docs/Api/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet
*PetApi* | [**updatePetWithForm**](docs/Api/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
*PetApi* | [**uploadFile**](docs/Api/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
*StoreApi* | [**deleteOrder**](docs/Api/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
*StoreApi* | [**deleteOrder**](docs/Api/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
*StoreApi* | [**getInventory**](docs/Api/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
*StoreApi* | [**getOrderById**](docs/Api/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID
*StoreApi* | [**getOrderById**](docs/Api/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID
*StoreApi* | [**placeOrder**](docs/Api/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet
*UserApi* | [**createUser**](docs/Api/UserApi.md#createuser) | **POST** /user | Create user
*UserApi* | [**createUsersWithArrayInput**](docs/Api/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array
Expand All @@ -106,10 +115,43 @@ Class | Method | HTTP request | Description

## Documentation For Models

- [AdditionalPropertiesClass](docs/Model/AdditionalPropertiesClass.md)
- [Animal](docs/Model/Animal.md)
- [AnimalFarm](docs/Model/AnimalFarm.md)
- [ApiResponse](docs/Model/ApiResponse.md)
- [ArrayOfArrayOfNumberOnly](docs/Model/ArrayOfArrayOfNumberOnly.md)
- [ArrayOfNumberOnly](docs/Model/ArrayOfNumberOnly.md)
- [ArrayTest](docs/Model/ArrayTest.md)
- [Boolean](docs/Model/Boolean.md)
- [Capitalization](docs/Model/Capitalization.md)
- [Cat](docs/Model/Cat.md)
- [Category](docs/Model/Category.md)
- [ClassModel](docs/Model/ClassModel.md)
- [Client](docs/Model/Client.md)
- [Dog](docs/Model/Dog.md)
- [EnumArrays](docs/Model/EnumArrays.md)
- [EnumClass](docs/Model/EnumClass.md)
- [EnumTest](docs/Model/EnumTest.md)
- [FormatTest](docs/Model/FormatTest.md)
- [HasOnlyReadOnly](docs/Model/HasOnlyReadOnly.md)
- [Ints](docs/Model/Ints.md)
- [MapTest](docs/Model/MapTest.md)
- [MixedPropertiesAndAdditionalPropertiesClass](docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md)
- [Model200Response](docs/Model/Model200Response.md)
- [ModelList](docs/Model/ModelList.md)
- [ModelReturn](docs/Model/ModelReturn.md)
- [Name](docs/Model/Name.md)
- [NumberOnly](docs/Model/NumberOnly.md)
- [Numbers](docs/Model/Numbers.md)
- [Order](docs/Model/Order.md)
- [OuterBoolean](docs/Model/OuterBoolean.md)
- [OuterComposite](docs/Model/OuterComposite.md)
- [OuterEnum](docs/Model/OuterEnum.md)
- [OuterNumber](docs/Model/OuterNumber.md)
- [OuterString](docs/Model/OuterString.md)
- [Pet](docs/Model/Pet.md)
- [ReadOnlyFirst](docs/Model/ReadOnlyFirst.md)
- [SpecialModelName](docs/Model/SpecialModelName.md)
- [Tag](docs/Model/Tag.md)
- [User](docs/Model/User.md)

Expand All @@ -123,6 +165,16 @@ Class | Method | HTTP request | Description
- **API key parameter name**: api_key
- **Location**: HTTP header

## api_key_query

- **Type**: API key
- **API key parameter name**: api_key_query
- **Location**: URL query string

## http_basic_test

- **Type**: HTTP basic authentication

## petstore_auth

- **Type**: OAuth
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "GIT_USER_ID/GIT_REPO_ID",
"name": "git_user_id/git_repo_id",
"description": "",
"keywords": [
"swagger",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Swagger\Client\AnotherFakeApi

All URIs are relative to *http://petstore.swagger.io:80/v2*
All URIs are relative to *https://petstore.swagger.io/v2*

Method | HTTP request | Description
------------- | ------------- | -------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Swagger\Client\FakeApi

All URIs are relative to *http://petstore.swagger.io:80/v2*
All URIs are relative to *https://petstore.swagger.io/v2*

Method | HTTP request | Description
------------- | ------------- | -------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Swagger\Client\FakeClassnameTags123Api

All URIs are relative to *http://petstore.swagger.io:80/v2*
All URIs are relative to *https://petstore.swagger.io/v2*

Method | HTTP request | Description
------------- | ------------- | -------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Swagger\Client\PetApi

All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *https://petstore.swagger.io/v2*

Method | HTTP request | Description
------------- | ------------- | -------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Swagger\Client\StoreApi

All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *https://petstore.swagger.io/v2*

Method | HTTP request | Description
------------- | ------------- | -------------
[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID
[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Swagger\Client\UserApi

All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *https://petstore.swagger.io/v2*

Method | HTTP request | Description
------------- | ------------- | -------------
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/php/SwaggerClient-php/git_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ git_repo_id=$2
release_note=$3

if [ "$git_user_id" = "" ]; then
git_user_id="GIT_USER_ID"
git_user_id="git_user_id"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi

if [ "$git_repo_id" = "" ]; then
git_repo_id="GIT_REPO_ID"
git_repo_id="git_repo_id"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,7 @@ protected function uploadFileRequest($pet_id, $additional_metadata = null, $file
// form params
if ($file !== null) {
$multipart = true;
$formParams['file'] = \GuzzleHttp\Psr7\try_fopen(ObjectSerializer::toFormValue($file), 'rb');
$formParams['file'] = \GuzzleHttp\Psr7\Utils::TryFopen(ObjectSerializer::toFormValue($file), 'rb');
}
// body params
$_tempBody = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
/**
* Swagger Petstore
*
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
* Swagger Codegen version: 2.4.3-SNAPSHOT
* Swagger Codegen version: 2.4.22-SNAPSHOT
*/

/**
Expand Down Expand Up @@ -81,7 +81,7 @@ class Configuration
*
* @var string
*/
protected $host = 'http://petstore.swagger.io/v2';
protected $host = 'https://petstore.swagger.io/v2';

/**
* User agent of the HTTP request, set to "PHP-Swagger" by default
Expand Down
Loading