0.0.3 • Published 2 years ago

@trapi/decorator v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@trapi/decorator 📚

main codecov Known Vulnerabilities npm version

Inspect the CHANGELOG.md in the repository for breaking changes.

Table of Contents

Installation

npm install --save @trapi/decorator

Configuration

declare type Config = {
    /**
     * Use a pre-defined third party configuration in full scope or
     * only use a partial amount of defined type representations.
     *
     * Default: []
     */
    library?: LibraryConfig;
    /**
     * Use all internal defined representations or only use a subset.
     *
     * Default: true
     */
    internal?: MapperIDs;
    /**
     * Set up self defined aka. custom representations.
     */
    custom?: Partial<MapperIDRepresentation>;
}

Usage

import { Config, Mapper, NodeDecorator } from '@trapi/decorator';

const mapper = new Mapper({
    internal: true
});

const decorators : NodeDecorator[] = [
    { text: 'SwaggerTags', arguments: [['auth', 'admin']], typeArguments: [] },
    { text: 'SwaggerTags', arguments: [['auth'], ['admin']], typeArguments: [] },
    { text: 'SwaggerTags', arguments: [], typeArguments: [] },
];

let match = mapper.match('SWAGGER_TAGS', decorators);
let value = match.getPropertyValue('DEFAULT');
console.log(value);
// ['auth', 'admin']

match = mapper.match('RESPONSE_EXAMPLE', decorators);
console.log(match);
// undefined

License

Made with 💚

Published under MIT License.

0.0.3

2 years ago

0.0.2

2 years ago