Sunday, 21 February 2021 05:42

ABAP OpenAPI Client Generation in ABAP

Written by Lars Hvam
Rate this item
(0 votes)
“© 2020. SAP SE or an SAP affiliate company. All rights reserved.” “Used with permission of SAP SE”

The OpenAPI specification is a way to formally describe the services exposed by REST endpoints. To enforce design by contract(APIs), the specification is typically automatically turned into code in the client system, so the boring parts are hidden from the application developer, and the syntax checker can help to remind the developer when the contract is changed.

This client generation has long been a missing part in the ABAP ecosystem, and I’m happy to announce abap-openapi-client which is an open source OpenAPI client generator in ABAP ?

Why ABAP?

Both the code generation and the actual client code is ABAP. The code generation could have been in a different language, but to encourage ABAP developers to help with the ABAP generation, I find it important to have the generation in the same language.

Much of the code is just simple concatenation, which all(?) ABAP developers can help to evolve,

LOOP AT ms_specification-operations INTO ls_operation WHERE deprecated = abap_false. rv_abap = rv_abap && | METHOD { ms_input-interface_name }~{ ls_operation-abap_name }.\n| && operation_implementation( ls_operation ) && | ENDMETHOD.\n\n|. ENDLOOP.

Another feature is to run the client generation in the browser! I.e. the client generation code does not require installation into an ABAP system to run,

This works by transpiling the ABAP code to JavaScript.

CI/CD Setup

The code is hosted on GitHub, and employs a full Continuous Integration setup, each change triggers static analysis via abaplint, and unit tests are run via the transpiler, this will help to make safe changes in the codebase.

As a Continous Delivery example, GitHub provides specifications for all its endpoints, and the generated ABAP client code is automatically updated daily at https://github.com/abap-openapi/generated-github

Open Source

The code is open source under the MIT license. Expect bugs as multiple OpenAPI parts are not implemented yet, and ABAP is a funky language ? With the CI setup, it can all be fixed, one bug at a time.

Bug reports/comments/feature requests welcome on https://github.com/abap-openapi/abap-openapi-client

Read 25 times

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.