private function JsonApiGenerator::fixReferences in OpenAPI for JSON:API 8.2
Same name and namespace in other branches
- 3.x src/Plugin/openapi/OpenApiGenerator/JsonApiGenerator.php \Drupal\openapi_jsonapi\Plugin\openapi\OpenApiGenerator\JsonApiGenerator::fixReferences()
When embedding JSON Schemas you need to make sure to fix any possible $ref
Parameters
array $schema: The schema to fix.
$prefix: The prefix where this schema is embedded.
Return value
array
1 call to JsonApiGenerator::fixReferences()
- JsonApiGenerator::getDefinitions in src/
Plugin/ openapi/ OpenApiGenerator/ JsonApiGenerator.php
File
- src/
Plugin/ openapi/ OpenApiGenerator/ JsonApiGenerator.php, line 745
Class
- JsonApiGenerator
- Defines an OpenApi Schema Generator for the JsonApi module.
Namespace
Drupal\openapi_jsonapi\Plugin\openapi\OpenApiGeneratorCode
private function fixReferences(array $schema, $prefix) {
foreach ($schema as $name => $item) {
if (is_array($item)) {
$schema[$name] = $this
->fixReferences($item, $prefix);
}
if ($name === '$ref' && is_string($item) && strpos($item, '#/') !== FALSE) {
$schema[$name] = preg_replace('/#\\//', $prefix . '/', $item);
}
}
return $schema;
}