Socket
Book a DemoInstallSign in
Socket

@smartive/giuseppe-swagger-plugin

Package Overview
Dependencies
Maintainers
7
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smartive/giuseppe-swagger-plugin

Swagger documentation generator

2.0.0
latest
Source
npmnpm
Version published
Weekly downloads
526
526.19%
Maintainers
7
Weekly downloads
 
Created
Source

giuseppe-swagger-plugin

This is a plugin for giuseppe.

A bunch of badges

Build Status npm

Installation

To install this package, simply run

NPM

How to use

Here is a brief example of how to add the plugin to giuseppe:

import { Giuseppe } from 'giuseppe';
import { GiuseppeSwaggerPlugin } from 'giuseppe-swagger-plugin';

const app = new Giuseppe();
app.registerPlugin(new GiuseppeSwaggerPlugin());
app.start();

This is how to enrich a Giuseppe controller with swagger annotations:

@Controller()
class Ctrl2 {
    @SwaggerRoute({
        description: 'A route',
        responses: {
            200: {
                description: 'Response description',
                type: Model,
            },
        },
    })
    @Get('route')
    getRoute(
        @Query('a')
        a: string,

        @SwaggerParam({
            default: 10,
            description: 'Parameter b',
        })
        @Query('b')
        b: number,

        @SwaggerParam({
            type: Model
        })
        @Query('c')
        c: Model,

        @SwaggerParam({
            type: Number
        })
        @Query('d')
        d: number[],

        @SwaggerParam({
            type: Model
        })
        @Query('e')
        e: Model[],

        @Header('f')
        f: string,
    ): Model {
        return new Model();
    }
}

This is how to enrich a model with swagger annotations:

@SwaggerObject({
    description: 'A model',
})
class Model {
    @SwaggerField({
        required: true,
    })
    a: string;

    @SwaggerField()
    b: number;

    @SwaggerField({
        type: Other,
    })
    c: Model;

    @SwaggerField({
        type: Number
    })
    d: number[];

    @SwaggerField({
        type: Other
    })
    e: Other[];
}

This is how to generate the swagger json:

import { SwaggerDocs } from 'giuseppe-swagger-plugin';

@Controller()
class Ctrl {
    @SwaggerDocs('swagger', {
        info: {
            description: 'A test swagger route.',
            title: 'Swagger',
            version: '1.0.0',
        },
    })
    public getSwagger(): void { }
}

The schema can be forced to adhere to swagger 2.

Changelog

The changelog is generated by semantic release and is located under the release section.

Licence

This software is licenced under the MIT licence.

Keywords

giuseppe

FAQs

Package last updated on 20 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.