<commit_before>var debug = require('debug')('json-schema');

var loopback = require('loopback');
var loopbackExplorer = require('loopback-explorer');

var logger = require('../support/logger')
var LJSRequest = require('./ljs-request');
var modelPropertiesSanitizer = require('./model-properties-sanitizer');

var Model = require('loopback').Model;
var JsonSchema = module.exports = Model.extend('json-schema');

JsonSchema.prototype.addHeaders = function(ljsReq, res) {
    var baseUrl = ljsReq.baseUrl();

    var schemaLink = baseUrl + '/json-schemas/' + this.id;
    res.set('Content-Type', "application/json; profile='"+ schemaLink +"'");
    res.set('Link', '<' + schemaLink + '>; rel=describedby');
};

JsonSchema.findByCollectionName = function(collectionName, next, callback) {
    JsonSchema.findOne({ where: { collectionName: collectionName }}, function(err, jsonSchema) {
        if (err) {
            logger.error("Error fetching JSON Schema for collectionName:", collectionName, "Error:", err);
        } else if (jsonSchema === null) {<commit_msg>Closes #4. Attribute profile should not use '<commit_after>var debug = require('debug')('json-schema');

var loopback = require('loopback');
var loopbackExplorer = require('loopback-explorer');

var logger = require('../support/logger')
var LJSRequest = require('./ljs-request');
var modelPropertiesSanitizer = require('./model-properties-sanitizer');

var Model = require('loopback').Model;
var JsonSchema = module.exports = Model.extend('json-schema');

JsonSchema.prototype.addHeaders = function(ljsReq, res) {
    var baseUrl = ljsReq.baseUrl();

    var schemaLink = baseUrl + '/json-schemas/' + this.id;
    res.set('Content-Type', "application/json; profile="+ schemaLink);
    res.set('Link', '<' + schemaLink + '>; rel=describedby');
};

JsonSchema.findByCollectionName = function(collectionName, next, callback) {
    JsonSchema.findOne({ where: { collectionName: collectionName }}, function(err, jsonSchema) {
        if (err) {
            logger.error("Error fetching JSON Schema for collectionName:", collectionName, "Error:", err);
        } else if (jsonSchema === null) {
{'fraction_non_alphanumeric': 0.16186046511627908, 'fraction_numerical': 0.00046511627906976747, 'mean_word_length': 4.782258064516129, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5416853', 'n_tokens_mistral': 622, 'n_tokens_neox': 613, 'n_words': 143}