Background
Break News
How to add local font to Tailwind Css and NextJS? - Tutorial Design Pattern? - Blockchain Technology, How to create own Bitcoin virtual currency - Zustand mordern management state - Design Pattern - Flyweight Pattern? - Docker Full training Topic

[Solved] How to setup Swagger for CakePHP 4+

Friday 14 April 2023
|
Read: Completed in minutes

[Solved] How to setup Swagger for CakePHP 4+

As you see the title. Topic today will focus on How to setup Swagger in CakePHP 4.0+.

What is Swagger?

✋✋✋✋✋Hello everyone, Welcome to Learn Tech Tips Webzone, I am Zidane,

Swagger is an open-source set of rules, specifications, and tools for developing and describing RESTful APIs 2. It allows developers to create interactive, machine and human-readable API documentation 3. Swagger is a specification for building APIs that allows developers to describe their APIs in a standard format 5. It is both machine-readable and human-readable 3. Swagger can be used to share documentation among product managers, testers, and developers 3 [From BingAI] 

So if intergrated with swagger, we will have area for check api swagger

Here is the link vendor

https://github.com/alt3/cakephp-swagger

 

First of it you should run this 

composer require alt3/cakephp-swagger

Enable the plugin in the bootstrap() method found in src/Application.php:


public function bootstrap(): void
    {
        $this->addPlugin('CsvView');

        // Call parent to load bootstrap from files.
        parent::bootstrap(); 

        $this->addPlugin('Alt3/Swagger');
    }

Congratulation, you have swagger docs

localhost/ecpark-portal/swagger/docs/api

How to setup Swagger for CakePHP 4+ - Zidane - Webzone Tech Tips

If you want to show above information, you should fill below information like this.


    /**
        @SWG\Swagger(
            @SWG\Info(
                title="Ecpark",
                description="Ecpark API",
                termsOfService="https://swagger.io/terms/",
                version="1.0.0"
            )
        )

        @SWG\Get(
            path="/ecpark-portal/api/v1/districts/getList.json",
            summary="Retrieve a list of districts",
            tags={"Districts"},
            consumes={"application/json"},
            produces={"application/json"},
            @SWG\Parameter(
                name="language",
                description="This fields is language: zh_HK",
                in="query",
                required=true,
                type="string"
            ),
            @SWG\Parameter(
                name="region_id",
                description="region id",
                in="query",
                required=true,
                type="number"
            ),
            @SWG\Response(
                response="200",
                description="Successful operation",
                @SWG\Schema(
                    type="object",
                    ref="#/definitions/Result"
                )
            ),
            @SWG\Response(
                response=429,
                description="Rate Limit Exceeded"
            )
        )

        @SWG\Definition(
            definition="Result",
            required={"name", "description"},
            @SWG\Property(
                property="status",
                type="integer",
                description="Response status"
            ),
            @SWG\Property(
                property="message",
                type="string",
                description="Response message"
            ),
            @SWG\Property(
                property="params",
                type="object",
                description="Params object"
            )
        )
    */



Some useful link

https://localhost/ecpark-portal/swagger#/ -> show all api here

https://localhost/ecpark-portal/swagger/docs/api => for debug if you fetch swagger link cannot load

Here is my another channel welcome to checkin up

 
 
You can check source code on my above video with CSS Transform, is it easy to use? Love you all :)
Thanks for reading. Any feedback and questions about How to use CSS Transform Leave your comment on below post, we can discuss about it.
✋✋✋✋ Webzone tech Tips - I am Zidane, See you next time



 

 




🙇🏼 We Appreciate Your Comments and Suggestions - Webzone - all things Tech Tips web development 🙇🏼
Popular Webzone Tech Tips topic maybe you will be like it - by Webzone Tech Tips - Zidane
As a student, I found Blogspot very useful when I joined in 2014. I have been a developer for years . To give back and share what I learned, I started Webzone, a blog with tech tips. You can also search for tech tips zidane on Google and find my helpful posts. Love you all,

I am glad you visited my blog. I hope you find it useful for learning tech tips and webzone tricks. If you have any technical issues, feel free to browse my posts and see if they can help you solve them. You can also leave a comment or contact me if you need more assistance. Here is my blog address: https://learn-tech-tips.blogspot.com.

My blog where I share my passion for web development, webzone design, and tech tips. You will find tutorials on how to build websites from scratch, using hot trends frameworks like nestjs, nextjs, cakephp, devops, docker, and more. You will also learn how to fix common bugs on development, like a mini stackoverflow. Plus, you will discover how to easily learn programming languages such as PHP (CAKEPHP, LARAVEL), C#, C++, Web(HTML, CSS, javascript), and other useful things like Office (Excel, Photoshop). I hope you enjoy my blog and find it helpful for your projects. :)

Thanks and Best Regards!
Follow me on Tiktok @learntechtips and send me a direct message. I will be happy to chat with you.
Webzone - Zidane (huuvi168@gmail.com)
I'm developer, I like code, I like to learn new technology and want to be friend with people for learn each other
I'm a developer who loves coding, learning new technologies, and making friends with people who share the same passion. I have been a full stack developer since 2015, with more than years of experience in web development.
Copyright @2022(November) Version 1.0.0 - By Webzone, all things Tech Tips for Web Development Zidane
https://learn-tech-tips.blogspot.com