Skip to Content
Technical Articles

SAP NetWeaver Gateway OpenAPI / Swagger documentation, yes it’s possible!

Background

During one of my recent projects, implementing an API using SAP NetWeaver Gateway, I stumbled upon the question to deliver a Swagger / OpenAPI documentation for the delivered API.

Well that was a new one for me! Off course I was used to use Swagger documentation (such as the one SAP Cloud Platform Internet Of Things provides for example), but I never created one myself before. So after a lot of research I was able to create the OpenAPI / Swagger documentation by hand for my API.

Since I really liked the way the Swagger UI was working and how it acts both as an API test tool and API documentation, it got me thinking:

  • Wouldn’t it be nice to have this functionality available for all my SAP NetWeaver Gateway services?
  • Wouldn’t this speed up my Fiori developments as well? (Faster testing and no more work regarding documenting my OData services)

So I went to work!

Integrating OpenAPI / Swagger UI into ABAP

I had some issues with me previously created OpenAPI documentation. Everything was in place, but testing using Swagger UI was not possible due to Cross-Origin Resource Sharing (CORS) errors since my Swagger UI was running in a different domain (locally on my laptop).

Another thing that got me thinking, how to handle the X-CSRF-Tokens?

Well after some fiddling around, I managed to come up with a transaction that:

  • Lists all activated services (both OData V2 and V4)
  • Creates the necessary OpenAPI JSON (including entity data model)
  • Launches the Swagger UI (fully functional)

Backend transaction preview:

Swagger UI:

Testing a GET request:

Next steps

While the base solution seems to be fully functional (except for complex types), I’m still looking into:

  • Some minor code refactoring
  • Testing additional OData functions (function imports, complex types, …)
  • Adding some more configuration options (enable / disable entity data model, OpenAPI / Swagger version, …)
  • Handling systems which have X-CSRF-Tokens disabled (which I hope, I never run into!)
  • Testing the solution in environments using a front-end server (current development system uses an embedded gateway since it’s an S/4HANA 1809 system)
  • Open-source this solution?

I’m very interested in your feedback! Are there any other functionalities that come to mind? (maybe we can even discuss them in person at SAP TechEd Las Vegas?)

EDIT: Solution was released as ABAP OpenAPI UI. Details can be found here.

7 Comments
You must be Logged on to comment or reply to a post.