class ReDoc in ReDoc for OpenAPI UI 8
Implements openapi_ui plugin for the swagger-ui library.
Plugin annotation
@OpenApiUi(
id = "redoc",
label = @Translation("ReDoc"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\openapi_ui\Plugin\openapi_ui\OpenApiUi implements OpenApiUiInterface
- class \Drupal\openapi_ui_redoc\Plugin\openapi_ui\OpenApiUi\ReDoc
- class \Drupal\openapi_ui\Plugin\openapi_ui\OpenApiUi implements OpenApiUiInterface
Expanded class hierarchy of ReDoc
File
- src/
Plugin/ openapi_ui/ OpenApiUi/ ReDoc.php, line 18
Namespace
Drupal\openapi_ui_redoc\Plugin\openapi_ui\OpenApiUiView source
class ReDoc extends OpenApiUi {
/**
* {@inheritdoc}
*/
public function build(array $render_element) {
$schema = $render_element['#openapi_schema'];
$build = [
'#type' => 'html_tag',
'#tag' => 'redoc',
'#attributes' => [
'id' => 'redoc-ui',
'no-auto-auth' => TRUE,
],
'#attached' => [
'library' => [
'openapi_ui_redoc/redoc',
],
],
];
if ($schema instanceof Url) {
$build['#attributes']['spec-url'] = $schema
->toString();
}
else {
$build['#attributes']['spec'] = Json::encode($schema);
// We need to shim the redoc library to load from the spec attribute.
$build['#attached']['library'][] = 'openapi_ui_redoc/redoc_attr';
}
return $build;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |
ReDoc:: |
public | function |
Render the tree for an openapi doc library. Overrides OpenApiUi:: |