Skip to content

Commit

Permalink
Fix: Ensure external refs are propagated to generated code
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jamietanna committed Jan 25, 2024
1 parent 390058d commit 0692acc
Show file tree
Hide file tree
Showing 14 changed files with 1,198 additions and 0 deletions.
43 changes: 43 additions & 0 deletions internal/test/issues/issue-1378/bionicle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
openapi: 3.0.1

info:
title: Test
description: Test
version: 1.0.0

paths:
/bionicle/{name}:
get:
parameters:
- $ref: "#/components/parameters/bionicleName"
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Bionicle'
'400':
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Bionicle'

components:
parameters:
bionicleName:
name: name
in: path
description: Name of the character
required: true
schema:
type: string

schemas:
Bionicle:
type: object
properties:
name:
type: string
required:
- name
Loading

0 comments on commit 0692acc

Please sign in to comment.