@@ -96,57 +96,56 @@ func (sp *SchemaProxy) Schema() *Schema {
9696 if sp .rendered != nil {
9797 return sp .rendered
9898 }
99- if sp .rendered == nil {
100- if sp .schema == nil || sp .schema .Value == nil {
101- return nil
102- }
10399
104- sp .lock .Lock ()
105-
106- //check the high-level cache first.
107- idx := sp .schema .Value .GetIndex ()
108- if idx != nil && sp .schema .Value != nil {
109- if sp .schema .Value .IsReference () && sp .schema .Value .GetReferenceNode () != nil && sp .schema .GetValueNode () != nil {
110- loc := fmt .Sprintf ("%s:%d:%d" , idx .GetSpecAbsolutePath (), sp .schema .GetValueNode ().Line , sp .schema .GetValueNode ().Column )
111- if seen , ok := idx .GetHighCache ().Load (loc ); ok {
112- sp .lock .Unlock ()
113- idx .HighCacheHit ()
114- return seen .(* Schema )
115- } else {
116- idx .HighCacheMiss ()
117- }
100+ if sp .schema == nil || sp .schema .Value == nil {
101+ return nil
102+ }
103+
104+ sp .lock .Lock ()
105+
106+ //check the high-level cache first.
107+ idx := sp .schema .Value .GetIndex ()
108+ if idx != nil && sp .schema .Value != nil {
109+ if sp .schema .Value .IsReference () && sp .schema .Value .GetReferenceNode () != nil && sp .schema .GetValueNode () != nil {
110+ loc := fmt .Sprintf ("%s:%d:%d" , idx .GetSpecAbsolutePath (), sp .schema .GetValueNode ().Line , sp .schema .GetValueNode ().Column )
111+ if seen , ok := idx .GetHighCache ().Load (loc ); ok {
112+ sp .lock .Unlock ()
113+ idx .HighCacheHit ()
114+ return seen .(* Schema )
115+ } else {
116+ idx .HighCacheMiss ()
118117 }
119118 }
119+ }
120120
121- s := sp .schema .Value .Schema ()
122- if s == nil {
123- sp .buildError = sp .schema .Value .GetBuildError ()
124- sp .lock .Unlock ()
125- return nil
126- }
127- sch := NewSchema (s )
121+ s := sp .schema .Value .Schema ()
122+ if s == nil {
123+ sp .buildError = sp .schema .Value .GetBuildError ()
124+ sp .lock .Unlock ()
125+ return nil
126+ }
127+ sch := NewSchema (s )
128128
129- if idx != nil {
129+ if idx != nil {
130130
131- // only store the schema in the cache if is a reference!
132- if sp .IsReference () && sp .GetReferenceNode () != nil && sp .schema != nil && sp .schema .GetValueNode () != nil {
133- //if sp.schema.GetValueNode() != nil {
134- loc := fmt .Sprintf ("%s:%d:%d" , idx .GetSpecAbsolutePath (), sp .schema .GetValueNode ().Line , sp .schema .GetValueNode ().Column )
131+ // only store the schema in the cache if is a reference!
132+ if sp .IsReference () && sp .GetReferenceNode () != nil && sp .schema != nil && sp .schema .GetValueNode () != nil {
133+ //if sp.schema.GetValueNode() != nil {
134+ loc := fmt .Sprintf ("%s:%d:%d" , idx .GetSpecAbsolutePath (), sp .schema .GetValueNode ().Line , sp .schema .GetValueNode ().Column )
135135
136- // caching is only performed on traditional $ref nodes with a reference and a value node, any 3.1 additional
137- // will not be cached as libopenapi does not yet support them.
138- if len (sp .GetReferenceNode ().Content ) == 2 {
139- idx .GetHighCache ().Store (loc , sch )
140- }
136+ // caching is only performed on traditional $ref nodes with a reference and a value node, any 3.1 additional
137+ // will not be cached as libopenapi does not yet support them.
138+ if len (sp .GetReferenceNode ().Content ) == 2 {
139+ idx .GetHighCache ().Store (loc , sch )
141140 }
142141 }
143-
144- sch .ParentProxy = sp
145- sp .rendered = sch
146- sp .lock .Unlock ()
147- return sch
148142 }
149- return nil
143+
144+ sch .ParentProxy = sp
145+ sp .rendered = sch
146+ sp .lock .Unlock ()
147+ return sch
148+
150149}
151150
152151// IsReference returns true if the SchemaProxy is a reference to another Schema.
@@ -273,7 +272,7 @@ func (sp *SchemaProxy) MarshalYAMLInline() (interface{}, error) {
273272 if sp .GetReference () == c .LoopPoint .Definition {
274273 // nope
275274 return sp .GetReferenceNode (),
276- fmt .Errorf ("cannot render circular reference: %s" , c .LoopPoint .Definition )
275+ fmt .Errorf ("cannot render circular reference: %s" , c .LoopPoint .Definition )
277276 }
278277 basePath := sp .GoLow ().GetIndex ().GetSpecAbsolutePath ()
279278
0 commit comments