Skip to content

Drupal Content Entity schema generator for Druxt with support for View and Form displays.

DruxtSchema

View source on GitHub

DruxtSchema

The DruxtSchema class.

Builds Druxt Schema objects using Drupal JSON:API Entity Form and View Display mode data.

Kind: global class


new DruxtSchema(baseUrl, [options])

DruxtSchema constructor.

  • Validates module options.
  • Sets up options.
  • Sets up a DruxtClient instance.
ParamTypeDefaultDescription
baseUrlstringThe Drupal base URL.
[options]objectDruxt Router options.
[options.axios]objectAxios instance settings.
[options.endpoint]string"jsonapi"The JSON:API endpoint.

Example

const schema = new DruxtSchema('https://example.com', {})

.druxt : DruxtClient

Instance of the Druxt Client.

Kind: instance property of DruxtSchema
See: DruxtClient


.get() ⇒ object

Gets all available schemas for Entity Views and Form modes.

Kind: instance method of DruxtSchema
Returns: object - The JSON:API Resource index and processed schemas.

Example

const { schemas } = await schema.get()

.getSchema(config, [options]) ⇒ Schema

Gets a matching schema as per the provided configuration.

Kind: instance method of DruxtSchema
Returns: Schema - The generated Schema.
See: Schema

ParamTypeDescription
configSchemaConfigurationThe Schema configuration object.
config.entityTypestringThe Drupal Entity type.
config.bundlestringThe Entity bundle.
[options]object(Optional) Additional Schema generation options, e.g. preloaded JSON:API resource data.

Example

const config = {
  entityType: 'node',
  bundle: 'page'
}
const schema = await schema.getSchema(config)

SchemaConfiguration : object

Druxt Schema configuration object.

Kind: global typedef
See: SchemaConfiguration