/**
  * @return array
  */
 public function toArray()
 {
     $array = parent::toArray();
     $array['properties'] = $this->properties->toArray();
     unset($array['name']);
     if (empty($array['properties'])) {
         $array['properties'] = new \stdClass();
     }
     return $array;
 }
Exemple #2
0
 /**
  * Create definitions if need
  * @throws \yii\base\InvalidConfigException
  */
 private function buildDefinitions()
 {
     if ($this->in != 'body') {
         return;
     }
     $def = new Definition($this->action);
     // get parameters and make of them a properties for definition
     foreach ($this->parameters as $id => $parameter) {
         /** @var  Parameter $parameter  */
         if ($parameter->in != 'body') {
             continue;
         }
         $this->parameters->delete($parameter);
         $def->addPropertyFromParameter($parameter);
     }
     Yii::$app->get('doc')->definitions->add($def);
     // we must create parameter with Schema for definition
     $parameter = new Parameter();
     $parameter->buildForDefinition($def);
     $this->parameters->add($parameter);
 }
Exemple #3
0
 /**
  * @return array
  */
 public function toArray()
 {
     return $this->verbs->toArray();
 }
Exemple #4
0
 /**
  * @return array
  */
 public function getDocument()
 {
     return ["swagger" => "2.0", "info" => ["version" => $this->module->apiVersion, "title" => Yii::$app->name, "description" => $this->module->description], "host" => $this->module->host, "basePath" => $this->module->basePath, "schemes" => $this->module->schemes, "consumes" => $this->module->consumes, "produces" => $this->module->produces, 'tags' => array_values($this->tags->toArray()), 'paths' => $this->paths->toArray(), 'definitions' => $this->definitions->toArray()];
 }