Skip to content
Draft
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
176cfe3
Update raml2html's README.md
adriendupuis Jun 8, 2022
648bb8d
tools/raml2html/README.md: Update dir paths
adriendupuis Dec 28, 2022
79e058e
mv rest_api_reference_test.php to `raml2html.php test`
adriendupuis Jan 3, 2023
62ff107
TestCommand.php: Enh. output
adriendupuis Jan 4, 2023
44fa866
TestCommand.php: clean-up
adriendupuis Jan 4, 2023
d22ef9b
ReferenceTester.php: Fix DOMElement namespace
adriendupuis Jan 4, 2023
97bc053
update the REST API Reference tester for 4.4.0-beta1
adriendupuis Jan 19, 2023
227d9ca
ReferenceTester.php: Fix exclusion of /api/datebasedpublisher/v1
adriendupuis Jan 23, 2023
909d0ba
ReferenceTester.php: Also test (deprecated) and (removed) flags
adriendupuis Jan 24, 2023
17a3691
Upgrade raml2html/composer.json to PHP 7.4
adriendupuis Feb 9, 2023
52cffaa
ReferenceTester.php: Use extension's yaml_parse_file
adriendupuis Feb 16, 2023
7c3feee
composer.json: add required PHP extensions
adriendupuis Feb 16, 2023
0d4e4e5
README.md: Update to PHP 7.4
adriendupuis Feb 16, 2023
ae740b9
raml2html/README.md: Remove late note about PHP 7.4
adriendupuis Feb 16, 2023
d58efc8
Update tools/raml2html/src/Command/TestCommand.php
adriendupuis Feb 16, 2023
adb0644
ReferenceTester.php: Remove path testing already done by TestCommand
adriendupuis Feb 16, 2023
7a01b0a
Merge branch 'master' into rest-api-ref-tester
adriendupuis Jun 30, 2023
6d91570
raml2html TestCommand: set a default path to reference
adriendupuis Jul 3, 2023
b7da863
ReferenceTester.php: Update route config files for 4.5
adriendupuis Jul 3, 2023
85b00b3
Merge branch 'master' into rest-api-ref-tester
adriendupuis Jul 11, 2023
9b34b69
Update raml2html/README.md
adriendupuis Jul 11, 2023
69e9fd8
Merge branch 'master' into rest-api-ref-tester
adriendupuis Apr 19, 2024
3d84c42
Merge branch 'master' into rest-api-ref-tester
adriendupuis Apr 22, 2024
cb66155
TestTypeUsageCommand.php
adriendupuis Apr 22, 2024
e636c0f
ReferenceTester.php: Update conf file list
adriendupuis Apr 22, 2024
dee8083
TestCommand.php → TestCompareCommand.php
adriendupuis Apr 22, 2024
2a85d7d
ReferenceTester.php: Sort prefixes
adriendupuis Apr 23, 2024
ee761d9
ReferenceTester.php: Skip some prefixed routes
adriendupuis Apr 23, 2024
4239e12
REST TestLogicCommand
adriendupuis Apr 23, 2024
76e1aa9
TestLogicCommand.php: Tune down the header checking
adriendupuis Apr 24, 2024
1e7e61f
TestLogicCommand::checkAcceptHeaderAgainstBody
adriendupuis Apr 24, 2024
e91a1eb
Enhance TestLogicCommand headers VS bodies checking
adriendupuis Apr 25, 2024
cdb1f73
TestTypeUsageCommand.php: Fix recursion
adriendupuis Apr 29, 2024
6f078eb
Merge branch 'master' into rest-api-ref-tester
adriendupuis Sep 19, 2024
ca4cf8d
tools/raml2html/README.md: Update test:compare example
adriendupuis Sep 19, 2024
ea9fbf4
ReferenceTester.php: add connector-qualifio
adriendupuis Sep 19, 2024
ad1a184
ReferenceTester.php: inc. code readability
adriendupuis Sep 19, 2024
b976ef5
ReferenceTester.php: Exclude few bundles when using debug:router
adriendupuis Sep 20, 2024
9a5db0a
raml2html/README.md: enh. test:compare doc
adriendupuis Sep 20, 2024
622df54
test:type:usage: handle arrays of objects
adriendupuis Sep 24, 2024
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
30 changes: 25 additions & 5 deletions tools/raml2html/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,35 @@ Tool for generating static HTML from RAML definitions.

## Installation

