fix: conversion with a parameter schema ref#419
Closed
vbehar wants to merge 2 commits into
Closed
Conversation
converting from v3 to v2 with an endpoint using a parameter with a schema ref used to fail with the following error:
```
--- FAIL: TestConvOpenAPIV3ToV2 (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x58 pc=0x100f71688]
goroutine 4 [running]:
testing.tRunner.func1.2({0x101035da0, 0x1012b6160})
/opt/homebrew/Cellar/go/1.17/libexec/src/testing/testing.go:1209 +0x258
testing.tRunner.func1(0x14000117380)
/opt/homebrew/Cellar/go/1.17/libexec/src/testing/testing.go:1212 +0x284
panic({0x101035da0, 0x1012b6160})
/opt/homebrew/Cellar/go/1.17/libexec/src/runtime/panic.go:1038 +0x21c
github.com/getkin/kin-openapi/openapi2conv.FromV3Parameter(0x140001ce7c8, 0x1400007da18)
/Users/vbehar/projects/oss/kin-openapi/openapi2conv/openapi2_conv.go:979 +0x138
github.com/getkin/kin-openapi/openapi2conv.FromV3Operation(0x1400007da00, 0x14000129c20)
/Users/vbehar/projects/oss/kin-openapi/openapi2conv/openapi2_conv.go:895 +0x250
github.com/getkin/kin-openapi/openapi2conv.FromV3(0x1400007da00)
/Users/vbehar/projects/oss/kin-openapi/openapi2conv/openapi2_conv.go:586 +0xddc
github.com/getkin/kin-openapi/openapi2conv.TestConvOpenAPIV3ToV2(0x14000117380)
/Users/vbehar/projects/oss/kin-openapi/openapi2conv/openapi2_conv_test.go:26 +0x19c
testing.tRunner(0x14000117380, 0x1010870e8)
/opt/homebrew/Cellar/go/1.17/libexec/src/testing/testing.go:1259 +0x104
created by testing.(*T).Run
/opt/homebrew/Cellar/go/1.17/libexec/src/testing/testing.go:1306 +0x328
FAIL github.com/getkin/kin-openapi/openapi2conv 0.840s
FAIL
```
This change fixes the issue by ensuring that we correctly handle a schema ref.
Contributor
Author
|
hum in fact I was too focused on the v3 to v2 conversion and missed that the v2 to v3 is also missing a fix here |
Collaborator
|
LGTM |
Collaborator
|
(Disregard that previous comment). Your test is not valid OpenAPIv2 per https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#fixed-fields-7 or https://swagger.io/docs/specification/2-0/describing-parameters/#faq in that the But the issue that the parameter schema $ref be used when defined is valid. I'm looking into it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
converting from v3 to v2 with an endpoint using a parameter with a schema ref used to fail with the following error:
This change fixes the issue by ensuring that we correctly handle a schema ref.