<commit_before>import {actionTypes} from './reducer';
import R from 'ramda';

const traversePropertyPath = (propertyPath, state) => {
    if (propertyPath === '') {
        return state;
    }

    const pathArray = propertyPath.split(';');

    return pathArray.reduce((accum, paramName) => {
        if (paramName.indexOf('[') !== -1) {
            const index = parseInt(paramName.slice(paramName.indexOf('[') + 1, paramName.indexOf(']')), 10);

            return accum.value[index];
        }
        return accum[paramName];
    }, state);
};

export default (state, action) => {
    const newState = R.clone(state);
    const newStateProperty = traversePropertyPath(action.postBodyParamName, newState);

    switch (action.type) {
    case actionTypes.POST_BODY_CHANGED:
//         console.log('POST BODY CHANGED', action);
        newStateProperty.value = action.inputVal;

        return newState;
    case actionTypes.TOGGLE_POST_BODY_ITEM_VISIBILITY:
//         console.log('TOGGLE VISIBILITY ACTION', action);

        newStateProperty.uiState.visible = !newStateProperty.uiState.visible;

        return newState;
    case actionTypes.ADD_ITEM_TO_POST_BODY_COLLECTION:
//         console.log('ADD TO COLLECTION ACTION', action);

        newStateProperty.uiState.visible = true;
        newStateProperty.value = newStateProperty.value.concat(action.itemSchema);
        // Should only set visibility on the array item if it's an object/array, not simple property:
        if (newStateProperty.value[newStateProperty.value.length - 1].uiState) {
            newStateProperty.value[newStateProperty.value.length - 1].uiState.visible = true;
        }
        return newState;
    default:
        return newState;
    }
};
<commit_msg>Fix postBody values to match swagger type  This way numbers and booleans are not saved as string values.<commit_after>import {actionTypes} from './reducer';
import R from 'ramda';

const traversePropertyPath = (propertyPath, state) => {
    if (propertyPath === '') {
        return state;
    }

    const pathArray = propertyPath.split(';');

    return pathArray.reduce((accum, paramName) => {
        if (paramName.indexOf('[') !== -1) {
            const index = parseInt(paramName.slice(paramName.indexOf('[') + 1, paramName.indexOf(']')), 10);

            return accum.value[index];
        }
        return accum[paramName];
    }, state);
};

export default (state, action) => {
    const newState = R.clone(state);
    const newStateProperty = traversePropertyPath(action.postBodyParamName, newState);

    switch (action.type) {
    case actionTypes.POST_BODY_CHANGED:
//         console.log('POST BODY CHANGED', action);

        switch(newStateProperty.fieldType) {
        case 'number':
            newStateProperty.value = parseFloat(action.inputVal);
            break;
        case 'boolean':
            newStateProperty.value = action.inputVal === 'true';
            break;
        default:
            newStateProperty.value = action.inputVal;
        }


        return newState;
    case actionTypes.TOGGLE_POST_BODY_ITEM_VISIBILITY:
//         console.log('TOGGLE VISIBILITY ACTION', action);

        newStateProperty.uiState.visible = !newStateProperty.uiState.visible;

        return newState;
    case actionTypes.ADD_ITEM_TO_POST_BODY_COLLECTION:
//         console.log('ADD TO COLLECTION ACTION', action);

        newStateProperty.uiState.visible = true;
        newStateProperty.value = newStateProperty.value.concat(action.itemSchema);
        // Should only set visibility on the array item if it's an object/array, not simple property:
        if (newStateProperty.value[newStateProperty.value.length - 1].uiState) {
            newStateProperty.value[newStateProperty.value.length - 1].uiState.visible = true;
        }
        return newState;
    default:
        return newState;
    }
};

{'fraction_non_alphanumeric': 0.1145215372710859, 'fraction_numerical': 0.003095176683002321, 'mean_word_length': 2.8434093161546086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2642393', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1087, 'n_words': 242}