Skip to content

Commit

Permalink
Update Client Generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Schmidt authored and Fabian Schmidt committed Oct 26, 2023
1 parent 47e1102 commit 8bb95d5
Show file tree
Hide file tree
Showing 5 changed files with 547 additions and 122 deletions.
16 changes: 9 additions & 7 deletions src/model/zcl_oapi_parser.clas.abap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CLASS zcl_oapi_parser DEFINITION PUBLIC.
PUBLIC SECTION.
METHODS parse
IMPORTING iv_json TYPE string
IMPORTING iv_json TYPE string
RETURNING VALUE(rs_schema) TYPE zif_oapi_specification_v3=>ty_specification.

PRIVATE SECTION.
Expand All @@ -14,30 +14,30 @@ CLASS zcl_oapi_parser DEFINITION PUBLIC.
RETURNING VALUE(rt_servers) TYPE zif_oapi_specification_v3=>ty_servers.

METHODS parse_parameters
IMPORTING iv_prefix TYPE string
IMPORTING iv_prefix TYPE string
RETURNING VALUE(rt_parameters) TYPE zif_oapi_specification_v3=>ty_parameters.

METHODS parse_parameters_ref
IMPORTING iv_prefix TYPE string
IMPORTING iv_prefix TYPE string
RETURNING VALUE(rt_parameters) TYPE string_table.

METHODS parse_responses
IMPORTING iv_prefix TYPE string
IMPORTING iv_prefix TYPE string
RETURNING VALUE(rt_responses) TYPE zif_oapi_specification_v3=>ty_responses.

METHODS parse_media_types
IMPORTING iv_prefix TYPE string
IMPORTING iv_prefix TYPE string
RETURNING VALUE(rt_media_types) TYPE zif_oapi_specification_v3=>ty_media_types.

METHODS parse_components
RETURNING VALUE(rs_components) TYPE zif_oapi_specification_v3=>ty_components.

METHODS parse_schema
IMPORTING iv_prefix TYPE string
IMPORTING iv_prefix TYPE string
RETURNING VALUE(ri_schema) TYPE REF TO zif_oapi_schema.

METHODS parse_schemas
IMPORTING iv_prefix TYPE string
IMPORTING iv_prefix TYPE string
RETURNING VALUE(rt_schemas) TYPE zif_oapi_specification_v3=>ty_schemas.

ENDCLASS.
Expand Down Expand Up @@ -145,6 +145,8 @@ CLASS zcl_oapi_parser IMPLEMENTATION.
LOOP AT lt_paths INTO lv_path.
CLEAR ls_operation.
ls_operation-path = lv_path.
ls_operation-path = replace( val = ls_operation-path regex = '\{[^}]*\}' with = space ).

lt_methods = mo_json->members( '/paths/' && lv_path && '/' ).
LOOP AT lt_methods INTO lv_method.
ls_operation-method = lv_method.
Expand Down
18 changes: 9 additions & 9 deletions src/model/zif_oapi_specification_v3.intf.abap
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ INTERFACE zif_oapi_specification_v3 PUBLIC.
TYPES ty_responses TYPE STANDARD TABLE OF ty_response WITH DEFAULT KEY.

TYPES: BEGIN OF ty_operation,
path TYPE string,
method TYPE string,
summary TYPE string,
description TYPE string,
operation_id TYPE string,
deprecated TYPE abap_bool,
abap_name TYPE string,
path TYPE string,
method TYPE string,
summary TYPE string,
description TYPE string,
operation_id TYPE string,
deprecated TYPE abap_bool,
abap_name TYPE string,
body_schema TYPE REF TO zif_oapi_schema,
body_schema_ref TYPE string,
parameters TYPE ty_parameters,
Expand Down Expand Up @@ -72,8 +72,8 @@ INTERFACE zif_oapi_specification_v3 PUBLIC.
END OF ty_components.

TYPES: BEGIN OF ty_info,
title TYPE string,
version TYPE string,
title TYPE string,
version TYPE string,
description TYPE string,
END OF ty_info.

Expand Down
42 changes: 42 additions & 0 deletions src/utils/zif_oapi_exit.intf.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
INTERFACE zif_oapi_exit
PUBLIC .

METHODS constructor_exit
IMPORTING
ii_client TYPE REF TO if_http_client.

METHODS before_send
IMPORTING
iv_path TYPE string
iv_operation_id TYPE string
iv_method TYPE string
ii_client TYPE REF TO if_http_client.

METHODS after_receive
IMPORTING
iv_path TYPE string
iv_operation_id TYPE string
iv_method TYPE string
ii_client TYPE REF TO if_http_client.

METHODS parse_response_to_abap
IMPORTING
iv_path TYPE string
iv_operation_id TYPE string
iv_method TYPE string
ii_client TYPE REF TO if_http_client
CHANGING
c_data TYPE data.

METHODS parse_body_to_data
IMPORTING
iv_path TYPE string
iv_operation_id TYPE string
iv_method TYPE string
ii_client TYPE REF TO if_http_client
i_body TYPE data
RETURNING
VALUE(rv_body_data) TYPE xstring.


ENDINTERFACE.
15 changes: 15 additions & 0 deletions src/utils/zif_oapi_exit.intf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_INTF" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VSEOINTERF>
<CLSNAME>ZIF_OAPI_EXIT</CLSNAME>
<LANGU>D</LANGU>
<DESCRIPT>OpenAPI Userexit</DESCRIPT>
<EXPOSURE>2</EXPOSURE>
<STATE>1</STATE>
<UNICODE>X</UNICODE>
</VSEOINTERF>
</asx:values>
</asx:abap>
</abapGit>
Loading

0 comments on commit 8bb95d5

Please sign in to comment.