Skip to content

Commit

Permalink
* When not using dot notation, overrides no longer remove all the ch…
Browse files Browse the repository at this point in the history
…ild keys in any parent array key. Instead, they are merged together.
  • Loading branch information
ProjectZero4 committed Sep 14, 2023
1 parent b32959d commit bee7e79
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Writing/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Knuckles\Scribe\Writing;

use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Storage;
use Knuckles\Scribe\Tools\ConsoleOutputUtils as c;
use Knuckles\Scribe\Tools\DocumentationConfig;
Expand Down Expand Up @@ -127,7 +128,7 @@ public function generatePostmanCollection(array $groupedEndpoints): string
$writer = app()->makeWith(PostmanCollectionWriter::class, ['config' => $this->config]);

$collection = $writer->generatePostmanCollection($groupedEndpoints);
$overrides = $this->config->get('postman.overrides', []);
$overrides = Arr::dot($this->config->get('postman.overrides', []));
if (count($overrides)) {
foreach ($overrides as $key => $value) {
data_set($collection, $key, $value);
Expand All @@ -147,7 +148,7 @@ public function generateOpenAPISpec(array $groupedEndpoints): string
$writer = app()->makeWith(OpenAPISpecWriter::class, ['config' => $this->config]);

$spec = $writer->generateSpecContent($groupedEndpoints);
$overrides = $this->config->get('openapi.overrides', []);
$overrides = Arr::dot($this->config->get('openapi.overrides', []));
if (count($overrides)) {
foreach ($overrides as $key => $value) {
data_set($spec, $key, $value);
Expand Down
3 changes: 2 additions & 1 deletion tests/Fixtures/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"_postman_id": "",
"description": "",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"version": "3.9.9"
"version": "3.9.9",
"termsOfService": "http://api.api.dev/terms-of-service"
},
"item": [
{
Expand Down
1 change: 1 addition & 0 deletions tests/Fixtures/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ info:
title: Laravel
description: ''
version: 3.9.9
termsOfService: "http://api.api.dev/terms-of-service"
servers:
-
url: 'http://localhost'
Expand Down
6 changes: 6 additions & 0 deletions tests/GenerateDocumentation/OutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ public function generated_postman_collection_file_is_correct()
config(['scribe.auth.enabled' => true]);
config(['scribe.postman.overrides' => [
'info.version' => '3.9.9',
'info' => [
'termsOfService' => 'http://api.api.dev/terms-of-service',
],
]]);
config([
'scribe.routes.0.apply.headers' => [
Expand Down Expand Up @@ -221,6 +224,9 @@ public function generated_openapi_spec_file_is_correct()
config(['scribe.openapi.enabled' => true]);
config(['scribe.openapi.overrides' => [
'info.version' => '3.9.9',
'info' => [
'termsOfService' => 'http://api.api.dev/terms-of-service',
],
]]);
config([
'scribe.routes.0.apply.headers' => [
Expand Down

0 comments on commit bee7e79

Please sign in to comment.