Skip to content

dzhitomirsky/episwag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Episwag

Swagger documentation generator for Epilogue.js

Intro

When you implement a relational database - driven application, using Express & Sequelize, you might want to bootstrap the rest api using the Epilogue.js library. In two words it generates CRUD enponts according to your domain and paths that you want, e.g:

 epilogue.initialize({ app, sequelize, base: '/api' }); // app is a initialized express instance

 const authorResource = epilogue.resource({
      model: Author,
      endpoints: ['/author', '/author/:id'],
    });

will generate next endpoints:

  • GET https://host:port/api/author - list/search authors
  • GET https://host:port/api/author/{id} - get author by id
  • DELETE https://host:port/api/author/{id} - delete author by id
  • POST https://host:port/api/author - create new author
  • PUT https://host:port/api/author/{id} - update new author

You can read more about Epilogue here.

The idea is that we have a generated api, why we can't generate documentation for it?

Usage example

(I assume that you are ising express) Define a Sequelize model:

const Author = sequelize.define('Author', {
  // some field definition 
})

Unit Epilogue resource:

epilogue.initialize({ app, sequelize, base: '/api' });

const authorResource = epilogue.resource({
  model: Author,
  endpoints: ['/author', '/author/:id'],
});

We are almost done, now we can generate swagger schema for our endpoints:

episwag({
  epilogueInstance: epilogue,
  resources: [
    authorResource,
    bookResource,
  ],
  header: { host: req.get('host') },
}))

About

Swagger docs generations for epilogue

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published