This repository was archived by the owner on Sep 13, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package openapi
2+
3+ type Extensions struct {
4+ Example string `json:"x-example,omitempty" yaml:"x-example,omitempty"`
5+ Faker string `json:"x-faker,omitempty" yaml:"x-faker,omitempty"`
6+ }
Original file line number Diff line number Diff line change @@ -2,13 +2,11 @@ package openapi
22
33import (
44 "fmt"
5-
6- "github.com/goccy/go-yaml"
75)
86
97// Schema -.
108type Schema struct {
11- Extensions map [ string ] interface {} `json:"-" yaml:"-"`
9+ Extensions
1210
1311 Properties Schemas `json:"properties,omitempty" yaml:"properties,omitempty"`
1412 Type string `json:"type,omitempty" yaml:"type,omitempty"`
@@ -20,20 +18,9 @@ type Schema struct {
2018 Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
2119}
2220
23- // GetExtensions -.
24- func (s * Schema ) GetExtensions () (map [string ]interface {}, error ) {
25- bytes , err := yaml .Marshal (s .Extensions )
26- if err != nil {
27- return nil , err
28- }
29-
30- var extensions map [string ]interface {}
31-
32- if err := yaml .Unmarshal (bytes , & extensions ); err != nil {
33- return nil , err
34- }
35-
36- return extensions , nil
21+ // IsRef -.
22+ func (s Schema ) IsRef () bool {
23+ return s .Ref != ""
3724}
3825
3926// Schemas -.
Original file line number Diff line number Diff line change @@ -183,18 +183,3 @@ func TestSchema_ResponseByExample(t *testing.T) {
183183 })
184184 }
185185}
186-
187- func TestGetExtensions (t * testing.T ) {
188- s := openapi.Schema {
189- Extensions : map [string ]interface {}{
190- "x-example" : "x-example" ,
191- },
192- }
193-
194- e , err := s .GetExtensions ()
195- if err != nil {
196- t .Fatal (err )
197- }
198-
199- require .IsType (t , map [string ]interface {}{}, e )
200- }
You can’t perform that action at this time.
0 commit comments