Skip to content

Commit ad5eada

Browse files
committed
Fix: Ensure external refs are propagated to generated code
As noted in #1378, there are cases where a complex set of `$ref`s between multiple files can lead to broken generated code, which does not correctly import the package that has been prepared for the external reference. We can handle this by looking up any references, where there is a `.Ref` passed into the type, and then iterate through relevant children. This requires we handle the updating in-place for these by using a bit of pointer + indexing fun. This also adds a relevant test case to validate the fix. Closes #1378.
1 parent 3bf5755 commit ad5eada

File tree

14 files changed

+1198
-0
lines changed

14 files changed

+1198
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
openapi: 3.0.1
2+
3+
info:
4+
title: Test
5+
description: Test
6+
version: 1.0.0
7+
8+
paths:
9+
/bionicle/{name}:
10+
get:
11+
parameters:
12+
- $ref: "#/components/parameters/bionicleName"
13+
responses:
14+
'200':
15+
content:
16+
application/json:
17+
schema:
18+
$ref: '#/components/schemas/Bionicle'
19+
'400':
20+
content:
21+
application/json:
22+
schema:
23+
oneOf:
24+
- $ref: '#/components/schemas/Bionicle'
25+
26+
components:
27+
parameters:
28+
bionicleName:
29+
name: name
30+
in: path
31+
description: Name of the character
32+
required: true
33+
schema:
34+
type: string
35+
36+
schemas:
37+
Bionicle:
38+
type: object
39+
properties:
40+
name:
41+
type: string
42+
required:
43+
- name

0 commit comments

Comments
 (0)