k8s.io/kube-openapi@v0.0.0-20240228011516-70dd3763d340/pkg/common/restfuladapter/webservice_adapter.go (about)

     1  package restfuladapter
     2  
     3  import (
     4  	"github.com/emicklei/go-restful/v3"
     5  	"k8s.io/kube-openapi/pkg/common"
     6  )
     7  
     8  var _ common.RouteContainer = &WebServiceAdapter{}
     9  
    10  // WebServiceAdapter adapts a restful.WebService to common.RouteContainer.
    11  type WebServiceAdapter struct {
    12  	WebService *restful.WebService
    13  }
    14  
    15  func (r *WebServiceAdapter) RootPath() string {
    16  	return r.WebService.RootPath()
    17  }
    18  
    19  func (r *WebServiceAdapter) PathParameters() []common.Parameter {
    20  	var params []common.Parameter
    21  	for _, rParam := range r.WebService.PathParameters() {
    22  		params = append(params, &ParamAdapter{rParam})
    23  	}
    24  	return params
    25  }
    26  
    27  func (r *WebServiceAdapter) Routes() []common.Route {
    28  	var routes []common.Route
    29  	for _, rRoute := range r.WebService.Routes() {
    30  		localRoute := rRoute
    31  		routes = append(routes, &RouteAdapter{&localRoute})
    32  	}
    33  	return routes
    34  }