public function handleCommand($command, $data = null) { switch (strtolower($command)) { // Info.string case 'title': case 'description': case 'version': case 'terms': // alias // alias case 'tos': // alias // alias case 'termsofservice': case 'contact': case 'license': return $this->Info->handleCommand($command, $data); // string[] // string[] case 'scheme': case 'schemes': $this->{$command} = array_unique(array_merge($this->{$command}, self::words_split($data))); return $this; // MIME[] // MIME[] case 'consume': case 'consumes': case 'produce': case 'produces': $this->{$command} = array_merge($this->{$command}, self::translateMimeTypes(self::words_split($data))); return $this; case 'model': // alias $data = 'params ' . $data; case 'define': case 'definition': $type = self::words_shift($data); switch ($type) { case 'response': // $definition = new SwaggerResponseDefinition($this); // break; // $definition = new SwaggerResponseDefinition($this); // break; case 'params': case 'parameters': // alias $definition = new Schema($this); break; default: throw new \SwaggerGen\Exception('Unsupported definition type: ' . $type); } $this->definitions[self::words_shift($data)] = $definition; return $definition; case 'api': // alias // alias case 'tag': $tagname = self::words_shift($data); $Tag = null; foreach ($this->Tags as $T) { if ($T->getName() === $tagname) { $Tag = $T; break; } } if (!$Tag) { $Tag = new Tag($this, $tagname, $data); $this->Tags[] = $Tag; } // @todo remove this; it's for backwards compatibility only if ($command === 'api') { // backwards compatibility $this->defaultTag = $Tag; } return $Tag; case 'endpoint': $path = self::words_shift($data); if ($path[0] !== '/') { $path = '/' . $path; } $Tag = null; if (($tagname = self::words_shift($data)) !== false) { foreach ($this->Tags as $T) { if (strtolower($T->getName()) === strtolower($tagname)) { $Tag = $T; break; } } if (!$Tag) { $Tag = new Tag($this, $tagname, $data); $this->Tags[] = $Tag; } } if (!isset($this->Paths[$path])) { $this->Paths[$path] = new Path($this, $Tag ?: $this->defaultTag); } return $this->Paths[$path]; case 'security': $name = self::words_shift($data); $type = self::words_shift($data); $SecurityScheme = new SecurityScheme($this, $type, $data); $this->securityDefinitions[$name] = $SecurityScheme; return $SecurityScheme; case 'require': $name = self::words_shift($data); $this->security[$name] = self::words_split($data); return $this; } return parent::handleCommand($command, $data); }