コード例 #1
0
 /**
  * {@inheritDoc}
  *
  * @param OpenApi $object
  */
 public function guessClass($object, $name)
 {
     $classes = [];
     if ($object->getDefinitions() !== null) {
         foreach ($object->getDefinitions() as $key => $definition) {
             $classes = array_merge($classes, $this->chainGuesser->guessClass($definition, $key));
         }
     }
     foreach ($object->getPaths() as $pathName => $path) {
         if ($path instanceof PathItem) {
             $classes = array_merge($classes, $this->getClassFromOperation($pathName, $path->getDelete()));
             $classes = array_merge($classes, $this->getClassFromOperation($pathName, $path->getGet()));
             $classes = array_merge($classes, $this->getClassFromOperation($pathName, $path->getHead()));
             $classes = array_merge($classes, $this->getClassFromOperation($pathName, $path->getOptions()));
             $classes = array_merge($classes, $this->getClassFromOperation($pathName, $path->getPatch()));
             $classes = array_merge($classes, $this->getClassFromOperation($pathName, $path->getPost()));
             $classes = array_merge($classes, $this->getClassFromOperation($pathName, $path->getPut()));
             $classes = array_merge($classes, $this->getClassFromParameters($pathName, $path->getParameters()));
         }
     }
     $classes = array_merge($classes, $this->getClassFromParameters($name, $object->getParameters()));
     return $classes;
 }
コード例 #2
0
 public function buildOperationCollection(OpenApi $openApi)
 {
     $operationCollection = new OperationCollection();
     $host = $openApi->getHost() === null ? 'localhost' : $openApi->getHost();
     foreach ($openApi->getPaths() as $path => $pathItem) {
         if ($pathItem instanceof PathItem) {
             if ($pathItem->getDelete() instanceof OpenApiOperation) {
                 $operationCollection->addOperation(new Operation($pathItem->getDelete(), $path, Operation::DELETE, $openApi->getBasePath(), $host));
             }
             if ($pathItem->getGet() instanceof OpenApiOperation) {
                 $operationCollection->addOperation(new Operation($pathItem->getGet(), $path, Operation::GET, $openApi->getBasePath(), $host));
             }
             if ($pathItem->getHead() instanceof OpenApiOperation) {
                 $operationCollection->addOperation(new Operation($pathItem->getHead(), $path, Operation::HEAD, $openApi->getBasePath(), $host));
             }
             if ($pathItem->getOptions() instanceof OpenApiOperation) {
                 $operationCollection->addOperation(new Operation($pathItem->getOptions(), $path, Operation::OPTIONS, $openApi->getBasePath(), $host));
             }
             if ($pathItem->getPatch() instanceof OpenApiOperation) {
                 $operationCollection->addOperation(new Operation($pathItem->getPatch(), $path, Operation::PATCH, $openApi->getBasePath(), $host));
             }
             if ($pathItem->getPost() instanceof OpenApiOperation) {
                 $operationCollection->addOperation(new Operation($pathItem->getPost(), $path, Operation::POST, $openApi->getBasePath(), $host));
             }
             if ($pathItem->getPut() instanceof OpenApiOperation) {
                 $operationCollection->addOperation(new Operation($pathItem->getPut(), $path, Operation::PUT, $openApi->getBasePath(), $host));
             }
         }
     }
     return $operationCollection;
 }