forked from go-openapi/jsonreference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples_test.go
More file actions
40 lines (28 loc) · 785 Bytes
/
examples_test.go
File metadata and controls
40 lines (28 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// SPDX-FileCopyrightText: Copyright (c) 2015-2025 go-swagger maintainers
// SPDX-License-Identifier: Apache-2.0
package jsonreference_test
import (
"fmt"
"log"
"github.com/go-openapi/jsonreference"
)
func ExampleRef_GetURL() {
fragRef := jsonreference.MustCreateRef("#/definitions/Pet")
fmt.Printf("URL: %s\n", fragRef.GetURL())
// Output: URL: #/definitions/Pet
}
func ExampleRef_Inherits() {
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
}