2017 © Pedro Peláez
 

project api-builder

Implementation of the API Builder for OPENI

image

openi-ict/api-builder

Implementation of the API Builder for OPENI

  • Thursday, July 9, 2015
  • by romdim
  • Repository
  • 12 Watchers
  • 2 Stars
  • 0 Installations
  • CSS
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

OPENi API Builder

OPENi API Builder is a web project that allows developers to add Objects and combine methods for use with the official OPENi API Framework., (*1)

Latest Stable Version Build Status, (*2)

DIRECTORY STRUCTURE

  .docs/              contains Documents for building the API Builder (mockups etc.)
  assets/             contains assets definition
  commands/           contains console commands (controllers)
  config/             contains application configurations
  controllers/        contains Web controller classes
  mail/               contains view files for e-mails
  migrations/         contains migrations for the database to be configured automatically
  models/             contains model classes
  runtime/            contains files generated during runtime
  tests/              contains various tests for the basic application (not yet fully charged)
  vendor/             contains dependent 3rd-party packages
  views/              contains view files for the Web application
  web/                contains the entry script and Web resources
  widgets/            contains additional widgets used in this app

REQUIREMENTS

The minimum requirement by this application template that your Web server supports PHP 5.4.0. Additional packages required are marked in the composer.json file., (*3)

INSTALLATION

Download the latest release or the zipped master source code from api-builder into a directory named api-builder that is directly under the Web root., (*4)

Run a command prompt in that directory and type:, (*5)

composer global require "fxp/composer-asset-plugin:1.0.0"
composer install

NOTE: If you do not have Composer, you may install it by following the instructions at getcomposer.org., (*6)

This will fetch all the required packages and save them in your vendor folder., (*7)

You can then access the application through the following URL:, (*8)

http://localhost/api-builder/web/

NOTE: For having recommendation features in the API views, Elasticsearch should be installed from here., (*9)

CONFIGURATION

Database

Create a file config/db.php with real data, for example:, (*10)

return [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=localhost;dbname=apiBuilder',
    'username' => 'root',
    'password' => '1234',
    'charset' => 'utf8',
];

Or rename the dbSample.php with your actual data., (*11)

Then, open a terminal and run, (*12)

yii migrate

to make all the tables in the database., (*13)

Also check and edit the other files in the config/ directory to customize your application. If your website is different than http://localhost/api-builder/ , you need to update the url property of the js file in /web/js/swagger/site.js ., (*14)

At last, you need to rename the /web/indexSample.php to /web/index.php for the application to work and comment out the environment lines if you are in production environment., (*15)

Elasticsearch

This request should be made to create the 'api-builder' index:, (*16)

curl -XPUT http://127.0.0.1:9200/api-builder
curl -XPOST http://127.0.0.1:9200/api-builder/_close

Recommended setting setup:, (*17)

curl -XPUT 'http://127.0.0.1:9200/api-builder/_settings' -d 
'{
     "settings": {
         "index": {
             "analysis": {
                 "filter": {
                     "stem_filter": {
                         "type": "stemmer",
                         "name": "english"
                     },
                     "low_filter": {
                         "type": "lowercase"
                     },
                     "synonym_filter": {
                         "type": "synonym",
                         "synonyms_path": "analysis/synonyms.txt"
                     },
                     "stop_filter": {
                         "type": "stop",
                         "stopwords_path": "analysis/stopwords.txt"
                     }
                 },
                 "analyzer": {
                     "analyzer": {
                         "type": "custom",
                         "tokenizer": "standard",
                         "filter": [
                             "low_filter",
                             "synonym_filter",
                             "stop_filter",
                             "stem_filter"
                         ],
                         "char_filter": [
                             "html_strip"
                         ]
                     }
                 }
             }
         }
     }
 }'

NOTE: This of course implies that you have a synonyms and stopwords texts in your elasticsearch/config/analysis/ folder. Samples can be found at the root folder of the project., (*18)

curl -XPUT 'http://127.0.0.1:9200/api-builder/api/_mapping' -d 
'{ 
     "api": { 
         "properties": { 
             "objects": { 
                 "type": "nested", 
                 "properties": { 
                     "name": { 
                         "type": "string", 
                         "index": "analyzed", 
                         "analyzer": "analyzer"
                     }, 
                     "description": { 
                         "type": "string", 
                         "index": "analyzed", 
                         "analyzer": "analyzer" 
                     }, 
                     "properties": { 
                         "type": "nested", 
                         "properties": { 
                             "name": { 
                                 "type": "string", 
                                 "index": "analyzed", 
                         "analyzer": "analyzer"
                             }, 
                             "type": { 
                                 "type": "string", 
                                 "index": "not_analyzed" 
                             } 
                         } 
                     } 
                 } 
             } 
         } 
     } 
 }'
 ```

 ```
 curl -XPOST http://127.0.0.1:9200/api-builder/_open

TECH STACK USED FOR DEVELOPMENT - MANY THANKS!

yii 2, (*19)

composer, (*20)

bootstrap, (*21)

bootstrap-material-design, (*22)

Krajee Yii Extensions, (*23)

Elasticsearch, (*24)

The Versions