[^,\'"]*[\'"]?([^\'",\s}]+)[\'"]?[^}]*}/s'; if (preg_match_all($pattern, $content, $route_matches, PREG_SET_ORDER)) { foreach ($route_matches as $match) { $path = $match[1]; $method = strtoupper(trim($match[2], '"\'')); // Converter constantes WordPress $method = str_replace([ 'WP_REST_Server::READABLE', 'WP_REST_Server::CREATABLE', 'WP_REST_Server::EDITABLE', 'WP_REST_Server::DELETABLE' ], ['GET', 'POST', 'PUT', 'DELETE'], $method); echo " $method $path\n"; $all_endpoints[] = [ 'entity' => $entity_name, 'method' => $method, 'path' => $path, 'full_url' => '/wp-json/care/v1' . $path ]; } } echo "\n"; } } // Gerar resumo echo "=== RESUMO TOTAL ===\n"; echo "Total de endpoints: " . count($all_endpoints) . "\n"; $by_entity = []; foreach ($all_endpoints as $endpoint) { $by_entity[$endpoint['entity']][] = $endpoint; } foreach ($by_entity as $entity => $endpoints) { echo "$entity: " . count($endpoints) . " endpoints\n"; } // Gerar JSON estruturado para documentação $structured_data = [ 'api_info' => [ 'name' => 'KiviCare REST API', 'version' => '1.0.0', 'namespace' => 'care/v1', 'base_url' => '/wp-json/care/v1' ], 'total_endpoints' => count($all_endpoints), 'endpoints_by_entity' => $by_entity, 'all_endpoints' => $all_endpoints ]; file_put_contents(__DIR__ . '/api-endpoints-map.json', json_encode($structured_data, JSON_PRETTY_PRINT)); echo "\nMapa de endpoints guardado em: api-endpoints-map.json\n";