Commit a208c61
[repo-assist] refactor+test: extract compileSingleRefOrNewObject helper; add text/plain body, octet-stream response, path-level param tests (+
[Content truncated due to length] (#452)
* refactor+test: extract compileSingleRefOrNewObject helper; add text/plain body, octet-stream response, path-level param tests (+9 tests, 465→474)
Task 5: Extract the three identical allOf/oneOf/anyOf single-$ref collapse
match arm bodies into a shared compileSingleRefOrNewObject local helper in
DefinitionCompiler.compileBySchema. The semantics are unchanged — each of the
three guards fires under the same conditions as before, but the 4-line inner
match expression is replaced by a single call. This removes ~18 lines of
duplicated code while keeping the guard conditions explicit and separate.
Task 10: Add 9 unit tests covering three previously untested OperationCompiler
behaviours:
- text/plain request body → parameter named "textPlain"
- application/octet-stream response → return type Task<IO.Stream>
- Path-level parameters on PathItem → inherited by all operations on that path
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* ci: trigger checks
* fix: use typed field access in generated property getter/setter
Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/b2ed13f0-6603-43f9-a415-011fb299a1b6
Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
* fix: revert FieldGet/FieldSet to FieldGetUnchecked/FieldSetUnchecked
The previous commit accidentally changed Expr.FieldGetUnchecked/FieldSetUnchecked
to the checked variants Expr.FieldGet/FieldSet. ProvidedField instances require the
Unchecked variants; the checked variants caused 100 type-inference errors in the
ProviderTests (FS0072) because the generated property accessors produced expressions
with incorrect type information.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* ci: trigger checks
* fix: restore typed field expressions for generated properties
* fix: revert FieldGet/FieldSet to FieldGetUnchecked/FieldSetUnchecked
Expr.FieldGet performs strict type-equality checks which rejects array
types where the provided-field type is System.IO.Stream[] but the
expression carries System.IO.Stream[*]. FieldGetUnchecked skips this
check and was the working approach before the previous fix attempt.
All 474 unit tests pass.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* ci: trigger checks
* fix: use fresh Var per call in coerceString/coerceQueryString to avoid duplicate quotation variable exceptions
When coerceString or coerceQueryString was called for multiple parameters
in the same operation, the quotation literal `<@ let x = ... @>` reused
the same Var object on every call. Composing multiple such quotations into
one invokeCode expression caused the ProvidedTypes/quotation compiler to
throw "An item with the same key has already been added. Key: x" (or 'o')
for any operation with two or more path/header/cookie/query parameters.
Fix: replace the static quotation literals with Expr.Let + a freshly
constructed Var on each call, ensuring each binding has its own unique
Var identity.
* style: apply Fantomas formatting
* fix: eliminate duplicate Var by building Expr.Call directly instead of let-binding
The original coerceString used a quotation literal:
<@ let x = (%obj) in RuntimeHelpers.toParam x @>
F# compiles quotation literals to static data, so the Var("x") inside
the literal is the same object on every call. When an operation has two
or more path/header/cookie parameters, coerceString is called once per
parameter and the fold combines the results. The resulting expression
tree contained the same Var object bound by multiple Let nodes.
ProvidedTypes' IL emitter does localsMap.Add(v, lb) for each Let(v,...)
node — since all Let nodes shared the same Var object, the second Add
threw "An item with the same key has already been added. Key: x".
The same problem affected coerceQueryString with Var("o").
Fix: replace the quotation literals entirely with Expr.Call, extracting
the MethodInfo once via a quotation pattern match and then building the
call node directly. This avoids any Let binding and any shared Var, so
each invocation produces a structurally independent expression.
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
Co-authored-by: Sergey Tihon <sergey.tihon@gmail.com>1 parent 16a1865 commit a208c61
3 files changed
Lines changed: 192 additions & 21 deletions
File tree
- src/SwaggerProvider.DesignTime
- tests/SwaggerProvider.Tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
444 | 455 | | |
445 | 456 | | |
446 | 457 | | |
| |||
472 | 483 | | |
473 | 484 | | |
474 | 485 | | |
475 | | - | |
| 486 | + | |
| 487 | + | |
476 | 488 | | |
477 | 489 | | |
478 | 490 | | |
479 | 491 | | |
480 | 492 | | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
| 493 | + | |
487 | 494 | | |
488 | 495 | | |
489 | 496 | | |
490 | 497 | | |
491 | 498 | | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
| 499 | + | |
498 | 500 | | |
499 | 501 | | |
500 | 502 | | |
501 | 503 | | |
502 | 504 | | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
| 505 | + | |
508 | 506 | | |
509 | 507 | | |
510 | 508 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
319 | 320 | | |
320 | 321 | | |
321 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
322 | 332 | | |
323 | | - | |
324 | | - | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
325 | 340 | | |
326 | 341 | | |
327 | 342 | | |
328 | | - | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
329 | 346 | | |
330 | 347 | | |
331 | 348 | | |
| |||
Lines changed: 156 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1113 | 1113 | | |
1114 | 1114 | | |
1115 | 1115 | | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
1116 | 1272 | | |
1117 | 1273 | | |
1118 | 1274 | | |
| |||
0 commit comments