WaveMaker Docs

WaveMaker Docs

  • Get started
  • Widgets
  • How-to
  • Enterprise
  • Releases
  • Blog
  • Sign-in

›All Blog Posts

All Blog Posts

  • Understanding Scaling of WaveMaker Applications
  • Automatically Import your Website Branding Styles into a Theme
  • Certificate Pinning Case Study
  • Cordova 10.0.0 Upgrade
  • WaveMaker Releases 10.6 Version
  • Retain UI State in WaveMaker Apps
  • Theme builder is ready with a new update
  • PostgREST OpenAPI support in WaveMaker
  • Fully automated and scalable test execution using k8s
  • New file picker for mobile apps - Improvements in UI to select files in mobile
  • WaveMaker releases 10.5 version
  • Deliver faster applications with WaveMaker!
  • GraphQL in a Micro Services Architecture
  • Build Themes for WaveMaker Apps Without Any Coding
  • COVID-19 Visualization using WaveMaker - Part 2
  • COVID-19 Visualization using WaveMaker - Part 1
  • WaveMaker Integrates with DigitalOcean Kubernetes for App Deployments
  • Deployment Experience made better!
  • OpenAPI support in WaveMaker
  • WaveMaker platform is updated to use WKWebView.
  • Deliver WaveMaker Apps as Micro Frontend modules
  • All-new WaveMaker docs with a powerful Search
  • Welcome to the WaveMaker Developers Blog

PostgREST OpenAPI support in WaveMaker

July 1, 2020

Nikhilesh K V

WaveMaker has added support for importing API that are documented using OpenAPIs, Swagger specification in 10.4. However building a robust OpenAPI support is very important as different API while using OpenAPI/Swagger document their endpoints in subtly different ways. We tried importing OpenAPI documents from different API sources. One such example is when we tested an OpenAPI document generated through PostgREST. In this blog we'll discuss what changes we have made in 10.5 in order to support OpenAPI documents generated from such sources.

OpenApi

Introduction to PostgREST

PostgREST is a standalone web server that turns your PostgreSQL database directly into a RESTful API. The structural constraints and permissions in the database determine the API endpoints and operations.

Structure of PostgREST generated OpenAPI Documents

Generally, the structure of an OpenAPI document generated out of a Spring/Node etc app looks like this.

   {
       "paths":{
           "/employees":{
               "post":{
                   "parameters":[
                       {
                           "in":"body",
                           "name":"employee",
                           "description":"employee",
                           "required":true,
                           "schema":{
                                "$ref":"#/definitions/Employee"
                           }
                       },
                       {
                           "in":"header",
                           "name":"Prefer",
                           "description":"Preference",
                           "required":false,                           
                           "type":"string"
                       }
                   ]

               }
           }
       },
       "definitions":{
           "Employee":{
               "type":"object",
               "properties":{
                   "empId":{
                        "type":"string"
                   },
                   "empName":{
                        "type":"string"
                   }
               },
               "title":"Employee"
           }
       }
   }

The above document indicates that the POST API expects an employee parameter of the type Employee in body and a Prefer parameter in header, therefore expecting the below parameters:

  • Prefer in header
  • empId and empName in Request Body

Now let us see an OpenAPI document generated out of PostgREST.

{
    "paths":{
        "/employees":{
            "post":{
                "parameters":[
                    {
                        "$ref":"#/parameters/body.employee"
                    },
                    {
                        "$ref":"#/parameters/preferReturn"
                    }
                ]
            }
        }
    },
    "definitions":{
        "Employee": {
            "type": "object",
            "properties": {
                "empId":{
                    "type":"string"
                },
                "empName":{
                    "type":"string"
                }
            }            
        }
    },
    "parameters":{
        "preferReturn":{
            "in":"header",
            "name":"Prefer",
            "description":"Preference",
            "required":false,
            "type":"string"
        },
        "body.employee":{
            "in":"body",
            "name":"employee",
            "description":"employee",
            "required":true,
            "schema":{
                "$ref":"#/definitions/employee"
            }            
        }
    }
}

Not only does WaveMaker allow importing of the REST API, but by parsing the entity definitions we generate user interface that handles create, read, update, delete of the entities. WaveMaker form generates form fields corresponding to the entity definition in the OpenAPI documentation.

If you have a look at the request parameters for the POST API, you can see that they are references to a different object in the document. So we will have to parse these parameters from the root level parameters object. On having a closer look at the body.employee parameter, we see that it is of the type Employee. We will have to parse its properties from the root level definitions object. By parsing these, we identify that the API expects the below parameters:

  • Prefer in header
  • empId and empName in Request Body

Since we did not have this kind of parsing logic in 10.4, we were unable to extract the form fields on dragging a Form widget for Employee Entity.

This feature is part of WaveMaker 10.5 release. Checkout more details on what is included in this release.

Conclusion

The OpenAPI support in WaveMaker has been around for few months now and with this release we are making this more robust. Our target is to be able to import API from varied sources so that our users can quickly build out web, mobile applications. We would love to hear from you, if you have tried this feature out. Write to us at info@wavemaker.com.

Tweet
Recent Posts
  • Introduction to PostgREST
  • Structure of PostgREST generated OpenAPI Documents
  • Conclusion
WaveMaker
  • PRICING
  • PARTNERS
  • CUSTOMERS
  • ABOUT US
  • CONTACT US
Terms of Use | Copyright © 2013-2021 WaveMaker, Inc. All rights reserved.