-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[APPS-4380] Components upgrade #15
base: feature/apps-4380-add-default-endpoints
Are you sure you want to change the base?
Changes from 3 commits
eae9e62
afca5ab
8dffd99
4d56b26
cc1d4d3
5246ae4
4b220a0
046cd4c
28c1ec6
7de9bd4
0ba1ef3
34f4598
d8a4b3c
ccc25d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2019-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace SprykerSdk\SyncApi\OpenApi\Merger; | ||
|
||
use cebe\openapi\spec\OpenApi; | ||
|
||
class ComponentMerger implements MergerInterface | ||
{ | ||
use OpenApiAccessorTrait; | ||
|
||
/** | ||
* @param \cebe\openapi\spec\OpenApi $targetOpenApi | ||
* @param \cebe\openapi\spec\OpenApi $sourceOpenApi | ||
* | ||
* @return \cebe\openapi\spec\OpenApi | ||
*/ | ||
public function merge(OpenApi $targetOpenApi, OpenApi $sourceOpenApi): OpenApi | ||
{ | ||
foreach ($this->getParameters($sourceOpenApi) as $parameterName => $parameter) { | ||
$this->addParameter($targetOpenApi, $parameterName, $parameter); | ||
} | ||
|
||
foreach ($this->getSchemas($sourceOpenApi) as $schemaName => $schema) { | ||
$this->addSchema($targetOpenApi, $schemaName, $schema); | ||
} | ||
|
||
return $targetOpenApi; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,7 @@ public function cleanUnused(OpenApi $openApi): OpenApi | |
|
||
$references = ReferenceFinder::findInArray($openApiAsArray); | ||
|
||
$openApi = $this->cleanUnusedParameters($openApi, $references); | ||
|
||
return $this->cleanUnusedSchemas($openApi, $references); | ||
return $this->cleanUnusedParameters($openApi, $references); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't remember seeing cleanup as part of the specification. What was the argument for implementing this, rather than treating unused parameters as a bug in the component sending the OpenAPI schema update? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed usage |
||
} | ||
|
||
/** | ||
|
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2019-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace SprykerSdk\SyncApi\OpenApi\Merger; | ||
|
||
use cebe\openapi\spec\OpenApi; | ||
|
||
class OpenApiMerger implements MergerInterface | ||
{ | ||
/** | ||
* @var array<\SprykerSdk\SyncApi\OpenApi\Merger\MergerInterface> | ||
*/ | ||
protected array $mergerCollection; | ||
|
||
/** | ||
* @var \SprykerSdk\SyncApi\OpenApi\Merger\ComponentsCleanerInterface | ||
*/ | ||
protected ComponentsCleanerInterface $componentsCleaner; | ||
|
||
/** | ||
* @param array<\SprykerSdk\SyncApi\OpenApi\Merger\MergerInterface> $mergerCollection | ||
* @param \SprykerSdk\SyncApi\OpenApi\Merger\ComponentsCleanerInterface $componentsCleaner | ||
*/ | ||
public function __construct( | ||
array $mergerCollection, | ||
ComponentsCleanerInterface $componentsCleaner | ||
) { | ||
$this->mergerCollection = $mergerCollection; | ||
$this->componentsCleaner = $componentsCleaner; | ||
} | ||
|
||
/** | ||
* @param \cebe\openapi\spec\OpenApi $targetOpenApi | ||
* @param \cebe\openapi\spec\OpenApi $sourceOpenApi | ||
* | ||
* @return \cebe\openapi\spec\OpenApi | ||
*/ | ||
public function merge(OpenApi $targetOpenApi, OpenApi $sourceOpenApi): OpenApi | ||
{ | ||
foreach ($this->mergerCollection as $merger) { | ||
$targetOpenApi = $merger->merge($targetOpenApi, $sourceOpenApi); | ||
} | ||
|
||
return $this->componentsCleaner->cleanUnused($targetOpenApi); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does anyone know why the OpenAPI schema is converted to JSON here as part of removing unused elements? There should definitely be a comment describing why that is necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed usage of this class but did not delete it for now - we may need to discuss this with Maksym when he's back from his vacation to understand if there is anything preventing us from deleting it.