mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 20:47:44 +00:00
chore: update to use iterators on orderedmaps
This commit is contained in:
committed by
quobix
parent
c3eb16d4e4
commit
161a41f73b
@@ -128,16 +128,14 @@ func (mg *MockGenerator) GenerateMock(mock any, name string) ([]byte, error) {
|
||||
examplesMap := examplesValue.(*orderedmap.Map[string, *highbase.Example])
|
||||
|
||||
// if the name is not empty, try and find the example by name
|
||||
for pair := orderedmap.First(examplesMap); pair != nil; pair = pair.Next() {
|
||||
k, exp := pair.Key(), pair.Value()
|
||||
for k, exp := range examplesMap.FromOldest() {
|
||||
if k == name {
|
||||
return mg.renderMock(exp.Value), nil
|
||||
}
|
||||
}
|
||||
|
||||
// if the name is empty, just return the first example
|
||||
for pair := orderedmap.First(examplesMap); pair != nil; pair = pair.Next() {
|
||||
exp := pair.Value()
|
||||
for exp := range examplesMap.ValuesFromOldest() {
|
||||
return mg.renderMock(exp.Value), nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user