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; $request_class = static::REQUEST_CLASS;
/** @var RequestContract $request */ /** @var RequestContract $result */
$request = new $request_class(); $result = new $request_class();
$request->setName($item->name); $result->setName($item->name);
$request->setHttpVersion(1.1); //TODO http version? $result->setHttpVersion(1.1); //TODO http version?
$request->setDescription($item->request?->description ?? null); $result->setDescription($item->request?->description ?? null);
$request->setVerb($item->request->method); $result->setVerb($item->request->method);
$request->setUrl($item->request->url->raw); $result->setUrl($item->request->url->raw);
$request->setHeaders($item->request->header); $result->setHeaders($item->request->header);
$request->setAuth($item->request?->auth ?? $this->collection?->auth ?? null); $result->setAuth($item->request?->auth ?? $this->collection?->auth ?? null);
if ($item->request->method !== 'GET' && !empty($item->request->body)) { 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); $this->setBodymode($body->mode);
if ($body->mode === 'formdata') { if ($body->mode === 'formdata') {
$this->setHeader('Content-Type', 'multipart/form-data')->setFormdataBody($body); $this->setHeader('Content-Type', 'multipart/form-data')
} elseif ($body->mode === 'raw') { ->setFormdataBody($body);
$this->setBodyAsIs($body); } elseif (!empty($body->options) && $body->options->{$this->bodymode}->language === 'json') {
if (!empty($body->options) && $body->options->{$this->bodymode}->language === 'json') { $this->setHeader('Content-Type', 'application/json')
$this->setHeader('Content-Type', 'application/json'); ->setJsonBody($body);
}
} }
return $this; return $this;
} }
@ -252,7 +251,7 @@ abstract class AbstractRequest implements Stringable, RequestContract
* @param object $body * @param object $body
* @return $this * @return $this
*/ */
protected function setBodyAsIs(object $body): static protected function setJsonBody(object $body): static
{ {
$this->body = $body->{$this->getBodymode()}; $this->body = $body->{$this->getBodymode()};
return $this; return $this;

View File

@ -21,7 +21,7 @@ class Processor
/** /**
* Converter version * Converter version
*/ */
public const VERSION = '1.4.1'; public const VERSION = '1.4.0';
/** /**
* @var string[] Paths to collection files * @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::setBodymode()
* @covers PmConverter\Converters\Abstract\AbstractRequest::setHeader() * @covers PmConverter\Converters\Abstract\AbstractRequest::setHeader()
* @covers PmConverter\Converters\Abstract\AbstractRequest::setBody() * @covers PmConverter\Converters\Abstract\AbstractRequest::setBody()
* @covers PmConverter\Converters\Abstract\AbstractRequest::setBodyAsIs() * @covers PmConverter\Converters\Abstract\AbstractRequest::setJsonBody()
* @covers PmConverter\Converters\Abstract\AbstractRequest::getBody() * @covers PmConverter\Converters\Abstract\AbstractRequest::getBody()
* @return void * @return void
*/ */