New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mtr-apidoc

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mtr-apidoc

Meteor Platform API Documentation Formatting Library w/ Swagger

  • 1.0.7
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

API Documentation Formatting Library

Meteor Platform API Documentation Formatting Library w/ Swagger.

Installation

npm i git+ssh://git@repository.meteor.asia/mtr-platform/libs/apidoc#v1.0.7

Penggunaan

Buat file doc.js di dalam root folder atau index.js di dalam folder doc dengan format seperti berikut:

const description = 'API description';
const schemes = ['https', 'http']; // Options are https & http
const tags = [
  {
    name: 'Tag Name',
    description: 'Tag description.',
  },
];
const paths = {
  'path-name': {
    get: { // Method type, options are get, post, put & delete
      tags: ['Tag Name'],
      description: 'Endpoint description',
      auth: true, // If set true then will add an Authorization field on headers
      dataTable: [ // Will automatically generate basic query parameters
        { name: 'id', searchable: true },
        { name: 'name', searchable: true },
        { name: 'phone', searchable: true },
        { name: 'email', searchable: true },
      ],
      parameters: [ // Can be used to add additional query parameters
        {
          name: 'status',
          in: 'query',
          type: 'string',
          default: '',
          description: 'Index only specific status',
        },
      ],
      results: {
        200: {
          total: 1,
          total_filtered: 1,
          total_displayed: 1,
          total_page: 1,
          page: 1,
          data: [
            {
              id: '3ec79570-75f7-11e9-8901-3778b1fc30d4',
              name: 'John Doe',
              phone: '88801426139',
              email: 'john.doe@yayasan.id',
            },
          ],
        },
      },
    },
  },
  '/path-name/{id}': {
    post: {
      tags: ['Tag Name'],
      description: 'Endpoint description',
      auth: true,
      parameters: [
        {
          name: 'id',
          in: 'path',       // Options are path, query, header & formData
                            // If value is 'path' then the parameter's name must exist in the endpoint,
                            // in this example is 'id' on '/path-name/{id}'
          type: 'string',   // Options are string, number, integer & boolean
          required: true,   // If not set then the field parameter is optional
          default: '2017ace8-3785-11ea-b295-84ef18e0817f',
          description: 'Parameter description',
          validation: ['Not empty', 'ID is in pathIDs'], // Validation set on API, free test
        },
      ],
      results: {
        200: {
          id: '23b97ce8-1944-11e9-9620-d5ae65e64e7e', // String
          int: 1579586389,                            // Number
          arr: ['OK', 'YES'],                         // Array
          obj: { ok: 1, no: 0 },                      // Object
          is: true,                                   // Boolean
        },
        403: {
          auth_token: {
            value: 'jwt expired',
            msg: 'TokenExpiredError',
          },
        },
      },
      // Possible response code, options are 200, 400, 401, 403, 500
      // Response code value can be in String, Number, Object or Boolean
    },
  },
};

module.exports = {
  description, schemes, tags, paths,
};

Deklarasikan module library di dalam file xxx-gateway/api.js.

const jsonDoc = require('mtr-apidoc');

module.exports = (router) => {
  router.get('/', jsonDoc);
};

FAQs

Package last updated on 10 Sep 2022

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc