Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fliptoo committed Mar 19, 2013
0 parents commit 6f64e49
Show file tree
Hide file tree
Showing 30 changed files with 6,767 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

node_modules/
.DS_Store
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

examples/
.DS_Store
.git*
project.sublime-project
project.sublime-workspace
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright (c) 2013 Fliptoo <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
48 changes: 48 additions & 0 deletions examples/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

/**
* @swagger
* resourcePath: /api
* description: All about API
*/

/**
* @swagger
* path: /login
* operations:
* - httpMethod: POST
* summary: Login with username and password
* notes: Returns a user based on username
* responseClass: User
* nickname: login
* consumes:
* - text/html
* parameters:
* - name: username
* description: Your username
* paramType: query
* required: true
* dataType: string
* - name: password
* description: Your password
* paramType: query
* required: true
* dataType: string
*/
exports.login = function (req, res) {
var user = {};
user.username = req.param('username');
user.password = req.param('password');
res.json(user);
}

/**
* @swagger
* models:
* User:
* id: User
* properties:
* username:
* type: String
* password:
* type: String
*/
36 changes: 36 additions & 0 deletions examples/api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
resourcePath: /api
description: All about API
apis:

- path: /login
operations:

- httpMethod: POST
summary: Login with username and password
notes: Returns a user based on username
responseClass: User
nickname: login
consumes:
- text/html
parameters:

- name: username
dataType: string
paramType: query
required: true
description: Your username

- name: password
dataType: string
paramType: query
required: true
description: Your password

models:
User:
id: User
properties:
username:
type: String
password:
type: String
44 changes: 44 additions & 0 deletions examples/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

/**
* Module dependencies.
*/

var express = require('express')
, api = require('./api')
, http = require('http')
, path = require('path')
, swagger = require('../');

var app = express();

app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(swagger.init(app, {
swaggerUI: './public/swagger/',
basePath: 'http://localhost:3000',
apis: ['./api.js']
//apis: [__dirname + '/api.yml']
}));
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
});

app.configure('development', function(){
app.use(express.errorHandler());
});

app.get('/', function(req, res){
res.render('index', { title: 'Express' });
});

app.post('/login', api.login);

http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
8 changes: 8 additions & 0 deletions examples/public/stylesheets/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
body {
padding: 50px;
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
}

a {
color: #00B7FF;
}
135 changes: 135 additions & 0 deletions examples/public/swagger/css/hightlight.default.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*
Original style from softwaremaniacs.org (c) Ivan Sagalaev <[email protected]>
*/

pre code {
display: block; padding: 0.5em;
background: #F0F0F0;
}

pre code,
pre .subst,
pre .tag .title,
pre .lisp .title,
pre .clojure .built_in,
pre .nginx .title {
color: black;
}

pre .string,
pre .title,
pre .constant,
pre .parent,
pre .tag .value,
pre .rules .value,
pre .rules .value .number,
pre .preprocessor,
pre .ruby .symbol,
pre .ruby .symbol .string,
pre .aggregate,
pre .template_tag,
pre .django .variable,
pre .smalltalk .class,
pre .addition,
pre .flow,
pre .stream,
pre .bash .variable,
pre .apache .tag,
pre .apache .cbracket,
pre .tex .command,
pre .tex .special,
pre .erlang_repl .function_or_atom,
pre .markdown .header {
color: #800;
}

pre .comment,
pre .annotation,
pre .template_comment,
pre .diff .header,
pre .chunk,
pre .markdown .blockquote {
color: #888;
}

pre .number,
pre .date,
pre .regexp,
pre .literal,
pre .smalltalk .symbol,
pre .smalltalk .char,
pre .go .constant,
pre .change,
pre .markdown .bullet,
pre .markdown .link_url {
color: #080;
}

pre .label,
pre .javadoc,
pre .ruby .string,
pre .decorator,
pre .filter .argument,
pre .localvars,
pre .array,
pre .attr_selector,
pre .important,
pre .pseudo,
pre .pi,
pre .doctype,
pre .deletion,
pre .envvar,
pre .shebang,
pre .apache .sqbracket,
pre .nginx .built_in,
pre .tex .formula,
pre .erlang_repl .reserved,
pre .prompt,
pre .markdown .link_label,
pre .vhdl .attribute,
pre .clojure .attribute,
pre .coffeescript .property {
color: #88F
}

pre .keyword,
pre .id,
pre .phpdoc,
pre .title,
pre .built_in,
pre .aggregate,
pre .css .tag,
pre .javadoctag,
pre .phpdoc,
pre .yardoctag,
pre .smalltalk .class,
pre .winutils,
pre .bash .variable,
pre .apache .tag,
pre .go .typename,
pre .tex .command,
pre .markdown .strong,
pre .request,
pre .status {
font-weight: bold;
}

pre .markdown .emphasis {
font-style: italic;
}

pre .nginx .built_in {
font-weight: normal;
}

pre .coffeescript .javascript,
pre .javascript .xml,
pre .tex .formula,
pre .xml .javascript,
pre .xml .vbscript,
pre .xml .css,
pre .xml .cdata {
opacity: 0.5;
}
Loading

0 comments on commit 6f64e49

Please sign in to comment.