go-openapi / spec

openapi specification object model

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NewRef should return an empty Ref if refURI is empty

nikhita opened this issue · comments

We are using go-openapi for validation of Custom Resources in Kubernetes (kubernetes/kubernetes#47263).

While using the spec.NewRef function, an empty string i.e spec.NewRef("") results in a Ref with a # - not an empty Ref value. Due to this, we incorporated an additional check.

Looking at the code in https://github.com/go-openapi/jsonreference, it looks like an empty Ref should be produced but I couldn't really figure out why that does not occur.

cc @sttts

would it be ok if it returned:

{"$ref":""}

@casualjim That would be perfect, thanks. 👍

i fixed this now so please close when you've confirmed :)