2 Replies Latest reply on Jul 7, 2020 5:47 AM by user3228965

    ORDS openapi invalid payload generation

    user3228965

      Hi.

      I'm a beginner at using ORDS to create REST web services. I'm trying to create a few handlers for PL/SQL functions in a package. Db version is 12.1.0.2, ORDS version is 19.2.0.r1991647.

      The problem:

      There are two among those handlers, that have a similar parameter scheme (4 in, 2 out), though the datatypes and parameter names are different. For some reason openapi generated for these two handlers attributes them with the exact same type of payload. Is it a normal behavior (hopefully one I can change in configuration), or a bug? Because now I can't create a decent client code with swagger - I have to create a client for one of the functions by hand.

      I've tried both with and without using ORDS.DEFINE_PARAMETER, with both 'URI' and 'HEADER' as the source type of 'IN' parameters - none of it solved the problem. Please help.

       

      Here are the handler definitions:

       

      ORDS.define_handler(
      p_module_name    => 'rest-fb',
      p_pattern        => 'fb513/',
      p_method         => 'POST',
      p_source_type    => ORDS.source_type_plsql,
      p_source => '
              DECLARE 
                  v_ret tex.response_41_T;
                  v_P_FUNDALLOCATIONLIST TEX.FUNDALLOCATIONLIST_44_T;
              BEGIN
                      v_ret := TEX.F_FUND_INTERFACE.FB513(P_POLICY => TEX.POLICY_25_T(:P_POLICY_policyid, :P_POLICY_accounttype),
                          P_FUNDALLOCATION => TEX.FUNDALLOCATION_26_T(:P_FUNDALLOCATION_datefrom, :P_FUNDALLOCATION_dateto),
                          P_FUNDALLOCATIONLIST => v_P_FUNDALLOCATIONLIST
                      );
                  :out_fundallocation := tex.fundallocationlist_44_t2json(v_P_FUNDALLOCATIONLIST);
                  :out_response := tex.response_41_t2json(v_ret);
              END;
      ',
      p_comments => 'fb513',
      p_mimes_allowed => 'application/json',
      p_items_per_page => 0);
      
      
      ORDS.define_handler(
      p_module_name    => 'rest-fb',
      p_pattern        => 'fb587/',
      p_method         => 'POST',
      p_source_type    => ORDS.source_type_plsql,
      p_source => '
              DECLARE 
                  v_ret tex.response_65_T;
                  v_P_PRINTDOCLIST TEX.PRINTDOCLIST_68_T;
              BEGIN
                  v_ret := TEX.F_FUND_INTERFACE.FB587(P_PRODUCT => TEX.PRODUCT_70_T(:P_PRODUCT_productno, :P_PRODUCT_statisticno),
                      P_PRINTDOCVALIDITY => TEX.PRINTDOCVALIDITY_71_T(:P_PRINTDOCVAL_effectivedate),
                      P_PRINCDOCLIST => TEX.PRINCDOCLIST_72_T(TEX.PRINTDOC_73_T_VARRAY_h2arr(:P_PRINCDOCLIST_printdoc)),
                      P_PRINTDOCLIST => v_P_PRINTDOCLIST
                      );
                  :out_printdoclist := tex.printdoclist_68_t2json(v_P_PRINTDOCLIST);
                  :out_response := tex.response_65_t2json(v_ret);
              END;
      ',
      p_comments => 'fb587',
      p_mimes_allowed => 'application/json',
      p_items_per_page => 0);
      
      
      
      

       

      And here's what open-api-catalog lists:

      ...

      "/fb513/":{"post":{"description":"fb513","responses":{"200":{"description":"output of the endpoint","schema":{"type":"object","properties":{"out_fundallocation":{"type":"string"},"out_response":{"type":"string"}}}}},"consumes":["application/json"],"parameters":[{"name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/PAYLOAD15"}}]}},

      "/fb587/":{"post":{"description":"fb587","responses":{"200":{"description":"output of the endpoint","schema":{"type":"object","properties":{"out_printdoclist":{"type":"string"},"out_response":{"type":"string"}}}}},"consumes":["application/json"],"parameters":[{"name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/PAYLOAD15"}}]}}},

      ...

      "PAYLOAD15":{"properties":{"p_policy_policyid":{"type":"string"},"p_policy_accounttype":{"type":"string"},"p_fundallocation_datefrom":{"type":"string"},"p_fundallocation_dateto":{"type":"string"},"out_fundallocation":{"type":"string"},"out_response":{"type":"string"}}},

      ...