Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrChildURL = errors.New("child url is nil")
ErrChildURL is raised when there is no child.
Functions ¶
This section is empty.
Types ¶
type Ref ¶
type Ref struct {
HasFullURL bool
HasURLPathOnly bool
HasFragmentOnly bool
HasFileScheme bool
HasFullFilePath bool
// contains filtered or unexported fields
}
Ref represents a json reference object.
func MustCreateRef ¶
MustCreateRef parses the ref string and panics when it's invalid. Use the New method for a version that returns an error.
func (*Ref) GetPointer ¶
func (r *Ref) GetPointer() *jsonpointer.Pointer
GetPointer gets the json pointer for this reference.
func (*Ref) GetURL ¶
GetURL gets the URL for this reference.
Example ¶
package main
import (
"fmt"
"github.com/go-openapi/jsonreference"
)
func main() {
fragRef := jsonreference.MustCreateRef("#/definitions/Pet")
fmt.Printf("URL: %s\n", fragRef.GetURL())
}
Output: URL: #/definitions/Pet
func (*Ref) Inherits ¶
Inherits creates a new reference from a parent and a child If the child cannot inherit from the parent, an error is returned.
Example ¶
package main
import (
"fmt"
"log"
"github.com/go-openapi/jsonreference"
)
func main() {
parent := jsonreference.MustCreateRef("http://example.com/base.json")
child, err := jsonreference.New("#/definitions/Pet")
if err != nil {
log.Printf("%v", err)
return
}
resolved, err := parent.Inherits(child)
if err != nil {
log.Printf("%v", err)
return
}
fmt.Printf("URL: %v\n", resolved)
}
Output: URL: http://example.com/base.json#/definitions/Pet
func (*Ref) IsCanonical ¶
IsCanonical returns true when this pointer starts with http(s):// or file://.
Click to show internal directories.
Click to hide internal directories.