Skip to content

Commit

Permalink
use parameter name as description if not defined (#6557)
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 authored Sep 24, 2017
1 parent c501103 commit 2d44d7f
Show file tree
Hide file tree
Showing 41 changed files with 185 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ use {{invokerPackage}}\ObjectSerializer;
*
{{/description}}
{{#allParams}}
* @param {{dataType}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
* @param {{dataType}} ${{paramName}}{{#description}} {{description}}{{/description}}{{^description}} {{paramName}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}}
*
* @throws \{{invokerPackage}}\ApiException on non-2xx response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa
/**
* Sets {{name}}
*
* @param {{datatype}} ${{name}}{{#description}} {{{description}}}{{/description}}
* @param {{datatype}} ${{name}}{{#description}} {{{description}}}{{/description}}{{^description}} {{{name}}}{{/description}}
*
* @return $this
*/
Expand Down
12 changes: 6 additions & 6 deletions samples/client/petstore/php/SwaggerClient-php/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ Please follow the [installation procedure](#installation--usage) and then run th
<?php
require_once(__DIR__ . '/vendor/autoload.php');

$api_instance = new Swagger\Client\Api\FakeApi();
$body = new \Swagger\Client\Model\OuterBoolean(); // \Swagger\Client\Model\OuterBoolean | Input boolean as post body
$api_instance = new Swagger\Client\Api\AnotherFakeApi();
$body = new \Swagger\Client\Model\Client(); // \Swagger\Client\Model\Client | client model

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

?>
Expand All @@ -75,6 +75,7 @@ All URIs are relative to *http://petstore.swagger.io:80/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 |
Expand All @@ -83,7 +84,7 @@ Class | Method | HTTP request | Description
*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* | [**testJsonFormData**](docs/Api/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data
*Fake_classname_tags123Api* | [**testClassname**](docs/Api/Fake_classname_tags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case
*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 @@ -104,7 +105,6 @@ Class | Method | HTTP request | Description
*UserApi* | [**loginUser**](docs/Api/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system
*UserApi* | [**logoutUser**](docs/Api/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session
*UserApi* | [**updateUser**](docs/Api/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user
*AnotherfakeApi* | [**testSpecialTags**](docs/Api/AnotherfakeApi.md#testspecialtags) | **PATCH** /another-fake/dummy | To test special tags


## Documentation For Models
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Swagger\Client\AnotherfakeApi
# Swagger\Client\AnotherFakeApi

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

Method | HTTP request | Description
------------- | ------------- | -------------
[**testSpecialTags**](AnotherfakeApi.md#testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
[**testSpecialTags**](AnotherFakeApi.md#testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags


# **testSpecialTags**
Expand All @@ -19,14 +19,14 @@ To test special tags
<?php
require_once(__DIR__ . '/vendor/autoload.php');

$api_instance = new Swagger\Client\Api\AnotherfakeApi(new \Http\Adapter\Guzzle6\Client());
$api_instance = new Swagger\Client\Api\AnotherFakeApi(new \Http\Adapter\Guzzle6\Client());
$body = new \Swagger\Client\Model\Client(); // \Swagger\Client\Model\Client | client model

try {
$result = $api_instance->testSpecialTags($body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AnotherfakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL;
echo 'Exception when calling AnotherFakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL;
}
?>
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ $api_instance = new Swagger\Client\Api\FakeApi(new \Http\Adapter\Guzzle6\Client(
$number = 3.4; // float | None
$double = 1.2; // double | None
$pattern_without_delimiter = "pattern_without_delimiter_example"; // string | None
$byte = "B"; // string | None
$byte = "byte_example"; // string | None
$integer = 56; // int | None
$int32 = 56; // int | None
$int64 = 789; // int | None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ This endpoint does not need any parameter.

### Return type

[**map[string,int]**](../Model/map.md)
**map[string,int]**

### Authorization

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* AnotherfakeApi
* AnotherFakeApi
* PHP version 5
*
* @category Class
Expand All @@ -17,7 +17,6 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
*/

/**
Expand All @@ -39,14 +38,14 @@
use Swagger\Client\ObjectSerializer;

/**
* AnotherfakeApi Class Doc Comment
* AnotherFakeApi Class Doc Comment
*
* @category Class
* @package Swagger\Client
* @author Swagger Codegen team
* @link https://github.com/swagger-api/swagger-codegen
*/
class AnotherfakeApi
class AnotherFakeApi
{
/**
* @var ClientInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1533,8 +1533,8 @@ protected function testEndpointParametersRequest($number, $double, $pattern_with
'Missing the required parameter $pattern_without_delimiter when calling testEndpointParameters'
);
}
if (!preg_match("/^[A-Z].*_/", $pattern_without_delimiter)) {
throw new \InvalidArgumentException("invalid value for \"pattern_without_delimiter\" when calling FakeApi.testEndpointParameters, must conform to the pattern /^[A-Z].*_/.");
if (!preg_match("/^[A-Z].*/", $pattern_without_delimiter)) {
throw new \InvalidArgumentException("invalid value for \"pattern_without_delimiter\" when calling FakeApi.testEndpointParameters, must conform to the pattern /^[A-Z].*/.");
}

// verify the required parameter 'byte' is set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class FakeClassnameTags123Api

/**
* @param ClientInterface $client
* @param Configuration $config
* @param HeaderSelector $selector
* @param Configuration $config
* @param HeaderSelector $selector
*/
public function __construct(
ClientInterface $client = null,
Expand All @@ -85,7 +85,8 @@ public function getConfig()
*
* To test class name in snake case
*
* @param \Swagger\Client\Model\Client $body client model (required)
* @param \Swagger\Client\Model\Client $body client model (required)
*
* @throws \Swagger\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \Swagger\Client\Model\Client
Expand All @@ -101,7 +102,8 @@ public function testClassname($body)
*
* To test class name in snake case
*
* @param \Swagger\Client\Model\Client $body client model (required)
* @param \Swagger\Client\Model\Client $body client model (required)
*
* @throws \Swagger\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \Swagger\Client\Model\Client, HTTP status code, HTTP response headers (array of strings)
Expand All @@ -127,7 +129,11 @@ public function testClassnameWithHttpInfo($body)

if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
"[$statusCode] Error connecting to the API ({$request->getUri()})",
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
Expand All @@ -153,7 +159,11 @@ public function testClassnameWithHttpInfo($body)
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Client', $e->getResponseHeaders());
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Swagger\Client\Model\Client',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
Expand All @@ -166,23 +176,28 @@ public function testClassnameWithHttpInfo($body)
*
* To test class name in snake case
*
* @param \Swagger\Client\Model\Client $body client model (required)
* @param \Swagger\Client\Model\Client $body client model (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function testClassnameAsync($body)
{
return $this->testClassnameAsyncWithHttpInfo($body)->then(function ($response) {
return $response[0];
});
return $this->testClassnameAsyncWithHttpInfo($body)
->then(
function ($response) {
return $response[0];
}
);
}

/**
* Operation testClassnameAsyncWithHttpInfo
*
* To test class name in snake case
*
* @param \Swagger\Client\Model\Client $body client model (required)
* @param \Swagger\Client\Model\Client $body client model (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
Expand All @@ -191,46 +206,58 @@ public function testClassnameAsyncWithHttpInfo($body)
$returnType = '\Swagger\Client\Model\Client';
$request = $this->testClassnameRequest($body);

return $this->client->sendAsync($request)->then(function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
if ($returnType !== 'string') {
$content = json_decode($content);
return $this->client
->sendAsync($request)
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
if ($returnType !== 'string') {
$content = json_decode($content);
}
}

return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
}

return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
}, function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
"[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})",
$statusCode,
$response->getHeaders(),
$response->getBody()
);
});
}

/**
* Create request for operation 'testClassname'
*
* @param \Swagger\Client\Model\Client $body client model (required)
* @param \Swagger\Client\Model\Client $body client model (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function testClassnameRequest($body)
{
// verify the required parameter 'body' is set
if ($body === null) {
throw new \InvalidArgumentException('Missing the required parameter $body when calling testClassname');
throw new \InvalidArgumentException(
'Missing the required parameter $body when calling testClassname'
);
}

$resourcePath = '/fake_classname_test';
Expand Down Expand Up @@ -272,13 +299,15 @@ protected function testClassnameRequest($body)
'contents' => $formParamValue
];
}
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);

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

} else {
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}

Expand All @@ -288,9 +317,6 @@ protected function testClassnameRequest($body)
$queryParams['api_key_query'] = $apiKey;
}

$query = \GuzzleHttp\Psr7\build_query($queryParams);
$url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : '');

$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
Expand All @@ -302,9 +328,10 @@ protected function testClassnameRequest($body)
$headers
);

$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PATCH',
$url,
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ protected function addPetRequest($body)
* Deletes a pet
*
* @param int $pet_id Pet id to delete (required)
* @param string $api_key (optional)
* @param string $api_key api_key (optional)
*
* @throws \Swagger\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function getMapProperty()
/**
* Sets map_property
*
* @param map[string,string] $map_property
* @param map[string,string] $map_property map_property
*
* @return $this
*/
Expand All @@ -247,7 +247,7 @@ public function getMapOfMapProperty()
/**
* Sets map_of_map_property
*
* @param map[string,map[string,string]] $map_of_map_property
* @param map[string,map[string,string]] $map_of_map_property map_of_map_property
*
* @return $this
*/
Expand Down
Loading

0 comments on commit 2d44d7f

Please sign in to comment.