diff --git a/lib/Service/EndpointService.php b/lib/Service/EndpointService.php index e93b1db7..45fee819 100644 --- a/lib/Service/EndpointService.php +++ b/lib/Service/EndpointService.php @@ -292,12 +292,6 @@ private function replaceInternalReferences( $object = $mapper->find($serializedObject['id']); } - $uses = $object->getRelations(); - - if(isset($serializedObject) === true && !empty($serializedObject['@self']['relations'])) { - $uses = $serializedObject['@self']['relations']; - } - $useUrls = []; $uuidToUrlMap = []; @@ -312,12 +306,12 @@ private function replaceInternalReferences( $validUriProperties[] = $propertyName; } - if (isset($property['format']) === true && $property['format'] === 'uri') { + if (isset($property['format']) === true && $property['format'] === 'uri' && (isset($property['$ref']) === true|| isset($property['items']['$ref']) === true)) { $validUriProperties[] = $propertyName; } } - foreach ($uses as $key => $use) { + foreach ($object->jsonSerialize() as $key => $use) { $baseKey = explode('.', $key, 2)[0]; // Skip if the key (or its base form) is not in the valid URI properties if (in_array(needle: $baseKey, haystack: $validUriProperties) === false) { @@ -334,7 +328,6 @@ private function replaceInternalReferences( $explodedUrl = explode(separator: '/', string: $use); $useId = end($explodedUrl); } else { - unset($uses[$key]); continue; } @@ -448,6 +441,10 @@ private function rewriteExternalReferences(array $parameters, \OCA\OpenRegister\ continue; } + // Get the first endpoint found. + /** + * @var Endpoint $endpoint + */ $endpoint = array_shift($endpoints); $pathArray = $this->getPathParameters(endpointArray: $endpoint->getEndpointArray(), path: $parsedPath);