This repository was archived by the owner on Feb 20, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
This repository was archived by the owner on Feb 20, 2026. It is now read-only.
panic when a $ref refers to a local file #101
Copy link
Copy link
Open
Description
So I have my various services split up into their own yaml files and a common.yaml file they they will refer to
common.yaml
openapi: 3.0.3
info:
version: "v1"
title: "Common Components"
description: Common Components used by many endpoints
paths: {}
components:
##########################
# Common Parameters
##########################
parameters:
InteractionIdParam:
in: path
name: interaction_id
required: true
schema:
$ref: "common.yaml#/components/schemas/InteractionId"
##########################
# Common Data Models
##########################
schemas:
InteractionId:
description: >-
The primary Identifier for the call.
type: string
format: uuid
example: "fdb6816a-a281-412f-ae47-a40fc1033e13"test.yaml
openapi: 3.0.3
info:
version: "v1"
title: "Test Service"
description: The Test Service
paths:
/v1/test/{interaction_id}/results:
get:
summary: Test Service
description: |-
Render the test results
parameters:
- $ref: "common.yaml#/components/parameters/InteractionIdParam"
responses:
"200":
$ref: "test.yaml#/components/responses/GetTestSuccess"
components:
schemas:
TestGetResponse:
type: object
properties:
data:
type: string
responses:
GetTestSuccess:
description: OK
content:
application/json:
schema:
$ref: "test.yaml#/components/schemas/TestGetResponse"so when I run gnostic --resolve-refs --grpc-out=generated/proto/ common.yaml it works fine
when I run gnostic --resolve-refs --grpc-out=generated/proto/ test.yaml I get
gnostic --resolve-refs --grpc-out=generated/proto/ openapi/test.yaml
2023/10/26 12:19:29 Not able to find parameter information for: _ref:"common.yaml#/components/parameters/InteractionIdParam"
level:WARNING code:"OPERATION" text:"One of your operations does not have an 'operationId'. gnostic-grpc might produce an incorrect output file." keys:"paths" keys:"/v1/test/{interaction_id}/results" keys:"get"
Errors reading openapi/test.yaml
Plugin error: [file "test.proto" included an unresolvable reference to "test.InteractionIdParam"]
running gnostic --resolve-refs --pb_out=generated/pb/ openapi/test.yaml works fine and when I run gnostic-grpc not as a plugin I get
gnostic-grpc -input ./generated/pb/openapi/test.pb
2023/10/26 12:25:24 Not able to find parameter information for: _ref:"common.yaml#/components/parameters/InteractionIdParam"
2023/10/26 12:25:24 Plugin error: [file "test.proto" included an unresolvable reference to "test.InteractionIdParam"]
when I run the full test.yaml file I get
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x38 pc=0x105050384]
goroutine 1 [running]:
github.com/google/gnostic/surface.(*OpenAPI3Builder).buildFromResponse(0x8?, {0x140002349e0, 0xf}, 0x1f?)
/Users/devlon.gilcrease/projects/gnostic/surface/model_openapiv3.go:308 +0x114
github.com/google/gnostic/surface.(*OpenAPI3Builder).buildFromResponseOrRef(0x14000169ac8?, {0x140002349e0, 0xf}, 0x14000036ea0?)
/Users/devlon.gilcrease/projects/gnostic/surface/model_openapiv3.go:292 +0x104
github.com/google/gnostic/surface.(*OpenAPI3Builder).buildFromComponents(0x14000169ac8, 0x140001c2120)
/Users/devlon.gilcrease/projects/gnostic/surface/model_openapiv3.go:89 +0x3a8
github.com/google/gnostic/surface.(*OpenAPI3Builder).buildFromDocument(0x12c3b2928?, 0x140001b60c0)
/Users/devlon.gilcrease/projects/gnostic/surface/model_openapiv3.go:61 +0x2c
github.com/google/gnostic/surface.(*OpenAPI3Builder).buildModel(0x14000169ac8, 0x140001b60c0, {0x16b2634cb, 0x18})
/Users/devlon.gilcrease/projects/gnostic/surface/model_openapiv3.go:51 +0xb4
github.com/google/gnostic/surface.NewModelFromOpenAPI3(0x140001b60c0, {0x16b2634cb, 0x18})
/Users/devlon.gilcrease/projects/gnostic/surface/model_openapiv3.go:32 +0x50
github.com/google/gnostic/lib.(*pluginCall).perform(0x140000787a0, {0x10521c890?, 0x140001b60c0?}, 0x3, {0x16b2634cb, 0x18}, 0x0, 0x0)
/Users/devlon.gilcrease/projects/gnostic/lib/gnostic.go:174 +0x378
github.com/google/gnostic/lib.(*Gnostic).performActions(0x1400017a1c0, {0x10521c890?, 0x140001b60c0})
/Users/devlon.gilcrease/projects/gnostic/lib/gnostic.go:611 +0x234
github.com/google/gnostic/lib.(*Gnostic).Main(0x1400017a1c0)
/Users/devlon.gilcrease/projects/gnostic/lib/gnostic.go:683 +0x4c8
main.main()
/Users/devlon.gilcrease/projects/gnostic/gnostic.go:44 +0xb0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels