FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
VersionController.php
Go to the documentation of this file.
1 <?php
2 /***************************************************************
3  Copyright (C) 2019 Siemens AG
4  Author: Gaurav Mishra <mishra.gaurav@siemens.com>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  version 2 as published by the Free Software Foundation.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  ***************************************************************/
25 
30 
36 {
45  public function getVersion($request, $response, $args)
46  {
47  try {
48  $yaml = new Parser();
49  $yamlDocArray = $yaml->parse(file_get_contents(__DIR__ ."/../documentation/openapi.yaml"));
50  } catch (ParseException $exception) {
51  printf("Unable to parse the YAML string: %s", $exception->getMessage());
52  }
53  $apiVersion = $yamlDocArray["info"]["version"];
54  $security = array();
55  foreach ($yamlDocArray["security"] as $secMethod) {
56  $security[] = key($secMethod);
57  }
58  return $response->withJson(array(
59  "version" => $apiVersion,
60  "security" => $security
61  ), 200);
62  }
63 }
Base controller for REST calls.