github.com/rzurga/go-swagger@v0.28.1-0.20211109195225-5d1f453ffa3a/examples/todo-list/restapi/operations/todos/update_one_urlbuilder.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package todos 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the generate command 7 8 import ( 9 "errors" 10 "net/url" 11 golangswaggerpaths "path" 12 "strings" 13 ) 14 15 // UpdateOneURL generates an URL for the update one operation 16 type UpdateOneURL struct { 17 ID string 18 19 _basePath string 20 // avoid unkeyed usage 21 _ struct{} 22 } 23 24 // WithBasePath sets the base path for this url builder, only required when it's different from the 25 // base path specified in the swagger spec. 26 // When the value of the base path is an empty string 27 func (o *UpdateOneURL) WithBasePath(bp string) *UpdateOneURL { 28 o.SetBasePath(bp) 29 return o 30 } 31 32 // SetBasePath sets the base path for this url builder, only required when it's different from the 33 // base path specified in the swagger spec. 34 // When the value of the base path is an empty string 35 func (o *UpdateOneURL) SetBasePath(bp string) { 36 o._basePath = bp 37 } 38 39 // Build a url path and query string 40 func (o *UpdateOneURL) Build() (*url.URL, error) { 41 var _result url.URL 42 43 var _path = "/{id}" 44 45 id := o.ID 46 if id != "" { 47 _path = strings.Replace(_path, "{id}", id, -1) 48 } else { 49 return nil, errors.New("id is required on UpdateOneURL") 50 } 51 52 _basePath := o._basePath 53 if _basePath == "" { 54 _basePath = "/" 55 } 56 _result.Path = golangswaggerpaths.Join(_basePath, _path) 57 58 return &_result, nil 59 } 60 61 // Must is a helper function to panic when the url builder returns an error 62 func (o *UpdateOneURL) Must(u *url.URL, err error) *url.URL { 63 if err != nil { 64 panic(err) 65 } 66 if u == nil { 67 panic("url can't be nil") 68 } 69 return u 70 } 71 72 // String returns the string representation of the path with query string 73 func (o *UpdateOneURL) String() string { 74 return o.Must(o.Build()).String() 75 } 76 77 // BuildFull builds a full url with scheme, host, path and query string 78 func (o *UpdateOneURL) BuildFull(scheme, host string) (*url.URL, error) { 79 if scheme == "" { 80 return nil, errors.New("scheme is required for a full url on UpdateOneURL") 81 } 82 if host == "" { 83 return nil, errors.New("host is required for a full url on UpdateOneURL") 84 } 85 86 base, err := o.Build() 87 if err != nil { 88 return nil, err 89 } 90 91 base.Scheme = scheme 92 base.Host = host 93 return base, nil 94 } 95 96 // StringFull returns the string representation of a complete url 97 func (o *UpdateOneURL) StringFull(scheme, host string) string { 98 return o.Must(o.BuildFull(scheme, host)).String() 99 }