Skip postman schema conversion if it is already same as specified (#10)
This commit is contained in:
parent
01d29ee023
commit
60cad4b501
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace PmConverter\Converters\Postman20;
|
namespace PmConverter\Converters\Postman20;
|
||||||
|
|
||||||
use PmConverter\Collection;
|
use PmConverter\Collection;
|
||||||
|
use PmConverter\CollectionVersion;
|
||||||
use PmConverter\Converters\{
|
use PmConverter\Converters\{
|
||||||
Abstract\AbstractConverter,
|
Abstract\AbstractConverter,
|
||||||
ConverterContract};
|
ConverterContract};
|
||||||
@ -33,12 +34,16 @@ class Postman20Converter extends AbstractConverter implements ConverterContract
|
|||||||
public function convert(Collection $collection, string $outputPath): void
|
public function convert(Collection $collection, string $outputPath): void
|
||||||
{
|
{
|
||||||
$this->collection = $collection;
|
$this->collection = $collection;
|
||||||
|
// if data was exported from API, here is already valid json to
|
||||||
|
// just flush it in file, otherwise we need to convert it deeper
|
||||||
|
if ($this->collection->version() === CollectionVersion::Version21) {
|
||||||
$this->collection->info->schema = str_replace('/v2.1.', '/v2.0.', $this->collection->info->schema);
|
$this->collection->info->schema = str_replace('/v2.1.', '/v2.0.', $this->collection->info->schema);
|
||||||
$this->prepareOutputDir($outputPath);
|
|
||||||
$this->convertAuth($this->collection->raw());
|
$this->convertAuth($this->collection->raw());
|
||||||
foreach ($this->collection->item as $item) {
|
foreach ($this->collection->item as $item) {
|
||||||
$this->convertItem($item);
|
$this->convertItem($item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
$this->prepareOutputDir($outputPath);
|
||||||
$this->writeCollection();
|
$this->writeCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace PmConverter\Converters\Postman21;
|
namespace PmConverter\Converters\Postman21;
|
||||||
|
|
||||||
use PmConverter\Collection;
|
use PmConverter\Collection;
|
||||||
|
use PmConverter\CollectionVersion;
|
||||||
use PmConverter\Converters\{
|
use PmConverter\Converters\{
|
||||||
Abstract\AbstractConverter,
|
Abstract\AbstractConverter,
|
||||||
ConverterContract};
|
ConverterContract};
|
||||||
@ -33,12 +34,16 @@ class Postman21Converter extends AbstractConverter implements ConverterContract
|
|||||||
public function convert(Collection $collection, string $outputPath): void
|
public function convert(Collection $collection, string $outputPath): void
|
||||||
{
|
{
|
||||||
$this->collection = $collection;
|
$this->collection = $collection;
|
||||||
|
// if data was exported from API, here is already valid json to
|
||||||
|
// just flush it in file, otherwise we need to convert it deeper
|
||||||
|
if ($this->collection->version() === CollectionVersion::Version20) {
|
||||||
$this->collection->info->schema = str_replace('/v2.0.', '/v2.1.', $this->collection->info->schema);
|
$this->collection->info->schema = str_replace('/v2.0.', '/v2.1.', $this->collection->info->schema);
|
||||||
$this->prepareOutputDir($outputPath);
|
|
||||||
$this->convertAuth($this->collection->raw());
|
$this->convertAuth($this->collection->raw());
|
||||||
foreach ($this->collection->item as $item) {
|
foreach ($this->collection->item as $item) {
|
||||||
$this->convertItem($item);
|
$this->convertItem($item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
$this->prepareOutputDir($outputPath);
|
||||||
$this->writeCollection();
|
$this->writeCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user