[Golang][client] fix for schema definition name file (#433)

* fix schema/definition name as 'file'

* update samples

* Trigger CI due to previous Shippable race condition

* add fix with toModelName(openAPIType)

* update tests for file schema/definition name

* Update 3.0 test spec

* update samples

* update samples for jaxrs-cxf

* Trigger CI due to previous Shippable race condition

* add back explode
This commit is contained in:
John Wang
2018-07-05 05:32:24 -07:00
committed by William Cheng
parent 036570d93d
commit 0bffdf2463
185 changed files with 10409 additions and 11 deletions

View File

@@ -1151,6 +1151,221 @@ class FakeApi
);
}
/**
* Operation testBodyWithFileSchema
*
* @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class file_schema_test_class (required)
*
* @throws \OpenAPI\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return void
*/
public function testBodyWithFileSchema($file_schema_test_class)
{
$this->testBodyWithFileSchemaWithHttpInfo($file_schema_test_class);
}
/**
* Operation testBodyWithFileSchemaWithHttpInfo
*
* @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class (required)
*
* @throws \OpenAPI\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of null, HTTP status code, HTTP response headers (array of strings)
*/
public function testBodyWithFileSchemaWithHttpInfo($file_schema_test_class)
{
$request = $this->testBodyWithFileSchemaRequest($file_schema_test_class);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
/**
* Operation testBodyWithFileSchemaAsync
*
*
*
* @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function testBodyWithFileSchemaAsync($file_schema_test_class)
{
return $this->testBodyWithFileSchemaAsyncWithHttpInfo($file_schema_test_class)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation testBodyWithFileSchemaAsyncWithHttpInfo
*
*
*
* @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function testBodyWithFileSchemaAsyncWithHttpInfo($file_schema_test_class)
{
$returnType = '';
$request = $this->testBodyWithFileSchemaRequest($file_schema_test_class);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
return [null, $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()
);
}
);
}
/**
* Create request for operation 'testBodyWithFileSchema'
*
* @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class (required)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
protected function testBodyWithFileSchemaRequest($file_schema_test_class)
{
// verify the required parameter 'file_schema_test_class' is set
if ($file_schema_test_class === null || (is_array($file_schema_test_class) && count($file_schema_test_class) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $file_schema_test_class when calling testBodyWithFileSchema'
);
}
$resourcePath = '/fake/body-with-file-schema';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// body params
$_tempBody = null;
if (isset($file_schema_test_class)) {
$_tempBody = $file_schema_test_class;
}
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
[]
);
} else {
$headers = $this->headerSelector->selectHeaders(
[],
['application/json']
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
$httpBody = $_tempBody;
// \stdClass has no __toString(), so we should encode it manually
if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($httpBody);
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation testBodyWithQueryParams
*