Skip to content

allows more types with the Pointable interface#5

Merged
casualjim merged 1 commit into
go-openapi:masterfrom
axiomhq:expand-pointable
Nov 15, 2020
Merged

allows more types with the Pointable interface#5
casualjim merged 1 commit into
go-openapi:masterfrom
axiomhq:expand-pointable

Conversation

@gordallott

Copy link
Copy Markdown
Contributor

Sometimes the internal json structure allows for multiple objects at a node, such as

[
	{"Foo": "hello"},
	{"Bar": "world"},
]

which might be represented in go as

type Parent map[string]*Node

type Node struct {
	Foo *Foo
	Bar *Bar
}

with a JSON unmarshaller that is intelligent enough to allocate the right thing into the right Foo/Bar type.

In this case, it would be prefered for a jsonpointer reference to /0 to return a *Foo object and not a *Node object. this PR makes this possible by allowing the JSONLookup interface to work with non-struct types

Signed-off-by: Gord Allott <gord@axiom.co>
@codecov

codecov Bot commented Sep 3, 2020

Copy link
Copy Markdown

Codecov Report

Merging #5 into master will not change coverage.
The diff coverage is 73.91%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master       #5   +/-   ##
=======================================
  Coverage   78.02%   78.02%           
=======================================
  Files           1        1           
  Lines         182      182           
=======================================
  Hits          142      142           
  Misses         24       24           
  Partials       16       16           
Impacted Files Coverage Δ
pointer.go 78.02% <73.91%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed12351...cf3eb5b. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants