Skip to content

Commit fa49942

Browse files
authored
Merge pull request #7251 from LibreSign/backport/7234/stable33
[stable33] chore: migration to vue3
2 parents 17f299f + 42b0638 commit fa49942

278 files changed

Lines changed: 17015 additions & 13755 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/openapi.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,10 @@ jobs:
8787

8888
- name: Check openapi*.json and typescript changes
8989
run: |
90-
bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please run \"composer run openapi\" and commit the openapi*.json files and (if applicable) src/types/openapi/openapi*.ts, see the section \"Show changes on failure\" for details' && exit 1)"
90+
git diff --quiet -- openapi*.json src/types/openapi/openapi*.ts || (echo 'Please run "composer run openapi" and commit the openapi*.json files and (if applicable) src/types/openapi/openapi*.ts, see the section "Show changes on failure" for details' && exit 1)
9191
9292
- name: Show changes on failure
9393
if: failure()
9494
run: |
95-
git status
96-
git --no-pager diff
95+
git --no-pager diff -- openapi*.json src/types/openapi/openapi*.ts
9796
exit 1 # make it red to grab attention
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
--- a/src/AbstractRequester.php
2+
+++ b/src/AbstractRequester.php
3+
@@ -126,7 +126,7 @@ abstract class AbstractRequester
4+
/**
5+
* @param array|null $query
6+
* @return $this
7+
*/
8+
- public function withQuery(array $query = null): self
9+
+ public function withQuery(?array $query = null): self
10+
{
11+
$uri = $this->psr7Request->getUri();
12+
13+
--- a/src/ApiTestCase.php
14+
+++ b/src/ApiTestCase.php
15+
@@ -80,8 +80,8 @@ abstract class ApiTestCase extends TestCase
16+
string $method,
17+
string $path,
18+
int $statusExpected = 200,
19+
string|array|null $query = null,
20+
- array|string $requestBody = null,
21+
+ array|string|null $requestBody = null,
22+
array $requestHeader = []
23+
): ResponseInterface {
24+
$this->checkSchema();
25+
@@ -137,8 +137,8 @@ abstract class ApiTestCase extends TestCase
26+
27+
return $body;
28+
}
29+
30+
- public function assertRequestException(AbstractRequester $request, string $exceptionClass, string $exceptionMessage = null, bool $matchQueryParams = true): Throwable
31+
+ public function assertRequestException(AbstractRequester $request, string $exceptionClass, ?string $exceptionMessage = null, bool $matchQueryParams = true): Throwable
32+
{
33+
try {
34+
$this->assertRequest($request, $matchQueryParams);
35+
--- a/src/Exception/BaseException.php
36+
+++ b/src/Exception/BaseException.php
37+
@@ -9,7 +9,7 @@ class BaseException extends Exception
38+
{
39+
protected mixed $body;
40+
41+
- public function __construct($message = "", $body = [], $code = 0, Throwable $previous = null)
42+
+ public function __construct($message = "", $body = [], $code = 0, ?Throwable $previous = null)
43+
{
44+
$this->body = $body;
45+
if (!empty($body)) {
46+
47+
--- a/src/Base/Body.php
48+
+++ b/src/Base/Body.php
49+
@@ -328,6 +328,50 @@
50+
return true;
51+
}
52+
53+
+ protected function mergeAllOfSchemas(array $schemas): array
54+
+ {
55+
+ $mergedSchema = [];
56+
+
57+
+ foreach ($schemas as $schema) {
58+
+ if (isset($schema['$ref'])) {
59+
+ $schema = $this->schema->getDefinition($schema['$ref']);
60+
+ }
61+
+
62+
+ $mergedSchema = $this->mergeSchemaDefinitions($mergedSchema, $schema);
63+
+ }
64+
+
65+
+ return $mergedSchema;
66+
+ }
67+
+
68+
+ protected function mergeSchemaDefinitions(array $base, array $append): array
69+
+ {
70+
+ foreach ($append as $key => $value) {
71+
+ if (!array_key_exists($key, $base)) {
72+
+ $base[$key] = $value;
73+
+ continue;
74+
+ }
75+
+
76+
+ if (($key === self::SWAGGER_REQUIRED || $key === 'enum') && is_array($base[$key]) && is_array($value)) {
77+
+ $base[$key] = array_values(array_unique(array_merge($base[$key], $value), SORT_REGULAR));
78+
+ continue;
79+
+ }
80+
+
81+
+ if (is_array($base[$key]) && is_array($value) && $this->isAssociativeArray($base[$key]) && $this->isAssociativeArray($value)) {
82+
+ $base[$key] = $this->mergeSchemaDefinitions($base[$key], $value);
83+
+ continue;
84+
+ }
85+
+
86+
+ $base[$key] = $value;
87+
+ }
88+
+
89+
+ return $base;
90+
+ }
91+
+
92+
+ protected function isAssociativeArray(array $value): bool
93+
+ {
94+
+ return array_keys($value) !== range(0, count($value) - 1);
95+
+ }
96+
+
97+
/**
98+
* @param string $name
99+
* @param array $schemaArray
100+
@@ -362,27 +406,21 @@
101+
}
102+
103+
if (isset($schemaArray['allOf'])) {
104+
- $allOfSchemas = $schemaArray['allOf'];
105+
- foreach ($allOfSchemas as &$schema) {
106+
- if (isset($schema['$ref'])) {
107+
- $schema = $this->schema->getDefinition($schema['$ref']);
108+
- }
109+
- }
110+
- unset($schema);
111+
- $mergedSchema = array_merge_recursive(...$allOfSchemas);
112+
- return $this->matchSchema($name, $mergedSchema, $body);
113+
+ return $this->matchSchema($name, $this->mergeAllOfSchemas($schemaArray['allOf']), $body);
114+
}
115+
116+
- if (isset($schemaArray['oneOf'])) {
117+
+ if (isset($schemaArray['oneOf']) || isset($schemaArray['anyOf'])) {
118+
+ $schemas = $schemaArray['oneOf'] ?? $schemaArray['anyOf'];
119+
$matched = false;
120+
$catchException = null;
121+
- foreach ($schemaArray['oneOf'] as $schema) {
122+
+ foreach ($schemas as $schema) {
123+
try {
124+
$matched = $matched || $this->matchSchema($name, $schema, $body);
125+
} catch (NotMatchedException $exception) {
126+
$catchException = $exception;
127+
}
128+
}
129+
+
130+
if ($catchException !== null && $matched === false) {
131+
throw $catchException;
132+
}

REUSE.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ path = [
5858
"tests/integration/features/**/*.feature",
5959
"tests/psalm-baseline.xml",
6060
"tsconfig.json",
61+
"vendor-bin/**/patches.json",
6162
"vendor-bin/**/composer.json",
6263
"vendor-bin/**/composer.lock"
6364
]

0 commit comments

Comments
 (0)