Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

Commit

Permalink
improved stability of the swagger parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
kjschubert committed Jun 6, 2016
1 parent 4bb29ab commit 095f226
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ The PHP GIS Wrapper is tested with PHP unit. All the tests can be found in the f
If you send a pull request, please make sure that your code is covered and run phpunit in the root folder before you commit. Normally phpunit will automatically recognize the file phpunit.xml in the root folder.

# Changelog
## v0.2
## 0.2.1
- improved stability of the swagger parsing
## 0.2
In this version the PHP-GIS-Wrapper was completely refactored. The most important changes are:
- New system architecture, especially for the swagger parser. This leads to cleaner source code and a big performance boost.
- Ability to cache the swagger parsing result, which provides even better performance, especially for big projects
Expand All @@ -216,7 +218,7 @@ In this version the PHP-GIS-Wrapper was completely refactored. The most importan
- Validation of Parameter types
- the PHP GIS Wrapper became a Composer Package

## v0.1
## 0.1
This was the initial version of the PHP-GIS-Wrapper. It only supported GET requests.
- Originally there was only one AuthProvider called AuthProviderUser
- With the introduction of the GIS v2 this Provider was updated to the new GIS Identity, but then only supported EXPA users
Expand Down
10 changes: 5 additions & 5 deletions src/GIS.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public static function generateSimpleCache($apidoc = "https://gis-api.aiesec.org

if($root === false) {
throw new NoResponseException("Could not load swagger root file");
} elseif($root === null || !isset($root->apis) || !is_array($root->apis)) {
} elseif($root === null || !isset($root->apis) || !is_array($root->apis) || !isset($root->basePath)) {
throw new InvalidSwaggerFormatException("Invalid swagger file");
} else {
if(!in_array('application/json', $root->produces)) {
Expand Down Expand Up @@ -203,7 +203,7 @@ private static function proceedSubCache($url, $baseName) {
foreach($manifest->apis as $api) {
// prepare endpoint
$endpoint = array(
'summary' => $api->summary,
'summary' => (isset($api->summary)) ? $api->summary : null,
'path' => str_replace('.{format}', '.json', $manifest->basePath . $api->path),
'endpoint' => true,
'dynamic' => false,
Expand Down Expand Up @@ -274,8 +274,8 @@ private static function proceedSubCache($url, $baseName) {

// place endpoint
if(str_replace('.{format}', '', $api->path) == '/' . $manifest->apiVersion . '/' . $baseName) { // root endpoint
if(is_array($cache['subs'])) $endpoint['subs'] = $cache['subs'];
if($cache['dynamicSub']) $endpoint['dynamicSub'] = true;
if(isset($cache['subs']) && is_array($cache['subs'])) $endpoint['subs'] = $cache['subs'];
if(isset($cache['dynamicSub']) && $cache['dynamicSub']) $endpoint['dynamicSub'] = true;

$cache = $endpoint;
} elseif(count($path) == 1) { // level 1 sub endpoint
Expand Down Expand Up @@ -304,7 +304,7 @@ private static function proceedSubCache($url, $baseName) {
$ref = &$ref['subs'][$p];
}
// check for already added subs as well as the dynamicSub property and keep them
if(isset($ref['subs'])) $endpoint['subs'] = $ref['subs'];
if(isset($ref['subs']) && is_array($ref['subs'])) $endpoint['subs'] = $ref['subs'];
if(isset($ref['dynamicSub']) && $ref['dynamicSub']) $endpoint['dynamicSub'] = true;

// place endpoint
Expand Down

0 comments on commit 095f226

Please sign in to comment.