Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 8 additions & 9 deletions generate-spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -1014,9 +1014,15 @@
}
}

$usedRefs = array_merge(...$usedRefs);

$scopedSchemas = [];
foreach (['Capabilities', 'PublicCapabilities'] as $class) {
if (isset($schemas[$class])) {
$scopedSchemas[$class] = $schemas[$class];
$usedRefs[] = Helpers::collectUsedRefs($schemas[$class]);
}
}

$usedRefs = array_merge(...$usedRefs);
while ($usedRef = array_shift($usedRefs)) {
if (!str_starts_with((string)$usedRef, '#/components/schemas/')) {
continue;
Expand All @@ -1039,13 +1045,6 @@
$usedSchemas[] = $schemaName;
}

if (isset($schemas['Capabilities'])) {
$scopedSchemas['Capabilities'] = $schemas['Capabilities'];
}
if (isset($schemas['PublicCapabilities'])) {
$scopedSchemas['PublicCapabilities'] = $schemas['PublicCapabilities'];
}

if ($scopedSchemas === []) {
$scopedSchemas = new stdClass();
} else {
Expand Down
5 changes: 4 additions & 1 deletion tests/lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@

use OCP\Capabilities\ICapability;

/**
* @psalm-import-type NotificationsSchemaOnlyInCapabilities from ResponseDefinitions
*/
class Capabilities implements ICapability {
/**
* @return array{test: array{a: int}}
* @return array{test: array{a: int, b: NotificationsSchemaOnlyInCapabilities}}
*/
public function getCapabilities(): array {
return [];
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
* ref2: null|NotificationsPushDevice,
* ref3: string|null|NotificationsPushDevice,
* }
*
* @psalm-type NotificationsSchemaOnlyInCapabilities = array{
* key: string,
* }
*/
class ResponseDefinitions {
}
17 changes: 16 additions & 1 deletion tests/openapi-administration.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@
"test": {
"type": "object",
"required": [
"a"
"a",
"b"
],
"properties": {
"a": {
"type": "integer",
"format": "int64"
},
"b": {
"$ref": "#/components/schemas/SchemaOnlyInCapabilities"
}
}
}
Expand Down Expand Up @@ -115,6 +119,17 @@
"type": "string"
}
}
},
"SchemaOnlyInCapabilities": {
"type": "object",
"required": [
"key"
],
"properties": {
"key": {
"type": "string"
}
}
}
}
},
Expand Down
17 changes: 16 additions & 1 deletion tests/openapi-ex_app.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@
"test": {
"type": "object",
"required": [
"a"
"a",
"b"
],
"properties": {
"a": {
"type": "integer",
"format": "int64"
},
"b": {
"$ref": "#/components/schemas/SchemaOnlyInCapabilities"
}
}
}
Expand Down Expand Up @@ -82,6 +86,17 @@
}
}
}
},
"SchemaOnlyInCapabilities": {
"type": "object",
"required": [
"key"
],
"properties": {
"key": {
"type": "string"
}
}
}
}
},
Expand Down
17 changes: 16 additions & 1 deletion tests/openapi-federation.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@
"test": {
"type": "object",
"required": [
"a"
"a",
"b"
],
"properties": {
"a": {
"type": "integer",
"format": "int64"
},
"b": {
"$ref": "#/components/schemas/SchemaOnlyInCapabilities"
}
}
}
Expand Down Expand Up @@ -82,6 +86,17 @@
}
}
}
},
"SchemaOnlyInCapabilities": {
"type": "object",
"required": [
"key"
],
"properties": {
"key": {
"type": "string"
}
}
}
}
},
Expand Down
17 changes: 16 additions & 1 deletion tests/openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@
"test": {
"type": "object",
"required": [
"a"
"a",
"b"
],
"properties": {
"a": {
"type": "integer",
"format": "int64"
},
"b": {
"$ref": "#/components/schemas/SchemaOnlyInCapabilities"
}
}
}
Expand Down Expand Up @@ -307,6 +311,17 @@
]
}
}
},
"SchemaOnlyInCapabilities": {
"type": "object",
"required": [
"key"
],
"properties": {
"key": {
"type": "string"
}
}
}
}
},
Expand Down
17 changes: 16 additions & 1 deletion tests/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@
"test": {
"type": "object",
"required": [
"a"
"a",
"b"
],
"properties": {
"a": {
"type": "integer",
"format": "int64"
},
"b": {
"$ref": "#/components/schemas/SchemaOnlyInCapabilities"
}
}
}
Expand Down Expand Up @@ -307,6 +311,17 @@
]
}
}
},
"SchemaOnlyInCapabilities": {
"type": "object",
"required": [
"key"
],
"properties": {
"key": {
"type": "string"
}
}
}
}
},
Expand Down