@@ -65,7 +65,7 @@ func (s *OpenAPISpec) Endpoints() []Endpoint {
6565 Summary string `json:"summary"`
6666 Tags []string `json:"tags"`
6767 }
68- json .Unmarshal (raw , & detail )
68+ _ = json .Unmarshal (raw , & detail )
6969 tag := ""
7070 if len (detail .Tags ) > 0 {
7171 tag = detail .Tags [0 ]
@@ -114,7 +114,7 @@ func (s *OpenAPISpec) LookupEndpoint(method, path string) (*EndpointDetail, erro
114114 RequestBody json.RawMessage `json:"requestBody"`
115115 Responses json.RawMessage `json:"responses"`
116116 }
117- json .Unmarshal (raw , & parsed )
117+ _ = json .Unmarshal (raw , & parsed )
118118
119119 tag := ""
120120 if len (parsed .Tags ) > 0 {
@@ -133,7 +133,7 @@ func (s *OpenAPISpec) LookupEndpoint(method, path string) (*EndpointDetail, erro
133133 Type string `json:"type"`
134134 } `json:"schema"`
135135 }
136- json .Unmarshal (pRaw , & p )
136+ _ = json .Unmarshal (pRaw , & p )
137137 params = append (params , Parameter {
138138 Name : p .Name ,
139139 In : p .In ,
@@ -219,14 +219,14 @@ func (s *OpenAPISpec) resolveRef(raw json.RawMessage) any {
219219 var obj map [string ]json.RawMessage
220220 if err := json .Unmarshal (raw , & obj ); err != nil {
221221 var result any
222- json .Unmarshal (raw , & result )
222+ _ = json .Unmarshal (raw , & result )
223223 return result
224224 }
225225
226226 // Check for $ref
227227 if refRaw , ok := obj ["$ref" ]; ok {
228228 var ref string
229- json .Unmarshal (refRaw , & ref )
229+ _ = json .Unmarshal (refRaw , & ref )
230230 resolved := s .resolveComponentRef (ref )
231231 if resolved != nil {
232232 return resolved
@@ -235,7 +235,7 @@ func (s *OpenAPISpec) resolveRef(raw json.RawMessage) any {
235235
236236 // Otherwise return as generic map
237237 var result any
238- json .Unmarshal (raw , & result )
238+ _ = json .Unmarshal (raw , & result )
239239 return result
240240}
241241
@@ -263,7 +263,7 @@ func (s *OpenAPISpec) resolveComponentRef(ref string) any {
263263
264264 // Parse one level — don't recurse into nested $refs
265265 var schema any
266- json .Unmarshal (schemaRaw , & schema )
266+ _ = json .Unmarshal (schemaRaw , & schema )
267267 return schema
268268}
269269
@@ -299,9 +299,13 @@ func loadSpec(apiURL, cacheDir string, forceRefresh bool) (*OpenAPISpec, error)
299299 return nil , fmt .Errorf ("parsing OpenAPI spec: %w" , err )
300300 }
301301
302- // Write cache
303- os .MkdirAll (filepath .Dir (cachePath ), 0755 )
304- os .WriteFile (cachePath , data , 0644 )
302+ // Write cache (best-effort; ignore errors so a read-only cache dir doesn't break the command)
303+ if err := os .MkdirAll (filepath .Dir (cachePath ), 0755 ); err != nil {
304+ return & spec , nil
305+ }
306+ if err := os .WriteFile (cachePath , data , 0644 ); err != nil {
307+ return & spec , nil
308+ }
305309
306310 return & spec , nil
307311}
0 commit comments