Skip to content
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

CXP-1300: Adds first product meta schema #17982

Merged
merged 3 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions components/catalogs/back/.php_cd.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
'Akeneo\Catalogs\Application',
'Akeneo\Catalogs\Infrastructure',

// Allowed dependencies in Infrastructure
'Symfony\Component\Config',
'Symfony\Component\Console',
'Symfony\Component\DependencyInjection',
Expand All @@ -50,25 +51,32 @@
'Symfony\Component\Validator',
'Doctrine\DBAL',
'Ramsey\Uuid\Uuid',
'League\Flysystem\Filesystem',
'Opis\JsonSchema',
'Psr\Log\LoggerInterface',
'Akeneo\Platform\Bundle\InstallerBundle',
'Akeneo\Platform\Bundle\FrameworkBundle\Security\SecurityFacadeInterface',
'Akeneo\Tool\Component\Api',
'Akeneo\UserManagement\Component\Model\UserInterface',
'Akeneo\UserManagement\Component\Repository\UserRepositoryInterface',
'Akeneo\Connectivity\Connection\ServiceApi',
'League\Flysystem\Filesystem',
'Akeneo\Tool\Bundle\MeasureBundle\ServiceApi',

/**********************************************************************************************************/
/* Below are dependencies that we have, but we shouldn't rely on them.
/* They are coupling exceptions that should be replaced by better alternatives, like ServiceAPIs.
/**********************************************************************************************************/

// This class is not clearly identified as public API
'Akeneo\Connectivity\Connection\Infrastructure\Apps\Security\ScopeMapperInterface',

// used in Persistence\Measurement
'Akeneo\Tool\Bundle\MeasureBundle\ServiceApi\FindMeasurementFamilies',
// used in GetCurrentUsernameTrait
'Akeneo\UserManagement\Component\Model\UserInterface',
'Akeneo\UserManagement\Component\Repository\UserRepositoryInterface',

// used in TemporaryEnrichmentBridge
'Akeneo\Tool\Bundle\ElasticsearchBundle\Client',
'Akeneo\Tool\Component\StorageUtils\Cursor\CursorFactoryInterface',
'Symfony\Component\OptionsResolver',

// @todo replace next ones with the ones from service API when available

// used in Persistence\Attribute
'Akeneo\Pim\Structure\Component\Model\AttributeInterface',
'Akeneo\Pim\Structure\Component\Repository\AttributeRepositoryInterface',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function validate($value, Constraint $constraint): void
}

$metaSchemaId = $value->{'$schema'} ?? null;
if (null === $metaSchemaId) {
if (null === $metaSchemaId || !\is_string($metaSchemaId)) {
$this->context
->buildViolation('You must provide a $schema reference.')
->addViolation();
Expand All @@ -53,7 +53,9 @@ public function validate($value, Constraint $constraint): void
}

$validator = new Validator();
$validator->resolver()->registerFile($metaSchemaId, $metaSchemaPath);
$resolver = $validator->resolver();
\assert(null !== $resolver);
$resolver->registerFile($metaSchemaId, $metaSchemaPath);

$result = $validator->validate($value, $metaSchemaId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function validSchemaDataProvider(): array
{
return [
'0.0.1 with valid schema' => [
'schema' => <<<'JSON'
'schema' => <<<'JSON_WRAP'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the diff pls?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rector complained about it.
https://github.com/rectorphp/rector/blob/main/rules/Php73/Rector/String_/SensitiveHereNowDocRector.php

I'm not sure why this rule exists.
Either we don't care and uses _WRAP or we disable the rule.
WDYT ?

{
"$id": "https://example.com/product",
"$schema": "https://api.akeneo.com/mapping/product/0.0.1/schema",
Expand All @@ -75,7 +75,7 @@ public function validSchemaDataProvider(): array
}
}
}
JSON,
JSON_WRAP,
],
];
}
Expand All @@ -84,7 +84,7 @@ public function invalidSchemaDataProvider(): array
{
return [
'0.0.1 with invalid type number' => [
'schema' => <<<'JSON'
'schema' => <<<'JSON_WRAP'
{
"$schema": "https://api.akeneo.com/mapping/product/0.0.1/schema",
"properties": {
Expand All @@ -93,17 +93,17 @@ public function invalidSchemaDataProvider(): array
}
}
}
JSON,
JSON_WRAP,
],
'0.0.1 with missing target type' => [
'schema' => <<<'JSON'
'schema' => <<<'JSON_WRAP'
{
"$schema": "https://api.akeneo.com/mapping/product/0.0.1/schema",
"properties": {
"price": {}
}
}
JSON,
JSON_WRAP,
],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function getActivatedCurrencies();
/**
* Return an array of currency codes
*
* @return array
* @return array<string>
*/
public function getActivatedCurrencyCodes();
}