public function buildOperationCollection(Swagger $swagger) { $operationCollection = new OperationCollection(); foreach ($swagger->getPaths() as $path => $pathItem) { if ($pathItem instanceof PathItem) { if ($pathItem->getDelete() instanceof SwaggerOperation) { $operationCollection->addOperation(new Operation($pathItem->getDelete(), $path, Operation::DELETE, $swagger->getBasePath())); } if ($pathItem->getGet() instanceof SwaggerOperation) { $operationCollection->addOperation(new Operation($pathItem->getGet(), $path, Operation::GET, $swagger->getBasePath())); } if ($pathItem->getHead() instanceof SwaggerOperation) { $operationCollection->addOperation(new Operation($pathItem->getHead(), $path, Operation::HEAD, $swagger->getBasePath())); } if ($pathItem->getOptions() instanceof SwaggerOperation) { $operationCollection->addOperation(new Operation($pathItem->getOptions(), $path, Operation::OPTIONS, $swagger->getBasePath())); } if ($pathItem->getPatch() instanceof SwaggerOperation) { $operationCollection->addOperation(new Operation($pathItem->getPatch(), $path, Operation::PATCH, $swagger->getBasePath())); } if ($pathItem->getPost() instanceof SwaggerOperation) { $operationCollection->addOperation(new Operation($pathItem->getPost(), $path, Operation::POST, $swagger->getBasePath())); } if ($pathItem->getPut() instanceof SwaggerOperation) { $operationCollection->addOperation(new Operation($pathItem->getPut(), $path, Operation::PUT, $swagger->getBasePath())); } } } return $operationCollection; }
/** * {@inheritDoc} * * @param Swagger $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; }