Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Controller OpenAPI Documentation #968

Open
matjones opened this issue May 11, 2023 · 3 comments
Open

Custom Controller OpenAPI Documentation #968

matjones opened this issue May 11, 2023 · 3 comments
Assignees

Comments

@matjones
Copy link

matjones commented May 11, 2023

I had an expectation that if I created a custom controller, it would automatically get picked up in OpenAPI documentation. However I don't see my custom route listed when viewing the openapi route. Is there something I'm missing, or do they just not get documented.

Here is an example of my route:

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Tqdev\PhpCrudApi\Cache\Cache;
use Tqdev\PhpCrudApi\Column\ReflectionService;
use Tqdev\PhpCrudApi\Controller\Responder;
use Tqdev\PhpCrudApi\Database\GenericDB;
use Tqdev\PhpCrudApi\Middleware\Router\Router;

class CategoryDropdownController
{

	private $responder;

	public function __construct(Router $router, Responder $responder, GenericDB $db, ReflectionService $reflection, Cache $cache)
	{
		$router->register('GET', '/categorylist', array($this, 'getMyCustomQuery'));
		$this->responder = $responder;
		$this->db = $db;
	}

	public function getMyCustomQuery(ServerRequestInterface $request): ResponseInterface
	{
		$sql = "SELECT * from `categories`"; // Query is simplified for this example
		$pdo_statement = $this->db->pdo()->query($sql);
		$result = $pdo_statement->fetchAll();
		return $this->responder->success(['results' => $result]);
	}
}
@mevdschee
Copy link
Owner

mevdschee commented May 11, 2023

Is there something I'm missing, or do they just not get documented.

No, I'm sorry, customer routes are not automatically documented. Do anyone know how this documentation could be automated? I think it would be a great feature. I'm not sure it is feasible though..

@mevdschee mevdschee self-assigned this May 11, 2023
@matjones
Copy link
Author

No, I'm sorry, customer routes are not automatically documented. Do anyone know how this documentation could be automated? I think it would be a great feature. I'm not sure it is feasible though..

Thanks for the speedy response. It would be great if there was a way to achieve this too.

@Sparviero-Sughero
Copy link

No, I'm sorry, customer routes are not automatically documented. Do anyone know how this documentation could be automated? I think it would be a great feature. I'm not sure it is feasible though..

Thanks for the speedy response. It would be great if there was a way to achieve this too.

I have the same problem.
Did you solve it somehow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants