bin/normalize-request.js
function deserializeParameter(server, name, value, schema) {
    if (!schema) return value;

    const type = schemaType(schema);
    if (!type) server.log('req-params', 'Indeterminate schema type for parameter ' + name, schema);

    if (type === 'array') {
        const format = schema.hasOwnProperty('collectionFormat') ? schema.collectionFormat : 'csv';
        const delimiter = format === 'csv' ? ','
            : format === 'ssv' ? ' '
                : format === 'tsv' ? '\t'
                    : format === 'pipes' ? '|' : ',';
        value = value.split(delimiter);
        if (!schema.items) return value;
        return value.map(item => {
            return deserializeParameter(server, 'items for ' + name, item, schema.items);
        });

    } else if (type === 'boolean') {
        return !(value === 'false' || value === 'null' || value === '0' || value === '');

    } else if (type === 'integer' && rxInteger.test(value)) {
        return parseInt(value);

    } else if (type === 'number' && rxNumber.test(value)) {
        return parseFloat(value);

    } else {
        return value;
    }
}
function deserializeParameter(server, name, value, schema) {
    if (!schema) return value;

    const type = schemaType(schema);
    if (!type) server.log('req-params', 'Indeterminate schema type for parameter ' + name, schema);

    if (type === 'array') {
        const format = schema.hasOwnProperty('collectionFormat') ? schema.collectionFormat : 'csv';
        const delimiter = format === 'csv' ? ','
            : format === 'ssv' ? ' '
                : format === 'tsv' ? '\t'
                    : format === 'pipes' ? '|' : ',';
        value = value.split(delimiter);
        if (!schema.items) return value;
        return value.map(item => {
            return deserializeParameter(server, 'items for ' + name, item, schema.items);
        });

    } else if (type === 'boolean') {
        return !(value === 'false' || value === 'null' || value === '0' || value === '');

    } else if (type === 'integer' && rxInteger.test(value)) {
        return parseInt(value);

    } else if (type === 'number' && rxNumber.test(value)) {
        return parseFloat(value);

    } else {
        return value;
    }
}
function deserializeParameter ( server , name , value , schema ) { if ( ! schema ) return value ; const type = schemaType ( schema ) ; if ( ! type ) server . log ( 'req-params' , 'Indeterminate schema type for parameter ' + name , schema ) ; if ( type === 'array' ) { const format = schema . hasOwnProperty ( 'collectionFormat' ) ? schema . collectionFormat : 'csv' ; const delimiter = format === 'csv' ? ',' : format === 'ssv' ? ' ' : format === 'tsv' ? '\t' : format === 'pipes' ? '|' : ',' ; value = value . split ( delimiter ) ; if ( ! schema . items ) return value ; return value . map ( item => { return deserializeParameter ( server , 'items for ' + name , item , schema . items ) ; } ) ; } else if ( type === 'boolean' ) { return ! ( value === 'false' || value === 'null' || value === '0' || value === '' ) ; } else if ( type === 'integer' && rxInteger . test ( value ) ) { return parseInt ( value ) ; } else if ( type === 'number' && rxNumber . test ( value ) ) { return parseFloat ( value ) ; } else { return value ; } }
Deserialize a single parameter.
@param {SansServer} server
@param {string} name
@param {*} value
@param {*} schema
@returns {*}
Deserialize a single parameter .