The goal of this article is to provide documentations needed when upgrading Swagger SAP Commerce to version 2211.

SAP best practices recommends to use swaggerintegration extension to automate the API documentation process and provide Swagger UI for your web services.

Activating Swagger in 2211

The basic steps to activate Swagger in SAP CC 2211 are

    • Include swaggerintegration into your localextensions.xml

 

    • [...]
      <extension name="swaggerintegration"/>
      [...]

 

    • Run ant clean all

 

    • Restart the server

 

    • Perform an update system

If the swagger is still not working despite the actions above and you have 404 when loading the swagger in the browser

    • Check if you have restricted APIs configured in *.properties with following values
      commercewebservices.api.restrictions.disabled.endpoints=.*
      commercewebservices.api.restrictions.enabled.endpoints=<ENDPOINTS_METHODS_LISTS_SEPERATED_BY_COMMA>
      

 

    • If it is the case, you have two options
        1. Authorise all endpoints with the following configuration to include swagger endpoints
          commercewebservices.api.restrictions.disabled.endpoints=
          
        1. Keep the restrictions but allow swagger endpoints openapiJsonUsingGET and redirectToUiUsingGET
          commercewebservices.api.restrictions.disabled.endpoints=.*
          commercewebservices.api.restrictions.enabled.endpoints=openapiJsonUsingGET,redirectToUiUsingGET,<ENDPOINTS_METHODS_LISTS_SEPERATED_BY_COMMA>
          

After doing this, you will be able to load the swagger correctly with the following address : https://<API_URL>/occ

Below some useful links if you need to do some advanced configurations

Link Comment
ApiDocInfoProvider Check this link to know how you can use the implementation of ApiDocInfoProvider interface to provide information for API Documentation
Integrate with swaggerintegration Extension Check this link to know how to integrate  with  swaggerintegration extension
Authorization Exclusion Check this link to see how you can exclude endpoints in your spring security config.
Customized Servlet Path Check this link if you have a customised servlet path
OAuth2 Configuration Check this link to know which configuration information about OAuth is needed
Enable/Disable Swagger U Check this link to know how to enable/disable swagger
OpenAPI Customizer Check this link if you want to customise your OpenAPI documentation with Springdoc

 

Conclusion

With the information provided above, you will be able to activate swagger API in SAP Commerce 2211 and gain visibility on the APIs exposed by your SAP Commerce implementation

Sara Sampaio

Sara Sampaio

Author Since: March 10, 2022

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x