Code Monkey home page Code Monkey logo

express-mongoose-docs's Introduction

express-mongoose-docs

Build Status Coverage Status

This module will take away the pain of writing API and Data Model documentation for your Express & Mongoose based REST API. It auto-generates API documentation from the code on runtime so the documentation always stays up to date.

Installation

  • Step 1 : Install
npm install express-mongoose-docs
  • Step 2 : Configure

Add these lines to your app.js file

var docs = require("express-mongoose-docs");

Make sure the following line comes after all express middleware such as app.use(express.bodyParser());

docs(app, mongoose); // 2nd param is optional

That's it. The Docs web page should be accessible at Your-Base-URL/apiDocs

Example: http://localhost:5000/apiDocs

Screenshots

routes

data-model

express-mongoose-docs's People

Contributors

muslimmunir avatar nabeel-ahmad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

express-mongoose-docs's Issues

Conditional requirements are listed as required

Mongoose allow functions that return true or false as value for the required key:

    thisIsAField: {
      type: String,
      required: function(value) {
        return whatever ? true : false
      }
    },

However, express-mongoose-docs lists this as a required field. I propose that field requirements that return a function are listed as "conditional" instead of "true".

Duplicate models

In situations where two schemas reuse another schema, the generated documentation shows the reused schema multiple times rather than showing only one instance of that reused schema.

For example, ContextSchema will show twice in the documentation in two different places. (in coffeescript below)

Schema = require('mongoose').Schema
ContextSchema = new Schema(
    {
        name: String,
        sku: { type: String, index: true }
    },
    { strict: false, _id: false }
)
RuleContextSchema = new Schema(
  {
    context: [ContextSchema]
  }
  {strict: false}
)
FactContextSchema = new Schema(
    {
        context: [ContextSchema]
    },
    { strict: false }
)

Add ability to change the URL

While this module is very useful, if would be even more useful if it was possible to change the URL to something different than "/apiDocs"

Scroll on the nav sidebar

Scroll on the nav sidebar is necessary for al long list of models and routes.

I override the nav style with
<ul class="nav" style="position:relative">

Arrays of a type defined as an object show as undefined.

if you define a field using the object notation for mongoose schemas, defining the extra options for that field, the documentation doesn't generate correctly.

Example:

ContextSchema = new Schema(
    {
        name: [String] # works: shows as 'string []'
        sku: [{ type: String, index: true }] # doesn't work: shows as 'undefined []'
        seller: [{ type: String }] # doesn't work: shows as 'undefined []'
    },
    { strict: false, _id: false }
)

Routes documentation do not respect app.use('/path_to_routes', router);

The following steps may be used to reproduce this issue:

In the apiDocs there will be two entries for the get method with path '/'. Expected behaviour is to have a get method for the '/' and '/users' paths.

Any way to turn off model docs

I don't really want to expose the mongoose model docs.

Might be that express-docs and mongoose-docs are 2 different modules. Just a thought.

Great start, looks awesome!!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.