larshp / ABAP-Swagger

Expose ABAP REST services with Swagger/openapi spec
MIT License
97 stars 40 forks source link

Two different parameters, referencing same data type, have different definition #76

Open erichopp opened 3 years ago

erichopp commented 3 years ago

This is exposed by https://github.com/larshp/todo_logic

From this ABAP source: CLASS zcl_todo DEFINITION PUBLIC CREATE PUBLIC.

PUBLIC SECTION. METHODS create IMPORTING !is_data TYPE ztodo_data RETURNING VALUE(rs_key) TYPE ztodo_key . METHODS delete IMPORTING !is_key TYPE ztodo_key . METHODS list RETURNING VALUE(rt_list) TYPE ztodo_tt . METHODS update IMPORTING !iv_guid TYPE ztodo_key-guid !is_data TYPE ztodo_data . PROTECTED SECTION. PRIVATE SECTION. ENDCLASS.

The definitions section ends up with a duplicate key, ZTODO_KEY being defined two different ways: "definitions":{ "ZTODO_DATA": {"type":"object", "properties":{"TEXT":{"type":"string" }}}, "ZTODO_KEY": {"type":"object", "properties":{"GUID":{"type":"string", "maxLength": 22 }}}, "ZTODO_KEY":{"type": "object","properties": {"DATA": {"type":"object", "properties":{"GUID":{"type":"string", "maxLength": 22 }}}}}, "ZTODO_TT":{"type": "object","properties": {"DATA": {"type":"array", "items":{"type":"object", "properties":{"MANDT":{"type":"string", "maxLength": 3 },"GUID":{"type":"string", "maxLength": 22 },"TEXT":{"type":"string" }}}}}} }

larshp commented 3 years ago

thanks, pull requests welcome

however, I'm planning to move everything to https://github.com/abap-openapi, and rewrite this sometime, so it can be tested using https://github.com/open-abap

GianlucaCollot commented 3 years ago

The problem lies in ZCL_SWAG_SPEC=>RESPONSE() that buids the definition for returning parameters differently than what does REQUEST. Here is my fix: immagine