swagger plugin for D programming language
D
Latest commit 3ad1714 Oct 23, 2016 @gedaiu Removed DYAML dependency
Permalink
Failed to load latest commit information.
source
.gitignore fixed broken tests Aug 27, 2016
LICENSE.txt Added license Oct 20, 2015
README.md Removed DYAML dependency Oct 23, 2016
dub.json Removed DYAML dependency Oct 23, 2016

README.md

Swaggarize

Swagger library for D programming language

How to use it

Create handlers

module myapp.handlers;

import vibe.d;
import swaggerize.composites;

@swaggerPath("/hello", OperationsType.options)
void optionsList(string name)(HTTPServerRequest /*req*/, HTTPServerResponse res) {
  res.writeBody("hello world!");
}

Create vibe.d instance

import vibe.d;
import swaggerize.parser;
import swaggerize.composites;
import myapp.handlers;

MongoClient client;

shared static this()
{
  auto definitions = swaggerizeJson("./api.json");

  auto settings = new HTTPServerSettings;
  settings.port = 8080;
  settings.options = HTTPServerOption.parseQueryString | HTTPServerOption.parseJsonBody;

  client = connectMongoDB("127.0.0.1");

  auto router = new URLRouter;
  router.register!(myapp.handlers)(definitions);

  listenHTTP(settings, router);
}