abap-openapi / abap-openapi

ABAP OpenAPI Client and Server generator in ABAP
https://abap-openapi.github.io/web-openapi-client/
MIT License
69 stars 8 forks source link

unused interface "body" parameter in client implementation #179

Open AndreaBorgia-Abo opened 4 days ago

AndreaBorgia-Abo commented 4 days ago

Using the web client I generated the code for Digiseal Web, with YAML file converted to JSON.

Code for the "start authentication" method is as follows:

  METHOD zif_interface~dswebcore_start_authenticati.
    DATA lv_code         TYPE i.
    DATA lv_message      TYPE string.
    DATA lv_uri          TYPE string.
    DATA ls_header       LIKE LINE OF mt_extra_headers.
    DATA lv_dummy        TYPE string.
    DATA lv_content_type TYPE string.

    mi_client->propertytype_logon_popup = if_http_client=>co_disabled.
    mi_client->request->set_method( 'POST' ).
    mi_client->request->set_compression( ).
    lv_uri = mv_uri_prefix && '/core/start_authentication'.
    cl_http_utility=>set_request_uri(
      request = mi_client->request
      uri     = lv_uri ).
    LOOP AT mt_extra_headers INTO ls_header.
      mi_client->request->set_header_field(
        name  = ls_header-name
        value = ls_header-value ).
    ENDLOOP.
    mi_client->request->set_content_type( 'application/json' ).
    mi_client->send( mv_timeout ).
    mi_client->receive(
      EXCEPTIONS
        http_communication_failure = 1
        http_invalid_state         = 2
        http_processing_failed     = 3
        OTHERS                     = 4 ).
    IF sy-subrc <> 0.
      mi_client->get_last_error(
        IMPORTING
          code    = lv_code
          message = lv_message ).
      ASSERT 1 = 2.
    ENDIF.

    lv_content_type = mi_client->response->get_content_type( ).
    mi_client->response->get_status( IMPORTING code = lv_code ).
    CASE lv_code.
      WHEN '200'.
        SPLIT lv_content_type AT ';' INTO lv_content_type lv_dummy.
        CASE lv_content_type.
          WHEN 'application/json'.
            /ui2/cl_json=>deserialize(
              EXPORTING json = mi_client->response->get_cdata( )
              CHANGING data = return-_200_app_json ).
          WHEN OTHERS.
* unexpected content type
        ENDCASE.
      WHEN OTHERS.
* todo, error handling
    ENDCASE.

  ENDMETHOD.

Questions: is it to be expected that not everything is present in the client implementation? The "body" parameter from the interface is left unused.

larshp commented 4 days ago

there is still stuff that needs to be implemented, pull requests welcome

AndreaBorgia-Abo commented 4 days ago

So I am not seeing ghosts here, good :) I'll fix my test class first, then see how I can add it to the ABAP generator... the web version is hopefully just a transpiler step away.