0.6.5 • Published 8 years ago

koa-spec v0.6.5

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
8 years ago

koa-spec

npm version Build Status Coverage Status Code Climate Code Documentation Issue Count Dependency Status npm downloads GitHub Issues License Cat Gifs

Installation

$ npm install --save koa-spec ⏎

Examples

Various examples can be found in the /examples directory and executed like this:

$ node examples/simple/app.js ⏎

Basic Example

This is the most simple example showing basic routing (i.e. no parameter or response validation).

(data/)api.yaml

swagger: '2.0'
info:
  version: 0.0.1
  title: Simple.
paths:
  /:
    get:
      x-controller: IndexController
      x-controller-method: get
      responses:
        200:
          description: OK

(controllers/)IndexController.js

'use strict';

module.exports.get = function* () {
  this.body = { index : 'Hello koa-spec!' };
};

app.js

'use strict';

const koa = require('koa');
const koaspec = require('koa-spec');

const app = koa();

const spec = koaspec('data/api.yaml');
const router = spec.router();
app.use(router.routes());

app.listen(8000);

Result

$ curl localhost:8000 ⏎
{
  "index" : "Hello koa-spec!"
}

Features/Roadmap

  • YAML Parsing
  • $ref Resolving
    • local
    • relative
    • remote
    • circular
  • Routing
  • Validation
    • Required
    • Default values
      • Body parameter
      • Query string
      • Headers
    • x-nullable
    • Parameter
      • Sources
        • Header
        • Path
        • Query
        • Body
        • FormData
    • Response
      • Header
      • Body
    • Types
      • Integer
        • int32 (int)
        • int64 (long)
      • Number
        • float
        • double
      • String
        • string
        • byte
        • binary
        • UUID (V1/V4)
        • ISBN (10/13)
        • date (ISO8601)
        • date-time (ISO8601)
      • Boolean
        • boolean
    • Produces
    • Consumes
  • Error-Handling (throw early, throw often)
  • Spread out strictMode usage
0.6.5

8 years ago

0.6.4

8 years ago

0.6.3

8 years ago

0.6.2

8 years ago

0.6.1

8 years ago

0.6.0

8 years ago

0.5.0

8 years ago

0.4.0

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.4

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago