Generate DTO from Doc

PHOTO EMBED

Sat Mar 09 2024 02:43:16 GMT+0000 (Coordinated Universal Time)

Saved by @titorobe #javascript

const genDTO = (className, id) => {
  var fields = [
    'package com.voltcash.integrations.opencp.common.dto; ',
    '\n',
    'import com.voltcash.integrations.common.dto.BaseJsonEntity; ',
    'import lombok.Data;',
     '\n',
    '@Data ',
    'public class '+ className +' extends BaseJsonEntity{ ' 
  ];
 var declarations = $('#' + id).parentNode.querySelectorAll('td:first-child strong').forEach(e => fields.push('private String ' + e.innerHTML + ';'));
  
  fields.push('}');
  
  console.log(fields.join('\n'));
}
content_copyCOPY

Generate DTO from docs in https://cpx.central-payments.com/api-docs Need to pass the DTO class name and the id of the section in the Docs Page