Giter Club home page Giter Club logo

easyapi's Introduction

easyAPI

What is easyAPI?

easyAPI is skeleton REST API application and integrated with swagger to generate documentation API. With easyAPI you can generate REST API less than 5 minutes.

Installation & setup

  • clone this repository git clone https://github.com/pandigresik/easyAPI.git
  • cd easyAPI
  • composer install to install dependency this application
  • change your secret key in app/Config/Services.php on line 22
  • php spark serve to run this application, default you can open this address http://localhost:8080 on your browser
  • Copy env to .env and tailor for your app, specifically the baseURL and any database settings.

Generate REST API

  • php spark api:generate after that, system will ask you table name will generate that REST API. We can choose one table or all, if we want generate all write all or write one table name exist in your database If there is no error, system will generate for you controller, model and entity file.
  • Last you must add new route will display in last command to app/Config/Routes.php.
  • Generate api.yaml using command ./vendor/bin/openapi -o ./public/assets/api.yaml ./app to show API docs using swagger using datasource format yaml (default)
  • Generate api.json using command ./vendor/bin/openapi -o ./public/assets/api.json ./app to show API docs using swagger using datasource format json (optional)
  • Open API documentation in http://localhost:8080/swagger

Example case

  • join with other table, you can look at ArtikelKategoriModel.php
  • example parameter in swagger for order data {"order":[{"id":"desc"},{"tgl_upload":"asc"}]}
  • example parameter in swagger for search data {"search":[{"id_kategori":1}]}
  • example parameter in swagger for search range data {"search":[{"tgl_upload":{"start":"2016-01-01", "end":"2020-01-01"} }]}
  • example parameter in swagger for search using like {"search":[{"judul":"membangun%25"}]} or {"search":[{"judul":"%25membangun%25"}]} use %25 not % you can place %25 on before, after and combination before and after as your keyword to search data
  • search data based on column name {base_url}/artikels?search[id_kategori]=1
  • order data based on column name {base_url}/artikels?order[id]=desc&order[tgl_upload]=asc
  • search and order data based on column name {base_url}/artikels?search[id_kategori]=1&order[id]=desc&order[tgl_upload]=asc
  • search with pagination {base_url}/artikels?page=1&limit=10
  • search and order with pagination {base_url}/artikels?search[id_kategori]=1&order[id]=desc&order[tgl_upload]=asc&page=1&limit=10
  • search using between operator if we want filter data based range of date or etc {base_url}/artikels?search[tgl_upload][start]=2016-01-01&search[tgl_upload][end]=2020-01-01
  • search using keyword {base_url}/artikels?search[judul]=membangun%25 or {base_url}/artikels?search[judul]=%25membangun%25 will produce like operator on query

Video demo installation

Install easyAPI

Video swagger documentation generate by easyAPI

Test swagger documentation generate by easyAPI

Preview

API Docs Preview

Todo

  • create example using this application

Copyright

easyApi dikembangkan dan dimaintain oleh asligresik

Lisensi

Lisensi dari easyApi adalah MIT License namun proyek yang dibangun menyeseuaikan dengan kebijakan masing-masing

easyapi's People

Contributors

pandigresik avatar dependabot[bot] avatar

Stargazers

Roman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.