Example #1
0
 public function validate()
 {
     if (count($this->_partials) !== 0) {
         return true;
     }
     if (empty($this->nickname)) {
         Logger::notice('Required field "nickname" is missing for "' . $this->identity() . '" in ' . $this->_context);
     }
     Swagger::checkDataType($this->type, $this->_context);
     foreach ($this->parameters as $parameter) {
         if ($parameter->validate() == false) {
             return false;
         }
     }
     Items::validateContainer($this);
     Produces::validateContainer($this);
     Consumes::validateContainer($this);
     return true;
 }
Example #2
0
 public function validate()
 {
     if (empty($this->resourcePath)) {
         Logger::warning('@SWG\\Resource() is missing "resourcePath" in ' . $this->_context);
         return false;
     }
     if ($this->swaggerVersion) {
         if (version_compare($this->swaggerVersion, '1.2', '<')) {
             Logger::warning('swaggerVersion: ' . $this->swaggerVersion . ' is no longer supported. Use 1.2 or higher');
             $this->swaggerVersion = null;
         }
     }
     $validApis = array();
     foreach ($this->apis as $api) {
         $append = true;
         foreach ($validApis as $validApi) {
             if ($api->path === $validApi->path) {
                 // The same api path?
                 $append = false;
                 // merge operations
                 foreach ($api->operations as $operation) {
                     $validApi->operations[] = $operation;
                 }
                 // merge description
                 if ($validApi->description === null) {
                     $validApi->description = $api->description;
                 } elseif ($api->description !== null && $api->description !== $validApi->description) {
                     Logger::notice('Competing description for ' . $validApi->identity() . ' in ' . $validApi->_context . ' and ' . $api->_context);
                 }
                 break;
             }
         }
         if ($api->validate() && $append) {
             $validApis[] = $api;
         }
     }
     if (count($validApis) === 0 && count($this->_partials) === 0) {
         Logger::warning($this->identity() . ' doesn\'t have any valid api calls');
         return false;
     }
     $this->apis = $validApis;
     Produces::validateContainer($this);
     Consumes::validateContainer($this);
     return true;
 }