Skip to content

Instantly share code, notes, and snippets.

@roee88
Last active April 20, 2021 18:35
Show Gist options
  • Save roee88/626d93f9e73776c7f1ec3aa59d7db988 to your computer and use it in GitHub Desktop.
Save roee88/626d93f9e73776c7f1ec3aa59d7db988 to your computer and use it in GitHub Desktop.
kin-openapi external references bug
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"a": {
"type": "string"
},
"b": {
"type": "object",
"description": "I use a local reference.",
"properties": {
"name": {
"$ref": "#/definitions/a"
}
}
}
}
}
package test
import (
"testing"
"github.com/getkin/kin-openapi/openapi3"
)
func TestExternalRef(t *testing.T) {
loader := &openapi3.SwaggerLoader{
IsExternalRefsAllowed: true,
}
_, err := loader.LoadSwaggerFromFile("spec.yaml")
if err != nil {
t.Error(err)
}
}
openapi: 3.0.1
components:
schemas:
Test:
type: object
properties:
test:
$ref: 'ext.json#/definitions/b'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment