Build beautiful and interactive API documentation for ORDS

Image
In this blog post, I will show you how to quickly build beautiful and interactive API documentation for your Oracle APEX REST data sources using  swagger hub . Using APEX v23.1. I downloaded the  titanic data set  and loaded them into tables in my APEX instance, created some authorized restful services and published them using swagger hub. You can create a free account on swagger hub.   Check out my titanic swagger hub here ; Press Authorize. Username REST, password Glasgow123! I won't go through creating RESTful services and just show you the four I created that sit on top of the titanic data set; The GET is a very simple SQL query;      select * from TITANIC_DATA_SET_NEW A handy tip is to add comments, as there will appear on swagger hub, making your API self documenting; Once you have created your modules, press the Generate Swagger Doc button; This will generate an open API for you.  Copy the API and paste it into swagger hub This will generate the documentation; As mentioned b

APEX Office Print

This post is how we used APEX Office Print (AOP) in the University of Glasgow in Scotland to print APEX forms and loved it 😃

The app

The application is a Performance Development Review (PDR) APEX application for staff at the University of Glasgow.  There are 7,000 staff and several different forms depending on the staff role.  A professor will get a different form to a Janitor for example.

CSS Print

Our first attempt at printing was using a print style sheet.  This worked to a certain extent but we had major issues printing Interactive Grids and you dont have a great deal of control over what gets printed especially as we had several different APEX forms.

Apex Office Print to the rescue

We purchased AOP on-prem bronze  and its paid for itself in the year we have been using it as we have went from dozens of print queries where we were constantly updating our print CSS to zero queries (yes zero!!!).  The resulting word documents the users now download are also much more professional looking than a CSS print.

Installation

AOP runs on its own server in the University.  You then have to install the plugins in your APEX environment. Both were easy to install and it comes with good documentation.

SQL

First thing we did was create the SQL that would include all the form data we want to print. Here is a snippet where we get individual form items and row data that appears in interactive grids on the form.  In this example its research publications that staff have published;

to_char(start_date,'DD-MM-YYYY') "start_date",
(select forename||' '||surname from core_person where GUID=:P0_APPLICATION_USER) "pdr_person",
cursor(select title "title", authors "authors", year "year"
from EPRINT_PDR_PUBLICATIONS where GUID=:P0_APPLICATION_USER and SELECTED='Y'
) "publications",

A really neat feature of the AOP plugin is it allows you to send the results out as a template by choosing template type "AOP Template".  This is a really good starting position as the resulting word template gives you all the tags produced by AOP from your SQL.

Forms

Using the generated word template which has all the tags, we created a word form for each PDR form and uploaded them to static applkication files.

We then created a page zero item called P0_AOP_FILENAME to hold the AOP template name depending on which from the staff member is assigned.

When the user opens the form page in APEX we know which type of form the user has been assigned. 

We created a PL/SQL process in "pre rendering after header" in the form page to set P0_AOP_FILENAME.  We know the type of form using another item P0_ACTIVE_PDR_FORM_ID and append this to the P0_AOP_FILENAME item;

:P0_AOP_FILENAME := 'aop/1921/AOP_TEMPLATE_PDR_APPLICATION_FORM_' || :P0_ACTIVE_PDR_FORM_ID || '.docx';
We then use P0_AOP_FILENAME in AOP dynamic action settings;


Take aways

Dont use CSS print.  It eneded up causing us all sorts of unforseen issues.

AOP is a solid piece of software, the server has been running for over a year and has never had to be restarted.  This is quite amazing in itself.

We handed over the word templates to the project sponsor which is the Universities Human Resources department who are not technical and now make changes to the templates (leaving the tags). They make any changes and we load them back into static application files.

AOP support is really good.  Answered all our queries quickly.

7,000 staff using this application and at peak times we get around 400 print requests a day and not one issue reported.

Now getting used in several projects, all using the same templates so all project prints have the same look and feel.

Minor point's

Not that many articles on AOP on Google (thats why I posted this) so its a wee bit of a learning curve although not too bad, but its worth it as its a great piece of software and highly configurable.

Everybody loves it and now want excel prints.  Excel does not come in the bronze license. You need to purchase the silver license for $8,000. Working on HR...lol







Comments

Popular posts from this blog

Oracle APEX Interactive Grid colour cells based on a condition using JavaScript and CSS

Oracle APEX pretty checkbox item plugin

Build beautiful and interactive API documentation for ORDS