/** * @return mixed */ protected function swaggerResponse() { $builder = new SwaggerBuilder(Request::getHttpHost(), '/'); $builder->setTitle('Laravel Charon Pet Store API')->setDescription('API built with Laravel and Charon... about pets.')->setContact('CatLab Interactive', 'http://www.catlab.eu/', '*****@*****.**')->setVersion('1.0'); foreach ($this->getRouteCollection()->getRoutes() as $route) { $builder->addRoute($route); } /* * Authentication protocols * (note that this is only to document these; must be enforced in the controllers / middleware) */ $oauth2 = new OAuth2Authentication('oauth2'); $oauth2->setAuthorizationUrl(url('oauth/authorize'))->setFlow('implicit')->addScope('full', 'Full access'); $builder->addAuthentication($oauth2); return $builder->build(); }
/** * @param SwaggerBuilder $builder * @param $action * @return mixed[] */ public function toSwagger(SwaggerBuilder $builder, $action) { if (Action::isReadContext($action) && $this->isExpanded()) { return ['type' => 'object', 'schema' => $builder->getRelationshipSchema(ResourceDefinitionLibrary::make($this->childResource), $this->getExpandContext(), $this->cardinality)]; } elseif (Action::isWriteContext($action)) { if ($this->linkOnly) { return ['type' => 'object', 'schema' => $builder->getRelationshipSchema(ResourceDefinitionLibrary::make($this->childResource), Action::IDENTIFIER, $this->cardinality)]; } else { return ['type' => 'object', 'schema' => $builder->getRelationshipSchema(ResourceDefinitionLibrary::make($this->childResource), Action::CREATE, $this->cardinality)]; } } else { return ['type' => 'object', 'schema' => ['properties' => [ResourceTransformer::RELATIONSHIP_LINK => ['type' => 'string']]]]; } }