Coder Social home page Coder Social logo

apibundle's Introduction

ONGR Api Bundle

Api Bundle allows rapid setup of RESTful API to simplify Elasticsearch data access for the remote clients.

Build Status

Documentation

The source of the documentation is stored in the Resources/doc/ folder in this bundle.

Read the API Bundle Documentation

Setup the bundle

This example assumes that you already have configured Elasticsearch bundle. If you haven't, here's a quick setup guide on how to do it.

Step 1: Install

Api bundle is installed using Composer.

composer require ongr/api-bundle "~1.0"

Step 2: Enable bundle in the AppKernel

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new JMS\SerializerBundle\JMSSerializerBundle(),
        new ONGR\ElasticsearchBundle\ONGRElasticsearchBundle(),
        new ONGR\ApiBundle\ONGRApiBundle(),
    );
}

API Bundle requires JMS Serializer to work with JSON and XML

Step 3: Add configuration

Add minimal configuration for Api bundle to the config.yml.

#app/config/config.yml

ongr_api:
    default_encoding: json
        versions:
            v3:
                endpoints:
                    product:
                        repository: es.manager.default.product

The example above shows a minimal configuration. To learn more take a look at the configuration page.

Add routing

#app/config/routing.yml

ongr_api_routing:
    resource: @ONGRApiBundle/Resources/config/routing.yml
    prefix: /api

You can specify prefix like you want, api is only the example.

Step 4: That's it

Its ready to use. API Bundle will generate new url endpoints by your configuration, by previous configuration you will have: <yourdomain.com>/api/v3/product

What's next ?

Head to configuration page to learn how to get most of your API or take a look at the basic usage example

License

This bundle is covered by the MIT license. Please see the complete license in the bundle LICENSE file.

apibundle's People

Contributors

andriusbil avatar einorler avatar grandltu avatar mvar avatar saimaz avatar tomaspocevicius avatar trandangtri avatar trylika avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apibundle's Issues

Write functional tests

We need to test:

  • Multiple versions
  • Custom controller
  • Parent handling for endpoint
  • Parent handling for version
  • Config tree

Make sure correct routes are generated from the config in DI Extension

Look at the configuration docs: https://github.com/ongr-io/ApiBundle/blob/9610b53ea5bc7dd3390b4be27e7a94452a3e4cb8/Resources/doc/configuration.md

Say we have:

ongr_api:
   output_format: json
   version_in_url: true
   versions:
       v3:
           endpoints:
               person:
                   repository: es.manager.default.person
                   allow_extra_fields: false
                   allow_get_all: true

Routes we expect to have generated dynamicaly:
/api/v1/person POST
/api/v1/person/{id} PUT
/api/v1/person/{id} GET
/api/v1/person/_all GET
/api/v1/person/{id} DELETE
/api/v1/person/_batch POST

Routes must be pointed to specific RestController action.

There is a need to import object variations for specific endpoint

Basicaly it means there is a need to support relations for any document. I'm not so sure if that is reasonable to support it natively in API bundle. It's too complex to be tied to a products or some other domain. Curently we are trying to make it more universal version where we can provide an easy way to use Restful API for elasticsearch.

Remove symfony forms dependency

Forms now are used for validate documents. Exchange it with symfony/validator or something more reliable. Symfony forms IMO is worst choice.

Ability to run batch in background

Response should be sent immediately regarding if batch is complete or not. Status code should be 202.

It could be useful if request is large.

Add ?pretty

Could we add the pretty parameter to format the output. That would be very helpful for debugging.

Batch processor

Should handle batch api, provide user friendly error handling.

  • Should use rest controller for handling requests. (don't forward requests, low performance)
  • User Friendly errors

Remove Collection controllers

Remove: AbstractCollectionController, CollectionController, CollectionControllerInterface

We will create for _batch and _all standalone controllers.

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.