<commit_before>// Copyright 2016, EMC, Inc.

'use strict';

var injector = require('../../../index.js').injector;
var controller = injector.get('Http.Services.Swagger').controller;
var schemaApiService = injector.get('Http.Api.Services.Schema');
var nameSpace = '/api/2.0/schemas/';
var Errors = injector.get('Errors');
var taskOptionValidator = injector.get('TaskOption.Validator');

// GET /api/2.0/schemas
var schemasGet = controller(function() {
    return schemaApiService.getNamespace(nameSpace);
});

// GET /api/2.0/schemas/:identifier
var schemasIdGet = controller(function(req) {
    var schemaUid = nameSpace + req.swagger.params.identifier.value;
    var schema = schemaApiService.getSchema(schemaUid);
    if (schema) {
        return schema;
    }
    throw new Errors.NotFoundError(schemaUid + ' Not Found');
});

// GET /api/2.0/schemas/tasks
var taskSchemasGet = controller(function () {
    return taskOptionValidator.getAllSchemaNames({ includeNameSpace: true });
});

// GET /api/2.0/schemas/tasks/:identifier
var taskSchemasIdGet = controller(function (req) {
     var name = req.swagger.params.identifier.value;
     var resolveRef = req.swagger.params.resolveRef.value;
     var schema;
     if (resolveRef) {
        schema = taskOptionValidator.getSchemaResolved(name);
     }
     else {
        schema = taskOptionValidator.getSchema(name);
     }

     if (schema) {
         return schema;
     }

     throw new Errors.NotFoundError(name + ' Not Found');
});

module.exports = {
    schemasGet: schemasGet,
    schemasIdGet: schemasIdGet,
    taskSchemasGet: taskSchemasGet,
    taskSchemasIdGet: taskSchemasIdGet
};
<commit_msg>Update /schemas/tasks not to include namespace<commit_after>// Copyright 2016, EMC, Inc.

'use strict';

var injector = require('../../../index.js').injector;
var controller = injector.get('Http.Services.Swagger').controller;
var schemaApiService = injector.get('Http.Api.Services.Schema');
var nameSpace = '/api/2.0/schemas/';
var Errors = injector.get('Errors');
var taskOptionValidator = injector.get('TaskOption.Validator');

// GET /api/2.0/schemas
var schemasGet = controller(function() {
    return schemaApiService.getNamespace(nameSpace);
});

// GET /api/2.0/schemas/:identifier
var schemasIdGet = controller(function(req) {
    var schemaUid = nameSpace + req.swagger.params.identifier.value;
    var schema = schemaApiService.getSchema(schemaUid);
    if (schema) {
        return schema;
    }
    throw new Errors.NotFoundError(schemaUid + ' Not Found');
});

// GET /api/2.0/schemas/tasks
var taskSchemasGet = controller(function () {
    return taskOptionValidator.getAllSchemaNames({ includeNameSpace: false });
});

// GET /api/2.0/schemas/tasks/:identifier
var taskSchemasIdGet = controller(function (req) {
     var name = req.swagger.params.identifier.value;
     var resolveRef = req.swagger.params.resolveRef.value;
     var schema;
     if (resolveRef) {
        schema = taskOptionValidator.getSchemaResolved(name);
     }
     else {
        schema = taskOptionValidator.getSchema(name);
     }

     if (schema) {
         return schema;
     }

     throw new Errors.NotFoundError(name + ' Not Found');
});

module.exports = {
    schemasGet: schemasGet,
    schemasIdGet: schemasIdGet,
    taskSchemasGet: taskSchemasGet,
    taskSchemasIdGet: taskSchemasIdGet
};

{'fraction_non_alphanumeric': 0.13305489260143197, 'fraction_numerical': 0.008353221957040573, 'mean_word_length': 3.5931506849315067, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1169273', 'n_tokens_mistral': 1052, 'n_tokens_neox': 1028, 'n_words': 207}