---
lang: en
title: 'API docs: metadata.decoratorfactory._createdecorator'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/metadata
permalink: /doc/en/lb4/apidocs.metadata.decoratorfactory._createdecorator.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/metadata](./metadata.md) &gt; [DecoratorFactory](./metadata.decoratorfactory.md) &gt; [\_createDecorator](./metadata.decoratorfactory._createdecorator.md)

## DecoratorFactory.\_createDecorator() method

Create a decorator function

**Signature:**

```typescript
protected static _createDecorator<S, MT extends S | MetadataMap<S> | MetadataMap<S[]>, DT extends DecoratorType>(key: MetadataKey<S, DT>, spec: S, options?: DecoratorOptions): DT;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

key


</td><td>

[MetadataKey](./metadata.metadatakey.md)<!-- -->&lt;S, DT&gt;


</td><td>

Metadata key


</td></tr>
<tr><td>

spec


</td><td>

S


</td><td>

Metadata object from the decorator function


</td></tr>
<tr><td>

options


</td><td>

[DecoratorOptions](./metadata.decoratoroptions.md)


</td><td>

_(Optional)_ Options for the decorator


</td></tr>
</tbody></table>
**Returns:**

DT


