2.4.1 • Published 10 months ago

@routup/swagger v2.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@routup/swagger

npm version main codecov Known Vulnerabilities Conventional Commits

This is a plugin for reading and parsing the request payload.

Table of Contents

Installation

npm install @routup/swagger --save

Documentation

To read the docs, visit https://routup.net

Usage

Generator

Generate a swagger document for the API endpoints.

V2

import { generate, Version } from '@routup/swager';
import process from 'node:process';

await generate({
    version: Version.V2,
    options: {
        metadata: {
            preset: '@routup/swagger-preset',
            entryPoint: {
                cwd: process.cwd(),
                pattern: '**/*.ts',
            },
        },
        output: true,
        outputDirectory: 'writable',
        servers: ['http://localhost:3000/'],
    },
});

The function call will save the file under the location: ./writable/swagger.json.

V3

import { generate, Version } from '@routup/swager';
import process from 'node:process';

await generate({
    version: Version.V3,
    options: {
        metadata: {
            preset: '@routup/swagger-preset',
            entryPoint: {
                cwd: process.cwd(),
                pattern: '**/*.ts',
            },
        },
        output: true,
        outputDirectory: 'writable',
        servers: ['http://localhost:3000/'],
    },
});

The function call will save the file under the location: ./writable/swagger.json.

UI

Serve generated docs from (file- / web-) URL or based on a JSON file with swagger-ui.

import { createServer } from 'node:http';
import {
    createNodeDispatcher,
    Router
} from 'routup';
import { swaggerUI } from '@routup/swagger';

const router = new Router();

router.use('/docs', swaggerUI('test/data/swagger.json'));

const server = createServer(createNodeDispatcher(router));
server.listen(3000);

Now open the browser and visit:

http://localhost:3000/docs/

License

Made with 💚

Published under MIT License.

2.4.1

10 months ago

2.4.0

1 year ago

2.3.6

1 year ago

2.3.5

1 year ago

2.3.4

1 year ago

2.3.2

2 years ago

2.3.3

2 years ago

2.3.1

2 years ago

1.0.2

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

2.3.0

2 years ago

2.0.0-alpha.3

2 years ago

2.2.0

2 years ago

2.0.0-alpha.0

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.0-alpha.0

2 years ago

0.13.5

2 years ago

0.13.0

2 years ago

0.13.1

2 years ago

0.13.2

2 years ago

0.13.3

2 years ago

0.13.4

2 years ago

0.12.0

2 years ago

0.12.1

2 years ago

0.11.0

2 years ago

0.11.1

2 years ago

0.10.0

2 years ago

0.3.0

3 years ago

0.9.0

2 years ago

0.2.7

3 years ago

0.8.0

2 years ago

0.2.6

3 years ago

0.5.0

3 years ago

0.4.1

3 years ago

0.3.2

3 years ago

0.2.3

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.7.0

3 years ago

0.2.5

3 years ago

0.6.0

3 years ago

0.2.4

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago