0.6.5 • Published 9 years ago

koa-spec v0.6.5

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
9 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

9 years ago

0.6.4

9 years ago

0.6.3

9 years ago

0.6.2

9 years ago

0.6.1

9 years ago

0.6.0

10 years ago

0.5.0

10 years ago

0.4.0

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.4

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago