func SpecTagsOrder(spec *openapi3.Spec, explicitSortedTagNames []string) error {
	curTags := spec.Tags
	sm := openapi3.SpecMore{Spec: spec}
	opTagNames := sm.TagsMap(false, true)
	for tagName := range opTagNames {
		curTags = append(curTags, &oas3.Tag{Name: tagName})
	}
	newTags, err := TagsOrder(curTags, explicitSortedTagNames)
	if err != nil {
		return err
	}
	spec.Tags = newTags
	return nil
}
SpecTagsOrder sorts a specs tags based on an input set
and explitcit sort order. The remaining tags are sorted
alphabetically.
package openapi3edit
import (
	"fmt"
	"sort"
	"strings"
	oas3 "github.com/getkin/kin-openapi/openapi3"
	"github.com/grokify/simplego/type/stringsutil"
	"github.com/grokify/spectrum/openapi3"
)
func SpecTagsModify(spec *openapi3.Spec, changeTagsRaw map[string]string) {
	changeTags := map[string]string{}
	for old, new := range changeTagsRaw {
		changeTags[strings.TrimSpace(old)] = strings.TrimSpace(new)
	}
TAG:
	for i, tag := range spec.Tags {
		tag.Name = strings.TrimSpace(tag.Name)
		if len(tag.Name) > 0 {
			for tOld, tNew := range changeTags {
				if tag.Name == tOld {
					tag.Name = tNew
					spec.Tags[i] = tag
					continue TAG
				}
			}
		}
	}
	openapi3.VisitOperations(spec, func(skipPath, skipMethod string, op *oas3.Operation) {
	TAG:
		for i, tagName := range op.Tags {
			tagName = strings.TrimSpace(tagName)
			if len(tagName) > 0 {
				for tOld, tNew := range changeTags {
					if tagName == tOld {
						op.Tags[i] = tNew
						continue TAG
					}
				}
			}
		}
	})
}