diff --git a/src/PHPDraft/In/ApibFileParser.php b/src/PHPDraft/In/ApibFileParser.php index daa9c716..6f133959 100644 --- a/src/PHPDraft/In/ApibFileParser.php +++ b/src/PHPDraft/In/ApibFileParser.php @@ -60,6 +60,11 @@ function get_apib($filename) $this->get_apib($this->location . $value . '.apib'), $file); } + preg_match_all('', $file, $matches); + foreach ($matches[1] as $value) { + $file = str_replace('', $this->get_schema($value), $file); + } + return $file; } @@ -72,13 +77,31 @@ function get_apib($filename) */ private function file_check($filename) { - if (!file_exists($filename)) - { + if (!file_exists($filename)) { file_put_contents('php://stderr', "API File not found: $filename\n"); exit(1); } } + /** + * Get an external Schema by URL + * + * @param string $url URL to fetch the schema from + * + * @return string The schema as a string + */ + function get_schema($url) + { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + $result = curl_exec($ch); + curl_close($ch); + + return $result; + } + /** * Return the value of the class * diff --git a/src/PHPDraft/Out/HTML/default.phtml b/src/PHPDraft/Out/HTML/default.phtml index 3185f497..224a55ff 100644 --- a/src/PHPDraft/Out/HTML/default.phtml +++ b/src/PHPDraft/Out/HTML/default.phtml @@ -177,8 +177,7 @@ $base = $this->categories; description; ?> url_variables !== []): ?>
Example URI
- base_data['HOST']; ?> - build_url(); ?> + base_data['HOST']; ?>build_url(); ?> headers !== []): ?>
Headers