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