function formatDefinitions(def, resp = {}, constainXML) {
    try {
        // Forcing convertion to OpenAPI 3.x
        if (def && def.$ref && getOpenAPI() && def.$ref.includes('#/definitions/')) {
            def.$ref = def.$ref.replaceAll('#/definitions/', '#/components/schemas/');
        }

        /**
         * Enum (OpenAPI v3)
         */
        if (def['@enum']) {
            let enumType = 'string';
            if (def['@enum'][0]) {
                enumType = typeof def['@enum'][0];
            }
            def.type = enumType;
            def.enum = def['@enum'];
            delete def['@enum'];
            return def;
        }

        if (def && def.$ref) {
            if (def.$ref.split('#/').length === 1) {
                console.error('[swagger-autogen]: Syntax error: ', def.$ref);
                return resp;
            }
            let param = def.$ref.split('/').slice(-1)[0].replaceAll(' ', '');
            if (constainXML) {
                return {
                    xml: {
                        name: param.toLowerCase()
                    },
                    $ref: def.$ref
                };
            } else {
                return {
                    $ref: def.$ref
                };
            }
        }
        let arrayOf = null;
        if (typeof def === 'string') {
            resp.type = 'string';
            resp.example = def;
        } else if (typeof def === 'number') {
            resp.type = 'number';
            resp.example = def;
        } else if (typeof def === 'boolean') {
            resp.type = 'boolean';
            resp.example = def;
        } else {
            if (Array.isArray(def)) {
                if (def && typeof def[0] !== 'object') {
                    resp = {
                        type: 'array',
                        example: def,
                        items: {}
                    };
                } else {
                    resp = {
                        type: 'array',
                        items: {}
                    };
                }
                arrayOf = typeof def[0];
            } else {
                resp = {
                    type: 'object',
                    properties: {}
                };
            }
            Object.entries(def)
                .filter(e => e)
                .forEach(elem => {
                    if (typeof elem[1] === 'object') {
                        // Array or object
                        if (elem[0] && elem[0][0] && elem[0][0] == '$') {
                            // Required parameter
                            elem[0] = elem[0].slice(1);
                            if (!resp.required) {
                                resp.required = [];
                            }
                            resp.required.push(elem[0]);
                        }
                        if (resp.type == 'array') {
                            resp.items = {
                                ...formatDefinitions(elem[1], resp, constainXML)
                            };
                        } else {
                            resp.properties[elem[0]] = formatDefinitions(elem[1], resp, constainXML);
                        }
                    } else {
                        if (resp.type == 'array') {
                            if (arrayOf == 'object') {
                                if (!resp.items.properties) resp.items.properties = {};
                                resp.items.properties[elem[0]] = {
                                    type: typeof elem[1]
                                };
                            } else
                                resp.items = {
                                    type: typeof elem[1]
                                };
                        } else {
                            if (elem[0][0] == '$') {
                                // Required parameter
                                elem[0] = elem[0].slice(1);
                                if (!resp.required) resp.required = [];
                                resp.required.push(elem[0]);
                            }
                            resp.properties[elem[0]] = {
                                type: typeof elem[1],
                                example: elem[1]
                            };
                        }
                    }
                });
        }
        return resp;
    } catch (err) {
        return {};
    }
}
TODO: fill
@param {*} def
@param {*} resp