|
9 | 9 | "fmt" |
10 | 10 | "net/http" |
11 | 11 | "os" |
| 12 | + "slices" |
12 | 13 | "sort" |
13 | 14 | "strconv" |
14 | 15 | "strings" |
@@ -36,6 +37,7 @@ type methodTemplate struct { |
36 | 37 | HasBody bool |
37 | 38 | HasSummary bool |
38 | 39 | IsAppJSON bool |
| 40 | + IsExperimental bool |
39 | 41 | } |
40 | 42 |
|
41 | 43 | type paramsInfo struct { |
@@ -141,22 +143,24 @@ func buildMethod( |
141 | 143 | return nil |
142 | 144 | } |
143 | 145 |
|
144 | | - if o.Tags[0] == "experimental" { |
145 | | - fmt.Printf("[WARN] TODO: skipping operation %q, since it is experimental\n", o.OperationID) |
146 | | - return nil |
147 | | - } |
148 | | - |
149 | | - if o.Tags[0] == "console-auth" { |
| 146 | + if slices.Contains(o.Tags, "console-auth") { |
150 | 147 | fmt.Printf( |
151 | 148 | "[WARN] TODO: skipping operation %q, since it is for console authentication\n", |
152 | 149 | o.OperationID, |
153 | 150 | ) |
154 | 151 | return nil |
155 | 152 | } |
156 | 153 |
|
| 154 | + isExperimental := slices.Contains(o.Tags, "experimental") |
| 155 | + |
157 | 156 | methodName := strcase.ToCamel(o.OperationID) |
158 | 157 | pInfo := buildParams(o, methodName) |
159 | 158 |
|
| 159 | + // Prefix experimental operations so callers know the API may change. |
| 160 | + if isExperimental { |
| 161 | + methodName = "Experimental" + methodName |
| 162 | + } |
| 163 | + |
160 | 164 | // Adapt for ListAll methods |
161 | 165 |
|
162 | 166 | if isGetAllPages { |
@@ -206,6 +210,7 @@ func buildMethod( |
206 | 210 | HasParams: pInfo.paramsString != "", |
207 | 211 | HasSummary: o.Summary != "", |
208 | 212 | HasDescription: o.Description != "", |
| 213 | + IsExperimental: isExperimental, |
209 | 214 | } |
210 | 215 |
|
211 | 216 | // TODO: Handle other content types |
@@ -426,7 +431,11 @@ func buildPathOrQueryParams( |
426 | 431 | fmt.Sprintf("%q: %s.Format(time.RFC3339),", name, n), |
427 | 432 | ) |
428 | 433 | default: |
429 | | - pathParams = append(pathParams, fmt.Sprintf("%q: string(%s),", name, n)) |
| 434 | + if p.Schema.Value != nil && p.Schema.Value.Type.Is("integer") { |
| 435 | + pathParams = append(pathParams, fmt.Sprintf("%q: fmt.Sprint(%s),", name, n)) |
| 436 | + } else { |
| 437 | + pathParams = append(pathParams, fmt.Sprintf("%q: string(%s),", name, n)) |
| 438 | + } |
430 | 439 | } |
431 | 440 | } |
432 | 441 | } |
|
0 commit comments