Forum OpenACS Development: OpenAPI generated from ad_proc

Posted by Malte Sussdorff on
As I mentioned I have written some code which allows for auto generation of OpenAPI Calls based of ad_proc documentation.

The idea is that you use ad_proc to define the endpoint and the objects to be used in the endpoint and let the openapi generator then generate the OpenAPI code and use that e.g. in SwaggerUI to access the endpoint.

If someone is interested I am more than willing to give a demo to get feedback what I actually need to do in order to export the code for use as an OpenACS Package by others.

To give you an idea, here is an example

namespace eval cog_rest::json_object {
    ad_proc -public search_result {} {
        @return object json_object cognovis_object The object of the search result
        @return search_text string Text we display for the search result
        @return actions json_array webix_notification_action Actions for  the notification
        @return sort_order integer order by which to order the search result
    } -

ad_proc cog_rest::get::webix_search {
    {-object_type ""}
} {
    @param query string String which we are querying for

    @return search_results json_array search_result Results which match the query and for which the current user has access
} {
    set query [string tolower $query]
    regsub -all {["']} $query {} query

    # Remove accents and other special characters from search query
    # set query [db_exec_plsql normalize "select norm_text(:query)"]

    set search_results [list]

    if {$object_type eq ""} {
        set object_types [list "im_project" "im_company" "person" "im_invoice"]
    } else {
        set object_types $object_type
    foreach object_type $object_types {
        set search_results [concat $search_results [webix::search::${object_type} -query $query -rest_user_id $rest_user_id]]

    return [cog_rest::json_response]

Posted by Iuri Sampaio on
Hello Malte,
If you're willing to give, I'm certainly open to receive such a generous learning offer!
Haven't you thought about going to Viena and presenting it there?
They'd have filmed and streamed the whole event.
Unfortunately, today was the last day of the conference.
Best wishes,
Posted by Neophytos Demetriou on
Hi Malte, I have a half-baked OpenAPI renderer in React. It produces docs for the endpoints. Let me know if you have any use for it and I'll figure out a way to share it e.g. in file storage.
Posted by Gustaf Neumann on
We also made a couple of implementations towards OpenAPI, so collecting such approaches in e.g. the file storage seems like a good idea.

Concerning fully automated approaches (e.g. based on the object-model of OpenACS or the public API), one is exporting more details than desired. The mongoDB interface has the notion of embedding vs. linking complex structures, is designed for different renderers etc. So, there are quite a few ingredients out there.

Posted by Brian Fenton on

we may be interested in OpenAPI/Swagger too in the near future, and would love to hear ideas and experiences that people have had with OpenACS.