Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

digitalroute/bagger

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

160 Commits
160 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎒 Bagger

npm (scoped) npm Build license

A joi-compatible tool for building Swagger (Open API 3) documents. It enables developers to use the same joi schemas for validation and documentation, ensuring that API documentation never becomes stale.

Features

  • 🔨 Builder pattern: Dead simple api to create complex Swagger documents.
  • ✨ joi compatibility: Enables developers to use the same schemas for validation and documentation. Embedded Joi is now exposed by default.
  • 🔎 Intellisense: Really nice intellisense suggestions, and TypeScript definitions.
  • 🔒 Type safety: Bagger always produces 100% valid Swagger documents. If you use TypeScript the compiler will enforce correctness in most cases, and otherwise Bagger will validate during compilation.

Usage

// Import as a classic javascript
const { bagger } = require('@digitalroute/bagger');

// OR

// Import the default instances ESModule / Typescript
import { bagger } from '@digitalroute/bagger';

Example

import { bagger, joi } from '@digitalroute/bagger';

bagger.configure({
  title: 'Bagger API',
  version: 'v1',
  description: 'Provides resources for building swagger documents'
});

bagger
  .addRequest('/bags', 'get')
  .addTag('bags')
  .addTag('build')
  .addResponse(
    bagger
      .response(200)
      .description('Successfully fetched all bags')
      .content(
        'application/json',
        joi
          .array()
          .items(joi.string())
          .example([['handbag', 'backpack', 'purse']])
      )
  );

const swaggerDefinition = bagger.compile();

Documentation

About

🎒A joi-compatible tool for building swagger definitions

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.