openapi-typescript
openapi-typescript copied to clipboard
Fix invalid $ref index into path
⚠️ The Error
Refs into the parameters array are turned into invalid indexes into the paths structure.
🗣️ Discussion
The problematic behavior is triggered using a $ref that points into the parameters array.
The problematic generated type then tries to index into ["parameters"]["0"] as though it were an array, when in fact it should be indexing into ["parameters"]["query"].
This particular weird ref was generated when I bundled a big schema with @apidevtools/json-schema-ref-parser.
:wrench: Fix
- While parsing
oapiRefsfrom parameters arrays, pass the resolved ParameterObject and use itsinmethod to index intoparameterstype.
This probably doesn't work for more complex $refs, but I think it does slightly improve the semantic awareness of oapiRef.