-
-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on v2 to V3 conversion when using a hashmap/dict with $ref "failed to resolve "definitions" in fragment in URI: "#/definitions/": struct field "definitions" not found" #1016
Comments
Reproducer: Simply drop this in import (
"encoding/json"
"testing"
"github.com/getkin/kin-openapi/openapi2"
"github.com/stretchr/testify/require"
)
func TestIssue1016(t *testing.T) {
v2 := []byte(`
{
"basePath": "/v2",
"host": "test.example.com",
"info": {
"title": "MyAPI",
"version": "0.1",
"x-info": "info extension"
},
"paths": {
"/foo": {
"get": {
"operationId": "getFoo",
"responses": {
"200": {
"description": "returns all information",
"schema": {
"$ref": "#/definitions/PetDirectory"
}
},
"default": {
"description": "OK"
}
},
"summary": "get foo"
}
}
},
"schemes": [
"http"
],
"swagger": "2.0",
"definitions": {
"Pet": {
"type": "object",
"required": ["petType"],
"properties": {
"petType": {
"type": "string"
},
"name": {
"type": "string"
},
"age": {
"type": "integer"
}
}
},
"PetDirectory":{
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Pet"
}
}
}
}
`)
var doc2 openapi2.T
err := json.Unmarshal(v2, &doc2)
require.NoError(t, err)
_, err = v2v3YAML(v2)
require.NoError(t, err)
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was introduced by #1011
within a v2 doc, anytime a map/dictionary is defined using a $ref, conversion to v3
fails:
Converting this results in:
failed to resolve "definitions" in fragment in URI: "#/definitions/Pet": struct field "definitions" not found
reproducer below
The text was updated successfully, but these errors were encountered: