Commit ff01af8db045d50007df5b4d0639bba3b6e605ac

Authored by Nathanaël Jourdane
1 parent 55748a3e

Add script to generate the API documentation

php/my_config.template.php
... ... @@ -32,4 +32,6 @@ define('NEWMETA', '{:NEWMETA:}');
32 32 define('AMDA_SPASE_INTERFACE', '{:AMDA_SPASE_INTERFACE:}');
33 33 define('AMDAINTERNALDIR', '{:AMDAINTERNALDIR:}');
34 34  
  35 +define('REST_API_URL', '{:REST_API_URL:}');
  36 +define('API_DOC_PATH', '{:API_DOC_PATH:}');
35 37 ?>
... ...
php/rest/apidoc.json
... ... @@ -2,6 +2,6 @@
2 2 "name": "AMDA web-services Rest API",
3 3 "description": "The web-services provided by AMDA aim at giving to a user access public data as well as its private data. These data may be private or shared Time Tables, public or user-defined parameters. All these webservices are also available through a SOAP interface.",
4 4 "title": "AMDA Web-services Rest API documentation",
5   - "url": "http://amda.irap.omp.eu/php/rest/",
6   - "sampleUrl": "http://amda.irap.omp.eu/php/rest/"
  5 + "url": "{:REST_API_URL:}/php/rest/",
  6 + "sampleUrl": "{:REST_API_URL:}/php/rest/"
7 7 }
... ...
scripts/apiDoc.php 0 → 100644
... ... @@ -0,0 +1,12 @@
  1 +<?php
  2 +require_once dirname(__FILE__) . '/../php/config.php';
  3 +
  4 +$restFolderPath = AMDA_IHM . "php/rest";
  5 +$apidocConfigFile = $restFolderPath . "apidoc.json";
  6 +$tempConfigFile = tempnam(sys_get_temp_dir(), 'apidoc.json');
  7 +
  8 +$apidocConfig = str_replace("{:REST_API_URL:}", REST_API_URL, file_get_contents($apidocConfigFile));
  9 +file_put_contents($tempConfigFile, $apidocConfig);
  10 +
  11 +echo exec("apidoc -v -c $tempConfigFile -i $restFolderPath -o " . API_DOC_PATH);
  12 +?>
... ...