class SwaggerUi in Swagger UI for OpenAPI UI 8
Implements openapi_ui plugin for the swagger-ui library.
Plugin annotation
@OpenApiUi(
id = "swagger",
label = @Translation("Swagger UI"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\openapi_ui\Plugin\openapi_ui\OpenApiUi implements OpenApiUiInterface
- class \Drupal\openapi_ui_swagger\Plugin\openapi_ui\OpenApiUi\SwaggerUi
- class \Drupal\openapi_ui\Plugin\openapi_ui\OpenApiUi implements OpenApiUiInterface
Expanded class hierarchy of SwaggerUi
File
- src/
Plugin/ openapi_ui/ OpenApiUi/ SwaggerUi.php, line 18
Namespace
Drupal\openapi_ui_swagger\Plugin\openapi_ui\OpenApiUiView source
class SwaggerUi extends OpenApiUi {
/**
* {@inheritdoc}
*/
public function build(array $render_element) {
$schema = $render_element['#openapi_schema'];
$build = [
'#type' => 'html_tag',
'#tag' => 'div',
'#attributes' => [
'id' => 'swagger-ui',
'class' => [
'swagger-ui-wrap',
],
],
'#attached' => [
'library' => [
'openapi_ui_swagger/swagger_ui_integration',
],
],
];
if ($schema instanceof Url) {
$build['#attributes']['data-openapi-ui-url'] = $schema
->toString();
}
else {
$build['#attributes']['data-openapi-ui-spec'] = Json::encode($schema);
}
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 |
SwaggerUi:: |
public | function |
Render the tree for an openapi doc library. Overrides OpenApiUi:: |