mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 04:20:11 +00:00
Added all component schema to prevent allocations.
This function runs a lot and `syncMapToMap` is slow. The function is idepmotent so a cache prevents a lot of un-nessecary burn.
This commit is contained in:
@@ -254,6 +254,7 @@ type SpecIndex struct {
|
|||||||
allComponentSchemaDefinitions *sync.Map // all schemas found in components (openapi) or definitions (swagger).
|
allComponentSchemaDefinitions *sync.Map // all schemas found in components (openapi) or definitions (swagger).
|
||||||
securitySchemesNode *yaml.Node // components/securitySchemes node
|
securitySchemesNode *yaml.Node // components/securitySchemes node
|
||||||
allSecuritySchemes map[string]*Reference // all security schemes / definitions.
|
allSecuritySchemes map[string]*Reference // all security schemes / definitions.
|
||||||
|
allComponentSchemas map[string]*Reference // all component schemas
|
||||||
requestBodiesNode *yaml.Node // components/requestBodies node
|
requestBodiesNode *yaml.Node // components/requestBodies node
|
||||||
allRequestBodies map[string]*Reference // all request bodies
|
allRequestBodies map[string]*Reference // all request bodies
|
||||||
responsesNode *yaml.Node // components/responses node
|
responsesNode *yaml.Node // components/responses node
|
||||||
|
|||||||
@@ -328,7 +328,15 @@ func (index *SpecIndex) GetAllReferenceSchemas() []*Reference {
|
|||||||
|
|
||||||
// GetAllComponentSchemas will return all schemas defined in the components section of the document.
|
// GetAllComponentSchemas will return all schemas defined in the components section of the document.
|
||||||
func (index *SpecIndex) GetAllComponentSchemas() map[string]*Reference {
|
func (index *SpecIndex) GetAllComponentSchemas() map[string]*Reference {
|
||||||
return syncMapToMap[string, *Reference](index.allComponentSchemaDefinitions)
|
if index != nil && index.allComponentSchemas != nil {
|
||||||
|
return index.allComponentSchemas
|
||||||
|
}
|
||||||
|
if index != nil && index.allComponentSchemas == nil {
|
||||||
|
schemaMap := syncMapToMap[string, *Reference](index.allComponentSchemaDefinitions)
|
||||||
|
index.allComponentSchemas = schemaMap
|
||||||
|
return index.allComponentSchemas
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAllSecuritySchemes will return all security schemes / definitions found in the document.
|
// GetAllSecuritySchemes will return all security schemes / definitions found in the document.
|
||||||
|
|||||||
Reference in New Issue
Block a user