Setting the Api Version with Swagger UI

后端 未结 3 933
醉酒成梦
醉酒成梦 2020-12-19 22:21

I have a REST API developed through the use of Jersey and we document the REST API through swagger-ui. Unfortunately, we did not start versioning the API from day 1. We are

3条回答
  •  心在旅途
    2020-12-19 22:50

    It's pretty straight forward -

    1. Add a servlet to set the Swagger Bootstrap properties in your deployment descriptior file.
    
            SwaggerBootstrap
            com.example.util.SwaggerBootstrap
            
                URL Pattern Mapping
                paramName
                uri value
            
            2
        
    
    2. Create a servlet and set the Bean properties as below --
    
    public void init(ServletConfig servletConfig) 
    {
            try {
    
                // Setting the BeanConfig for start-up page
                BeanConfig bean = new BeanConfig();
                bean.setScan(true);
                bean.setResourcePackage("com.example.util");
                bean.setBasePath("yourBasePath"));  
                bean.setVersion("1.0");
                bean.setTitle("title"));
                bean.setDescription("description");
    
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    

提交回复
热议问题