How to activate swagger in SAP Commerce Cloud 2211
2023-11-17 17:35:21 Author: blogs.sap.com(查看原文) 阅读量:4 收藏

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.

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=
      
    2. 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

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


文章来源: https://blogs.sap.com/2023/11/17/how-to-activate-swagger-in-sap-commerce-cloud-2211/
如有侵权请联系:admin#unsafe.sh