Install required dependencies before use. Go to raml2html root directory and run:
PHP 7.4 and [Composer](https://getcomposer.org/) are required.

```
composer install
To install required dependencies, go to raml2html directory and run:

```sh
composer install;
```

To generate static HTML from RAML definitions, use the following code:
## Usage

To generate static HTML from RAML definitions, use the following code from project root:

```sh
php tools/raml2html/raml2html.php build --non-standard-http-methods=COPY,MOVE,PUBLISH,SWAP -t default -o docs/api/rest_api/rest_api_reference/output/ docs/api/rest_api/rest_api_reference/input/ez.raml
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no need to use a temporary location.

Suggested change
php tools/raml2html/raml2html.php build --non-standard-http-methods=COPY,MOVE,PUBLISH,SWAP -t default -o docs/api/rest_api/rest_api_reference/output/ docs/api/rest_api/rest_api_reference/input/ez.raml
php tools/raml2html/raml2html.php build --non-standard-http-methods=COPY,MOVE,PUBLISH,SWAP -t default -o docs/api/rest_api/rest_api_reference/ docs/api/rest_api/rest_api_reference/input/ez.raml

```

To test static HTML against an Ibexa DXP to find route removed and missing routes:

```sh
php tools/raml2html/raml2html.php build --non-standard-http-methods=COPY,MOVE,PUBLISH,SWAP -t default -o docs/api/rest_api_reference/output/ docs/api/rest_api_reference/input/ez.raml
php tools/raml2html/raml2html.php test docs/api/rest_api/rest_api_reference/rest_api_reference.html ~/ibexa-dxp
```

Note: The Ibexa DXP doesn't need to run.

```shell
mkdir ~/ibexa-dxp;
cd ~/ibexa-dxp;
composer create-project ibexa/commerce-skeleton . --no-install --ignore-platform-reqs --no-scripts;
composer install --ignore-platform-reqs --no-scripts;
cd -;
php tools/raml2html/raml2html.php test docs/api/rest_api/rest_api_reference/rest_api_reference.html ~/ibexa-dxp
```
4 changes: 4 additions & 0 deletions tools/raml2html/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
],
"require": {
"php": "^7.4",
"ext-json": "*",
"ext-yaml": "*",
"ext-dom": "*",
"ext-libxml": "*",
"symfony/console": "^4.2",
"raml-org/raml-php-parser": "dev-master",
"twig/twig": "^2.0",
Expand Down
2 changes: 2 additions & 0 deletions tools/raml2html/src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use EzSystems\Raml2Html\Command\BuildCommand;
use EzSystems\Raml2Html\Command\ClearCacheCommand;
use EzSystems\Raml2Html\Command\LintTypesCommand;
use EzSystems\Raml2Html\Command\TestCommand;
use EzSystems\Raml2Html\Generator\Generator;
use EzSystems\Raml2Html\RAML\ParserFactory;
use EzSystems\Raml2Html\Twig\Extension\HashExtension;
Expand Down Expand Up @@ -39,6 +40,7 @@ protected function getDefaultCommands(): array
$this->getRamlParserFactory()
),
new ClearCacheCommand(self::CACHE_DIR),
new TestCommand(),
]);
}

Expand Down
70 changes: 70 additions & 0 deletions tools/raml2html/src/Command/TestCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

declare(strict_types=1);

namespace EzSystems\Raml2Html\Command;

use EzSystems\Raml2Html\Test\ReferenceTester;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

final class TestCommand extends Command
{
/**
* {@inheritdoc}
*/
protected function configure(): void
{
$this->setName('test')
->setDescription('Compare REST API Reference documentation with Ibexa DXP routing configuration under /api/ibexa/v2 prefix')
->setHelp('It is recommended to not use --console-path and --routing-file options while testing the Rest API Reference HTML file against configuration. Those options are used to test that the default configuration file list is up-to-date and other subtleties.')
->addArgument('rest-api-reference', InputArgument::REQUIRED, 'Path to the REST API Reference HTML file')
->addArgument('ibexa-dxp-root', InputArgument::REQUIRED, 'Path to an Ibexa DXP root directory')
->addOption('console-path', 'c', InputOption::VALUE_OPTIONAL, 'Path to the console relative to Ibexa DXP root directory (if no value, use `bin/console`)', false)
->addOption('routing-file', 'f', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Path to a routing configuration YAML file relative to Ibexa DXP root directory', ReferenceTester::DEFAULT_FILE_LIST)
->addOption('tested-routes', 't', InputOption::VALUE_OPTIONAL,
"ref: Test if reference routes are found in the configuration file;\n
conf: Test if configuration routes are found in the reference file;\n
both: Test both.", 'both');
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$restApiReference = $input->getArgument('rest-api-reference');
if (!is_file($restApiReference)) {
$output->writeln("<error>$restApiReference doesn't exist or is not a file.</error>");
return 1;
}

$dxpRoot = $input->getArgument('ibexa-dxp-root');
if (!is_dir($dxpRoot)) {
$output->writeln("<error>$dxpRoot doesn't exist or is not a directory.</error>");
return 2;
}

$consolePath = $input->getOption('console-path');
if (null === $consolePath) {
$consolePath = 'bin/console';
}

$routingFiles = $input->getOption('routing-file');

$referenceTester = new ReferenceTester($restApiReference, $dxpRoot, $consolePath, $routingFiles, $output);

$testedRoutes = [
'ref' => ReferenceTester::TEST_REFERENCE_ROUTES,
'conf' => ReferenceTester::TEST_CONFIG_ROUTES,
'both' => ReferenceTester::TEST_ALL_ROUTES,
][$input->getOption('tested-routes')] ?? ReferenceTester::TEST_ALL_ROUTES;

$referenceTester->run($testedRoutes);

return 0;
}
}
Loading