View source | Discuss this page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Add page
Show collection (0 pages)
Collections help

Search

Module:OpenAPI

Contents

Introduction

This module allows to integrate in Openbravo APIs documented using the OpenAPI specification. It also provides the ability to visualize and interact with those APIs through Swagger-UI.

Bulbgraph.png   This feature is available starting from 3.0PR19Q3.
Bulbgraph.png   The OpenAPI module is intended for development purposes and therefore it should not be installed on productive environments.

API Generation

Defining the API

The steps to define an API are:

  1. Create a yaml file (.yml) file following the OpenAPI specification. See here for a detailed explanation of how to create the file.
  2. Place that file under a folder named api of your module.
Bulbgraph.png   It is recommended to follow this naming convention to avoid collisions when defining multiple APIs: modulepackage-apiname.yml.

See an API definition example here.

Setting the Openbravo server

One of the configuration properties of the OpenAPI specification file is the server which provides connectivity information to a target server that allows to interact with the API.

The OpenAPI module makes it possible to configure this property dynamically, so that it is set with the value of the context.url property of the Openbravo.properties file. This way we will be able to interact with the API using the Openbravo server itself. To define this setting in such way, the ${contextURL} placeholder should be used:

...
servers:
- url: ${contextURL}
...

That placeholder will be replaced with the context.url when deploying the API.

Deploying the API

The APIs are deployed at compile time. To deploy them, the following steps should be done:

  1. Move to the sourcepath/modules/org.openbravo.service.openapi module
  2. Run ant compile.api
  3. Go back to the sourcepath folder
  4. Run ant smartbuild

Visualizing the API

Once the APIs have been deployed, they can be visualized at the following URL:

http(s)://<openbravo_url>/api
API Visualization


A live example is available here.

Retrieved from "http://wiki.openbravo.com/wiki/Module:OpenAPI"

This page has been accessed 206 times. This page was last modified on 25 October 2019, at 08:08. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.