Skip to content

Commit c0a7118

Browse files
committed
REST API Ref set JSON before XML
1 parent 00dc462 commit c0a7118

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

tools/api_refs/api_refs.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ PHPDOC_TEMPLATE_VERSION='3.8.0'; # Version of the phpDocumentor base template se
1818
PHPDOC_DIR="$(pwd)/tools/api_refs/.phpdoc"; # Absolute path to phpDocumentor resource directory (containing the override template set)
1919
REDOCLY_CONFIG="$(pwd)/tools/api_refs/redocly.yaml"; # Absolute path to Redocly configuration file
2020
REDOCLY_TEMPLATE="$(pwd)/tools/api_refs/redocly.hbs"; # Absolute path to Redocly wrapping template
21+
OPENAPI_FIX="$(pwd)/tools/api_refs/openapi.php"; # A script editing and fixing few things on the dumped schema (should be temporary and fixes reported to source)
2122

2223
PHP_BINARY="php -d error_reporting=`php -r 'echo E_ALL & ~E_DEPRECATED;'`"; # Avoid depreciation messages from phpDocumentor/Reflection/issues/529 when using PHP 8.2 or higher
2324
TMP_DXP_DIR=/tmp/ibexa-dxp-phpdoc; # Absolute path of the temporary directory in which Ibexa DXP will be installed and the PHP API Reference built
@@ -206,6 +207,8 @@ echo 'Dump REST OpenAPI schema… ';
206207
$PHP_BINARY bin/console ibexa:openapi --yaml \
207208
| sed "s@info:@info:\n x-logo:\n url: 'https://doc.ibexa.co/en/latest/images/ibexa-dxp-logo.png'@" \
208209
> openapi.yaml;
210+
echo 'Fix REST OpenAPI schema… ';
211+
$PHP_BINARY $OPENAPI_FIX;
209212
echo 'Build REST Reference… ';
210213
redocly build-docs openapi.yaml --output $REST_API_OUTPUT_FILE --config $REDOCLY_CONFIG --template $REDOCLY_TEMPLATE;
211214

tools/api_refs/openapi.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
$openApi = yaml_parse_file('openapi.yaml');
4+
5+
foreach ($openApi['paths'] as $path => &$pathMethods) {
6+
foreach ($pathMethods as $method => &$methodDefinition) {
7+
if (array_key_exists('requestBody', $methodDefinition) && array_key_exists('content', $methodDefinition['requestBody'])) {
8+
//foreach ($methodDefinition['requestBody']['content'] as $contentType => &$contentDefinition) {}
9+
ksort($methodDefinition['requestBody']['content']);
10+
}/* */elseif (array_key_exists('requestBody', $methodDefinition)) {
11+
echo "$method $path\n";
12+
}/**/
13+
foreach ($methodDefinition['responses'] as $responseCode => &$responseDefinition) {
14+
if (array_key_exists('content', $responseDefinition)) {
15+
//foreach ($responseDefinition['content'] as $contentType => &$contentDefinition) {}
16+
ksort($responseDefinition['content']);
17+
}/* * /else {
18+
echo "$method $path: $responseCode\n";
19+
}/**/
20+
}
21+
}
22+
}
23+
24+
yaml_emit_file('openapi.fixed.yaml', $openApi);
25+
yaml_emit_file('openapi.yaml', $openApi);

0 commit comments

Comments
 (0)