Abstract Class luya\admin\openapi\BasePathParser
Inheritance | luya\admin\openapi\BasePathParser |
---|---|
Subclasses | luya\admin\openapi\ActionRouteParser, luya\admin\openapi\UrlRuleRouteParser |
Available since version | 3.2.0 |
Source Code | https://github.com/luyadev/luya-module-admin/blob/master/src/openapi/BasePathParser.php |
Base Class to convert Data into Paths.
Terminology:
- Absolute Route: admin/user/index or admin/api-cms-admin/create
- Controller Map Route: admin/api-cms-admin or admin/api-cms-nav
Public Methods
Method | Description | Defined By |
---|---|---|
generateOperationId() | Generate a readable operation id for current route and verb. | luya\admin\openapi\BasePathParser |
getPath() | Returns the path which should be associated with this endpoint. | luya\admin\openapi\BasePathParser |
getPathItem() | Return a PathItem. | luya\admin\openapi\BasePathParser |
isValid() | Whether this Parser is valid or not. | luya\admin\openapi\BasePathParser |
normalizeTag() | Generate a normalized tag from a given route. | luya\admin\openapi\BasePathParser |
routes() | Returns all absolute controller map routes which are covered by this parser. | luya\admin\openapi\BasePathParser |
Method Details
Generate a readable operation id for current route and verb.
public string generateOperationId ( $verb ) | ||
$verb | string |
public function generateOperationId($verb)
{
$path = ltrim(str_replace(["admin/api-", "admin/api", "admin/"], '', $this->getPath()), '/');
$operation = $verb . '-'. str_replace("/", " ", $path); // replace slashes with newlines
$camelCase = Inflector::slug($operation, '-', true, false);
return Generator::generateUniqueOperationId(Inflector::id2camel($camelCase));
}
Returns the path which should be associated with this endpoint.
This is the actual route which then recieves the request.
public abstract string getPath ( ) |
abstract public function getPath(): string;
Return a PathItem.
A PathItem represents a path within the openapi definition. A path (or maybe also named as endpoint/route) can have multiple verbs. Like post, get, put
public abstract \cebe\openapi\spec\PathItem getPathItem ( ) |
abstract public function getPathItem(): PathItem;
Whether this Parser is valid or not.
public abstract boolean isValid ( ) |
abstract public function isValid(): bool;
Generate a normalized tag from a given route.
public string normalizeTag ( $route ) | ||
$route | string |
public function normalizeTag($route)
{
$route = str_replace(["admin/"], '', $route);
return ltrim(trim($route, '/'));
}