ByteCrumb / Umbraco.Community.DeliveryApiExtensions

Umbraco Delivery API extensions⚡
Mozilla Public License 2.0
22 stars 2 forks source link
delivery-api umbraco
Delivery Api Extensions logo

Umbraco Delivery Api Extensions

Downloads NuGet GitHub license

Extensions for the Umbraco Delivery API.

Features ✨

Backoffice preview

Preview the Delivery API responses from the backoffice content/media nodes.

Preview

Typed swagger

Adds types to the Umbraco swagger based on your document and data types (just like Models Builder), so that you can more seamlessly generate typed clients.

Example of a Node console app using the types/functions generated by a typescript restful client generator using the typed swagger.

import { getContentItemByPath } from './api/umbraco-api';

const content = (await getContentItemByPath('/')).data;

// Content can be of any document type here

if (content.contentType === 'home') {
    // By checking the contentType, Typescript knows this is a Home page
    // and properly validates the properties and their types
    console.log(`Name: ${content.name}`);
    console.log(`Title: ${content.properties?.title}`);
    console.log(`Text: ${content.properties?.text?.markup}`);
}

Typed Swagger

Installation 🧑‍💻

Add the package to an existing Umbraco website (v12.2+) from nuget:

dotnet add package Umbraco.Community.DeliveryApiExtensions

Configuration (appsettings.json)

{
  "DeliveryApiExtensions": {
    "Preview": {
      "Enabled": true,
      "Media": {
        "Enabled": true
      },
      "AllowedUserGroupAliases": [], // All allowed by default
      "ContentAppWeight": -50
    },
    "TypedSwagger": {
      "Enabled": true,
      "Mode": "Auto"
    }
  }
}

Typed swagger modes

Contributing 🙌

Contributions to this package are most welcome! Please read the Contributing Guidelines.