Compare commits

..

No commits in common. "c6963e0574d72ff785c07beca1d3602da7414b3f" and "83794a746476d83d4b3f762c993dadc6e2dbd67e" have entirely different histories.

4 changed files with 19 additions and 20 deletions

View File

@ -132,19 +132,19 @@ abstract class AbstractConverter implements ConverterContract
{
$request_class = static::REQUEST_CLASS;
/** @var RequestContract $request */
$request = new $request_class();
$request->setName($item->name);
$request->setHttpVersion(1.1); //TODO http version?
$request->setDescription($item->request?->description ?? null);
$request->setVerb($item->request->method);
$request->setUrl($item->request->url->raw);
$request->setHeaders($item->request->header);
$request->setAuth($item->request?->auth ?? $this->collection?->auth ?? null);
/** @var RequestContract $result */
$result = new $request_class();
$result->setName($item->name);
$result->setHttpVersion(1.1); //TODO http version?
$result->setDescription($item->request?->description ?? null);
$result->setVerb($item->request->method);
$result->setUrl($item->request->url->raw);
$result->setHeaders($item->request->header);
$result->setAuth($item->request?->auth ?? $this->collection?->auth ?? null);
if ($item->request->method !== 'GET' && !empty($item->request->body)) {
$request->setBody($item->request->body);
$result->setBody($item->request->body);
}
return $request;
return $result;
}
/**

View File

@ -219,12 +219,11 @@ abstract class AbstractRequest implements Stringable, RequestContract
{
$this->setBodymode($body->mode);
if ($body->mode === 'formdata') {
$this->setHeader('Content-Type', 'multipart/form-data')->setFormdataBody($body);
} elseif ($body->mode === 'raw') {
$this->setBodyAsIs($body);
if (!empty($body->options) && $body->options->{$this->bodymode}->language === 'json') {
$this->setHeader('Content-Type', 'application/json');
}
$this->setHeader('Content-Type', 'multipart/form-data')
->setFormdataBody($body);
} elseif (!empty($body->options) && $body->options->{$this->bodymode}->language === 'json') {
$this->setHeader('Content-Type', 'application/json')
->setJsonBody($body);
}
return $this;
}
@ -252,7 +251,7 @@ abstract class AbstractRequest implements Stringable, RequestContract
* @param object $body
* @return $this
*/
protected function setBodyAsIs(object $body): static
protected function setJsonBody(object $body): static
{
$this->body = $body->{$this->getBodymode()};
return $this;

View File

@ -21,7 +21,7 @@ class Processor
/**
* Converter version
*/
public const VERSION = '1.4.1';
public const VERSION = '1.4.0';
/**
* @var string[] Paths to collection files

View File

@ -215,7 +215,7 @@ class AbstractRequestTest extends TestCase
* @covers PmConverter\Converters\Abstract\AbstractRequest::setBodymode()
* @covers PmConverter\Converters\Abstract\AbstractRequest::setHeader()
* @covers PmConverter\Converters\Abstract\AbstractRequest::setBody()
* @covers PmConverter\Converters\Abstract\AbstractRequest::setBodyAsIs()
* @covers PmConverter\Converters\Abstract\AbstractRequest::setJsonBody()
* @covers PmConverter\Converters\Abstract\AbstractRequest::getBody()
* @return void
*/