// Copyright 2014-2015, Renasar Technologies Inc.
/* jshint node: true */

'use strict';

var di = require('di'),
    express = require('express');

module.exports = schemasRouterFactory;

di.annotate(schemasRouterFactory, new di.Provide('Http.Api.Schemas'));
di.annotate(schemasRouterFactory,
    new di.Inject(
        '_',
        'Http.Services.RestApi',
        di.Injector
    )
);

function schemasRouterFactory (_, rest, injector) {
    var router = express.Router();

    var schemas = _.map(injector.getMatching('Serializables.V1.*'), function (item) {
        return item.schema;
    });

    router.get('/schemas', rest(function () {
        return schemas;
    }));

    router.get('/schemas/:id', rest(function (req) {
        return _.find(schemas, function (schema) {
            return schema.id === req.params.id;
        });
    }));

    return router;
}


@@ -601,83 +601,879 @@
     
-router.get('/schemas', rest(function () %7B%0A        return schemas;%0A    %7D));%0A
+/**%0A     * @api %7Bget%7D /api/1.1/schemas/ GET /%0A     * @apiVersion 1.1.0%0A     * @apiDescription get list of schemas%0A     * @apiName schemas-get%0A     * @apiGroup schemas%0A     * @apiSuccess %7Bjson%7D schemas List of all schemas or if there are none an empty object.%0A     */%0A    router.get('/schemas', rest(function () %7B%0A        return schemas;%0A    %7D));%0A%0A    /**%0A     * @api %7Bget%7D /api/1.1/schemas/:id GET /:id%0A     * @apiVersion 1.1.0%0A     * @apiDescription get specific schema details%0A     * @apiName schema-get%0A     * @apiGroup schemas%0A     * @apiParam %7BString%7D id schema id%0A     * @apiSuccess %7Bjson%7D schema the schemas that have the %3Ccode%3Eid%3C/code%3E%0A     * @apiError NotFound The schema with the %3Ccode%3Eid%3C/code%3E was not found.%0A     * @apiErrorExample %7Bjson%7D Error-Response:%0A     *     HTTP/1.1 404 Not Found%0A     *     %7B%0A     *       %22error%22: %22Not Found%22%0A     *      %7D%0A     */
 %0A   

add apidoc for schemas api related to MON-290