File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 1
1
module github.com/getkin/kin-openapi
2
2
3
- go 1.14
3
+ go 1.16
4
4
5
5
require (
6
6
github.com/ghodss/yaml v1.0.0
Original file line number Diff line number Diff line change
1
+ package openapi3_test
2
+
3
+ import (
4
+ "embed"
5
+ "fmt"
6
+ "net/url"
7
+
8
+ "github.com/getkin/kin-openapi/openapi3"
9
+ )
10
+
11
+ //go:embed testdata/recursiveRef/*
12
+ var fs embed.FS
13
+
14
+ func Example () {
15
+ loader := openapi3 .NewSwaggerLoader ()
16
+ loader .IsExternalRefsAllowed = true
17
+ loader .ReadFromURIFunc = func (loader * openapi3.SwaggerLoader , uri * url.URL ) ([]byte , error ) {
18
+ return fs .ReadFile (uri .Path )
19
+ }
20
+
21
+ doc , err := loader .LoadSwaggerFromFile ("testdata/recursiveRef/openapi.yml" )
22
+ if err != nil {
23
+ panic (err )
24
+ }
25
+
26
+ if err = doc .Validate (loader .Context ); err != nil {
27
+ panic (err )
28
+ }
29
+
30
+ fmt .Println (doc .Paths ["/foo" ].Get .Responses ["200" ].Value .Content ["application/json" ].Schema .Value .Properties ["foo" ].Value .Properties ["bar" ].Value .Type )
31
+ // Output: array
32
+ }
You can’t perform that action at this time.
0 commit comments