swagger-mongodb
lightweight swagger-ui crud-api backed by mongodb
note
- requires mongodb 2.6 or higer
live test-server
git-branch : | master | beta | alpha |
---|---|---|---|
test-server : | ![]() |
![]() |
![]() |
test-report : | |||
coverage : | |||
build-artifacts : | ![]() |
![]() |
![]() |
master branch
- stable branch
- HEAD should be tagged, npm-published package
beta branch
- semi-stable branch
- HEAD should be latest, npm-published package
alpha branch
- unstable branch
- HEAD is arbitrary
- commit history may be rewritten
quickstart web example
to run this example, follow the instruction in the script below
- example.js
/*example.js this node script will serve alightweight swagger-ui crud-api backed by mongodb instruction 1. save this script as example.js 2. run the shell command: $ npm install swagger-mongodb && \ npm_config_server_port=1337 node example.js 3. open a browser to http://localhost:1337 4. interact with the swagger-ui crud-api*/ /*jslint browser: true, maxerr: 8, maxlen: 96, node: true, nomen: true, regexp: true, stupid: true*/ { 'use strict'; // run node js-env code { var local; // init local local = {}; localglobal = global; localmodeJs = 'node'; try localswmg = ; catch errorCaught localswmg = ; localutility2 = localswmglocalutility2; // init onReady localutility2; // import swmg.local Object; // export local moduleexports = local; // init assets localutility2cacheDictassets'/' = '<!DOCTYPE html>\n' +/* jslint-ignore-begin */'<html>\n' +'<head>\n' +' <meta charset="UTF-8">\n' +' <title>\n' +' {{envDict.npm_package_name}} [{{envDict.npm_package_version}}]\n' +' </title>\n' +' <link rel="stylesheet" href="/assets/utility2.css">\n' +' <style>\n' +' * {\n' +' box-sizing: border-box;\n' +' }\n' +' body {\n' +' background-color: #fff;\n' +' font-family: Helvetical Neue, Helvetica, Arial, sans-serif;\n' +' }\n' +' body > div {\n' +' margin: 20px 0 20px 0;\n' +' }\n' +' .testReportDiv {\n' +' display: none;\n' +' }\n' +' </style>\n' +' {{envDict.npm_config_html_head_extra}}\n' +'</head>\n' +'<body>\n' +' <div class="ajaxProgressDiv" style="display: none;">\n' +' <div class="ajaxProgressBarDiv ajaxProgressBarDivLoading" \>loading</div>\n' +' </div>\n' +' <h1 \>{{envDict.npm_package_name}} [{{envDict.npm_package_version}}]</h1>\n' +' <h3>{{envDict.npm_package_description}}</h3>\n' +' <div class="testReportDiv"></div>\n' +' <div id="swagger-ui-container" style="display: none;"></div>\n' +' <iframe \height="512" \src="/assets/swagger-ui.html" \width="100%" \></iframe>\n' +' <script src="/assets/utility2.js"></script>\n' +' <script src="/assets/swagger-ui.rollup.js"></script>\n' +' <script src="/assets/swagger-mongodb.js"></script>\n' +' <script src="/test/test.js"></script>\n' +' <script>\n' +' window.utility2 = window.utility2 || {};\n' +' window.utility2.envDict = {\n' +' npm_package_description: "{{envDict.npm_package_description}}",\n' +' npm_package_name: "{{envDict.npm_package_name}}",\n' +' npm_package_version: "{{envDict.npm_package_version}}"\n' +' };\n' +' document.querySelector("iframe").onload = function () {\n' +' var self;\n' +' self = this;\n' +' self.height = innerHeight - self.offsetTop - 20;\n' +' self.contentWindow.location.hash = location.hash;\n' +' self.contentWindow.onclick = function () {\n' +' setTimeout(function () {\n' +' location.hash = self.contentWindow.location.hash;\n' +' });\n' +' };\n' +' };\n' +' </script>\n' +' {{envDict.npm_config_html_body_extra}}\n' +'</body>\n' +/* jslint-ignore-end */ '</html>\n'; localutility2cacheDictassets'/' = localutility2; localutility2cacheDictassets'/test/test.js' = localutility2istanbul_lite; // init mongodb-client localutility2onReadycounter += 1; localutility2; // init middleware localmiddleware = localutility2; // init error-middleware localmiddlewareError = localswmgmiddlewareError; // init petstore-api { var methodPath options schema; options = localutility2; options = definitions: optionsdefinitions paths: optionspaths tags: optionstags ; // remove unused properties delete optionsdefinitionsApiResponse; // init schema Object; localutility2; // transform petstore-api to swagger-mongodb's crud-api Object; localswmg; }; // init petstore-middleware localmiddlewaremiddlewareList; // run server-test localutility2; };};
output from shell
output from phantomjs-lite
npm-dependencies
package-listing
package.json
todo
- add logging feature
- rename delete to remove for naming consistency
- merge response.meta into response.data
- migrate to travis-ci docker container build
- add cached param for crudGetByQueryMany
- add SwmgUserLoginTokenCapped
- re-enable user login/logout
- test /user/login and /user/logout
- add max / min validation
- none
change since 611e604d
- npm publish 2015.7.13
- update README.md
- update dependencies
- none
changelog of last 50 commits
internal build-script
- build.sh
# build.sh # this shell script will run the build for this package shBuild # save exit-code EXIT_CODE=$? shBuildCleanup || exit $? # if running legacy-node, then do not continue [ "$(node --version)" \< "v0.12" ] && exit $EXIT_CODE # upload build-artifacts to github, # and if number of commits > 16, then squash older commits COMMIT_LIMIT=16 shBuildGithubUpload || exit $? # exit with $EXIT_CODE exit $EXIT_CODE