Closed rudy1976s closed 8 months ago
Can you format this report better? Use triple ticks and specify the language. I fixed one for you so you have an example.
Next can you specify what versions of stuff you are using such as PHP, CakePHP and this library?
When you say the swagger page is loading. Are the routes you expect to be there appearing?
Closing due to lack of feedback.
We have an application based on plugins. We followed the guide and creating a dedicated swagger_bake.php located in the plugin config folder. Here there is the sample code :
we have set up the XMl as follows :
` openapi: "3.0.0" info: version: 2.5.* title: Acme/Blog Api description: | Acme CMS Blog API license: name: MIT License paths: '/api-blog/posts/': get: summary: Index method description: 'This shows using the definitions from YML instead of reading from your cake routes and models. YML definitions take precedence over cake routes and models.' tags:
/examples/api-key-example
for demo/example. type: apiKey in: header name: API-KEY schemas: Exception: type: object properties: code: type: integer example: 500 url: type: string example: /url/path message: type: string example: Internal Error xml: name: response OperationResult: type: object properties: result: type: boolean message: type: string xml: name: response Posts: type: array items: $ref: '#/components/schemas/Post' Post: description: 'Post object' type: object properties: id: type: integer readOnly: true name: type: string example: 'countries' `We have generated the json with the appropriate command.
We have generated routes for the controller we need to manage as follows :
` $routes->scope('/api-blog', function (RouteBuilder $builder) { (new AutoRouter($builder, new ResourceScanner('Acme\Blog')))->buildResources();
});
`
Then we have created a controller with only two actions as mapped in the routes :
` declare(strict_types=1);
namespace Acme\Blog\Controller;
use Acme\Blog\Model\Entity\Post; use Acme\Blog\Model\Table\PostsTable; use Cake\Datasource\Exception\RecordNotFoundException; use Cake\Http\Exception\MethodNotAllowedException; use MixerApi\Crud\Interfaces\ReadInterface; use MixerApi\Crud\Interfaces\SearchInterface; use SwaggerBake\Lib\Attribute\OpenApiPaginator; use SwaggerBake\Lib\Extension\CakeSearch\Attribute\OpenApiSearch;
/**
@method Post[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = []) */ class PostsController extends AppController { public function initialize(): void { parent::initialize(); $this->loadComponent('Search.Search', [ 'actions' => ['index'], ]); } /**
[OpenApiPaginator]
[OpenApiSearch(tableClass:PostsTable::class)]
public function index(SearchInterface $search): void { $this->set('data', $this->paginate($search->query($this))); }
/**
`
The swagger pages is visible, but actually the controller is always asking for view template missing , while it should not do, because we should dealing with restful routes. ( the base controller has request handler component loaded ) I think we miss something but after several trying we are unable to come though. We tried to download and run the mixerapi project ( to check something working) but the docker is not working ( I have opened a ticket for that yesterday ). I know this topic is complicated , but we are stuck, could you please help us understanding what is wrong with our implementation ?
Thank you in advance
Rudy