diff --git a/dfp/api/openapi.yaml b/dfp/api/openapi.yaml index c81fb20..75d475a 100644 --- a/dfp/api/openapi.yaml +++ b/dfp/api/openapi.yaml @@ -133,6 +133,8 @@ paths: required: true schema: type: string + x-gosdk-type: resource_id + x-gosdk-type: resource_id requestBody: content: application/json: @@ -188,6 +190,8 @@ paths: required: true schema: type: string + x-gosdk-type: resource_id + x-gosdk-type: resource_id - description: The DNS Forwarding Proxy object identifier. in: query name: id diff --git a/dfp/api_infra_services.go b/dfp/api_infra_services.go index 1953dda..bfdd08a 100644 --- a/dfp/api_infra_services.go +++ b/dfp/api_infra_services.go @@ -123,7 +123,7 @@ func (a *InfraServicesAPIService) CreateOrUpdateDfpServiceExecute(r InfraService } localVarPath := localBasePath + "/dfp_services/{payload.service_id}" - localVarPath = strings.Replace(localVarPath, "{"+"payload.service_id"+"}", url.PathEscape(internal.ParameterValueToString(r.payloadServiceId, "payloadServiceId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"payload.service_id"+"}", url.PathEscape(internal.ParameterValueToStringForType(r.payloadServiceId, "payloadServiceId", "resource_id")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -427,7 +427,7 @@ func (a *InfraServicesAPIService) ReadDfpServiceExecute(r InfraServicesAPIReadDf } localVarPath := localBasePath + "/dfp_services/{service_id}" - localVarPath = strings.Replace(localVarPath, "{"+"service_id"+"}", url.PathEscape(internal.ParameterValueToString(r.serviceId, "serviceId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"service_id"+"}", url.PathEscape(internal.ParameterValueToStringForType(r.serviceId, "serviceId", "resource_id")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} diff --git a/internal/client.go b/internal/client.go index 46baf02..dd126cd 100644 --- a/internal/client.go +++ b/internal/client.go @@ -132,11 +132,24 @@ func typeCheckParameter(obj interface{}, expected string, name string) error { } func ParameterValueToString(obj interface{}, key string) string { + if key == "id" { + // "id" is always assumed to be a resource_id + // If "id" is not a resource_id, it should be explicitly set to have a different type using "x-gosdk-type" extension + return ParameterValueToStringForType(obj, key, "resource_id") + } + return ParameterValueToStringForType(obj, key, "") +} + +func ParameterValueToStringForType(obj interface{}, key string, objType string) string { + if objType == "resource_id" { + return extractResourceId(parameterValueToString(obj, key)) + } + return parameterValueToString(obj, key) +} + +func parameterValueToString(obj interface{}, key string) string { if reflect.TypeOf(obj).Kind() != reflect.Ptr { s := fmt.Sprintf("%v", obj) - if key == "id" { - s = extractResourceId(s) - } return s } var param, ok = obj.(MappedNullable) @@ -148,9 +161,6 @@ func ParameterValueToString(obj interface{}, key string) string { return "" } s := fmt.Sprintf("%v", dataMap[key]) - if key == "id" { - s = extractResourceId(s) - } return s }