Skip to content

Commit e247a28

Browse files
committed
Update docs to deal with #309
I am not going to re-build the functions myself, there is little gain, however I have documented the behavior clearly.
1 parent bd5b0fe commit e247a28

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

index/spec_index.go

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,17 @@ func (index *SpecIndex) GetOperationParameterReferences() map[string]map[string]
340340
return index.paramOpRefs
341341
}
342342

343-
// GetAllSchemas will return references to all schemas found in the document both inline and those under components
344-
// The first elements of at the top of the slice, are all the inline references (using GetAllInlineSchemas),
345-
// and then following on are all the references extracted from the components section (using GetAllComponentSchemas).
346-
// finally all the references that are not inline, but marked as $ref in the document are returned (using GetAllReferenceSchemas).
347-
// the results are sorted by line number.
343+
// GetAllSchemas returns references to ALL schemas found in the document:
344+
// - Inline schemas (defined directly in operations, parameters, etc.)
345+
// - Component schemas (defined under components/schemas or definitions)
346+
// - Reference schemas ($ref pointers to schemas)
347+
//
348+
// Results are sorted by line number in the source document.
349+
//
350+
// Note: This is the only GetAll* function that returns inline and $ref variants.
351+
// Other GetAll* functions (GetAllRequestBodies, GetAllResponses, etc.) only return
352+
// items defined in the components section. Use GetAllInlineSchemas, GetAllComponentSchemas,
353+
// and GetAllReferenceSchemas for more granular access.
348354
func (index *SpecIndex) GetAllSchemas() []*Reference {
349355
componentSchemas := index.GetAllComponentSchemas()
350356
inlineSchemas := index.GetAllInlineSchemas()
@@ -413,12 +419,14 @@ func (index *SpecIndex) GetAllComponentSchemas() map[string]*Reference {
413419
return index.allComponentSchemas
414420
}
415421

416-
// GetAllSecuritySchemes will return all security schemes / definitions found in the document.
422+
// GetAllSecuritySchemes returns all security schemes defined in the components section
423+
// (components/securitySchemes in OpenAPI 3.x, or securityDefinitions in Swagger 2.0).
417424
func (index *SpecIndex) GetAllSecuritySchemes() map[string]*Reference {
418425
return syncMapToMap[string, *Reference](index.allSecuritySchemes)
419426
}
420427

421-
// GetAllHeaders will return all headers found in the document (under components)
428+
// GetAllHeaders returns all headers defined in the components section (components/headers).
429+
// This does not include inline headers defined directly in operations or $ref pointers.
422430
func (index *SpecIndex) GetAllHeaders() map[string]*Reference {
423431
return index.allHeaders
424432
}
@@ -428,7 +436,8 @@ func (index *SpecIndex) GetAllExternalDocuments() map[string]*Reference {
428436
return index.allExternalDocuments
429437
}
430438

431-
// GetAllExamples will return all examples found in the document (under components)
439+
// GetAllExamples returns all examples defined in the components section (components/examples).
440+
// This does not include inline examples defined directly in operations or $ref pointers.
432441
func (index *SpecIndex) GetAllExamples() map[string]*Reference {
433442
return index.allExamples
434443
}
@@ -453,32 +462,40 @@ func (index *SpecIndex) GetAllSummaries() []*DescriptionReference {
453462
return index.allSummaries
454463
}
455464

456-
// GetAllRequestBodies will return all requestBodies found in the document (under components)
465+
// GetAllRequestBodies returns all request bodies defined in the components section (components/requestBodies).
466+
// This does not include inline request bodies defined directly in operations or $ref pointers.
457467
func (index *SpecIndex) GetAllRequestBodies() map[string]*Reference {
458468
return index.allRequestBodies
459469
}
460470

461-
// GetAllLinks will return all links found in the document (under components)
471+
// GetAllLinks returns all links defined in the components section (components/links).
472+
// This does not include inline links defined directly in responses or $ref pointers.
462473
func (index *SpecIndex) GetAllLinks() map[string]*Reference {
463474
return index.allLinks
464475
}
465476

466-
// GetAllParameters will return all parameters found in the document (under components)
477+
// GetAllParameters returns all parameters defined in the components section (components/parameters).
478+
// This does not include inline parameters defined directly in operations or path items.
479+
// For operation-level parameters, use GetOperationParameterReferences.
467480
func (index *SpecIndex) GetAllParameters() map[string]*Reference {
468481
return index.allParameters
469482
}
470483

471-
// GetAllResponses will return all responses found in the document (under components)
484+
// GetAllResponses returns all responses defined in the components section (components/responses).
485+
// This does not include inline responses defined directly in operations or $ref pointers.
472486
func (index *SpecIndex) GetAllResponses() map[string]*Reference {
473487
return index.allResponses
474488
}
475489

476-
// GetAllCallbacks will return all links found in the document (under components)
490+
// GetAllCallbacks returns all callbacks defined in the components section (components/callbacks).
491+
// This does not include inline callbacks defined directly in operations or $ref pointers.
477492
func (index *SpecIndex) GetAllCallbacks() map[string]*Reference {
478493
return index.allCallbacks
479494
}
480495

481-
// GetAllComponentPathItems will return all path items found in the document (under components)
496+
// GetAllComponentPathItems returns all path items defined in the components section (components/pathItems).
497+
// This does not include path items defined directly under the paths object or $ref pointers.
498+
// For paths-level path items, use GetAllPaths.
482499
func (index *SpecIndex) GetAllComponentPathItems() map[string]*Reference {
483500
return index.allComponentPathItems
484501
}

0 commit comments

Comments
 (0)