SkillAgentSearch skills...

Docs

No description available

Install / Use

/learn @appliedblockchain/Docs
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<h1 align="center"> API Documentation Creator </h1>

Installation

  1. Add as a package dependency
$ npm install ab-docs --save
  1. Require it in your code
const { withDocs } = require('ab-docs')
  1. Create a swagger specification to pass into the function. A base specification should be provided with an info object (containing at least the title and version strings) and any other global descriptions.
module.exports = {
  baseSpec: {
    info: {
      title: name,
      description: 'API description',
      version
    },
    basePath: '/',
    tags: [
      {
        name: 'tag name',
        description: 'tag description'
      },
    ]
  },
  specOptions: {
    defaultResponses: {}
  }
}
  1. Use withDocs function like so:
const { withDocs } = require('ab-docs')

withDocs(router, routes, baseSpec, specOptions)

Accessing API Documentation

Endpoint: /docs

Example endpoint structure:

{
    method: 'get',
    path: '/endpoint',
    validate: {
      type: 'json',
      body: Joi.object({
        property: 'value'
      })
      output: {
        200: {
          body: Joi.object({
            property: 'value'
          }).description('...')
        },
        404: {
          body: Joi.object({
            errors: Joi.array().items(
              {
                property: 'value'
              }
            )
          }).description('...')
        }
      }
    },
    meta: {
      swagger: {
        summary: '...',
        description: '...',
        tags: [ 'refer to existing tags in config file' ]
      }
    },
    handler: ...
  }
View on GitHub
GitHub Stars0
CategoryDevelopment
Updated1y ago
Forks0

Languages

JavaScript

Security Score

50/100

Audited on Jun 14, 2024

No findings