ABAP-Swagger
An approach to expose ABAP REST services
一种公开 ABAP REST 服务的方法
Usage
1: develop a class in ABAP with public methods
2: implement interface ZIF_SWAG_HANDLER, and register the public methods(example method zif_swag_handler~meta)
3: the methods are now accessible via rest(example)
4: the Swagger UI can be accessed via swagger.html
in the base dir of the REST services
Installing and Requirements
Install via abapGit
Requires native JSON support see ABAP and JSON - SAP Community or SAP note 1648418
CLASS zcl_swag_example DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_http_extension.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS ZCL_SWAG_EXAMPLE IMPLEMENTATION.
METHOD if_http_extension~handle_request.
DATA: lo_swag TYPE REF TO zcl_swag,
lo_handler TYPE REF TO zcl_swag_example_handler.
CREATE OBJECT lo_swag
EXPORTING
ii_server = server
iv_title = 'Example'
iv_base = '/zswag'. " <=== Adapt to your SICF path
CREATE OBJECT lo_handler.
lo_swag->register( lo_handler ).
lo_swag->run( ).
ENDMETHOD.
ENDCLASS.