diff --git a/layouts/partials/rest-apis/is-operation-included.html b/layouts/partials/rest-apis/is-operation-included.html index 2f3cce00493..2d5ec787789 100644 --- a/layouts/partials/rest-apis/is-operation-included.html +++ b/layouts/partials/rest-apis/is-operation-included.html @@ -1,21 +1,19 @@ {{ $operation := .operation | default . }} {{ $audience := .audience | default "cloud" }} {{ $xInternal := index $operation "x-internal" }} -{{ $include := false }} +{{ $values := slice }} -{{ if not $xInternal }} - {{ $include = true }} -{{ else }} - {{ $values := slice }} - {{ if reflect.IsSlice $xInternal }} - {{ $values = $xInternal }} +{{ with $xInternal }} + {{ if reflect.IsSlice . }} + {{ $values = . }} {{ else }} - {{ $values = slice $xInternal }} + {{ $values = slice . }} {{ end }} +{{ end }} - {{ if in $values $audience }} - {{ $include = true }} - {{ end }} +{{ $include := false }} +{{ if in $values $audience }} + {{ $include = true }} {{ end }} {{- if $include -}}true{{- else -}}false{{- end -}} diff --git a/layouts/partials/rest-apis/viewer.html b/layouts/partials/rest-apis/viewer.html index 0661c612015..5bac898e59c 100644 --- a/layouts/partials/rest-apis/viewer.html +++ b/layouts/partials/rest-apis/viewer.html @@ -16,8 +16,6 @@ {{ $methodOrder := slice "get" "post" "put" "patch" "delete" "options" "head" }} {{ $operations := slice }} {{ $tagCounts := dict }} -{{ $cloudOnlyCount := 0 }} -{{ $sharedCount := 0 }} {{ range $path, $route := $spec.paths }} {{ range $methodOrder }} @@ -25,7 +23,6 @@ {{ with index $route $method }} {{ $operation := . }} {{ $includeOperation := eq (partial "rest-apis/is-operation-included.html" (dict "operation" $operation "audience" "cloud") | strings.TrimSpace) "true" }} - {{ $xInternal := index $operation "x-internal" }} {{ if $includeOperation }} {{ $servers := index $operation "servers" | default (index $route "servers") | default ($spec.servers | default (slice)) }} {{ $tagName := "Ungrouped" }} @@ -41,13 +38,6 @@ {{ $pathSlug = "root" }} {{ end }} {{ $operationID := printf "%s-%s" $method $pathSlug }} - {{ $isShared := not $xInternal }} - - {{ if $isShared }} - {{ $sharedCount = add $sharedCount 1 }} - {{ else }} - {{ $cloudOnlyCount = add $cloudOnlyCount 1 }} - {{ end }} {{ $operations = $operations | append (dict "id" $operationID @@ -59,7 +49,6 @@ "tag" $tagName "tagLabel" (index $tagMeta "label") "tagDescription" (index $tagMeta "description") - "isShared" $isShared "servers" $servers "data" $operation ) }} @@ -91,6 +80,50 @@ {{ end }} {{ end }} +{{ $baseTagLabels := dict }} +{{ $baseTagLabelCounts := dict }} +{{ range $tagName := $orderedTags }} + {{ $tagMeta := partial "rest-apis/tag-meta.html" (dict "name" $tagName "tags" $tagIndex) | transform.Unmarshal (dict "format" "json") }} + {{ $baseLabel := index $tagMeta "label" | default "Ungrouped" }} + {{ $baseTagLabels = merge $baseTagLabels (dict $tagName $baseLabel) }} + {{ $baseCount := index $baseTagLabelCounts $baseLabel | default 0 }} + {{ $baseTagLabelCounts = merge $baseTagLabelCounts (dict $baseLabel (add $baseCount 1)) }} +{{ end }} + +{{ $tagLabels := dict }} +{{ $sortedTagEntries := slice }} +{{ range $tagName := $orderedTags }} + {{ $baseLabel := index $baseTagLabels $tagName | default "Ungrouped" }} + {{ $resolvedLabel := $baseLabel }} + {{ if gt (index $baseTagLabelCounts $baseLabel | default 0) 1 }} + {{ $parts := split $tagName "_" }} + {{ $suffixParts := after 1 $parts }} + {{ $suffixLabel := delimit $suffixParts " " }} + {{ if ne $suffixLabel "" }} + {{ $suffixLabel = $suffixLabel | title }} + {{ end }} + {{ if and (ne $suffixLabel "") (ne (lower $suffixLabel) (lower $baseLabel)) }} + {{ $resolvedLabel = printf "%s %s" $baseLabel $suffixLabel }} + {{ end }} + {{ end }} + {{ $tagLabels = merge $tagLabels (dict $tagName $resolvedLabel) }} + {{ $sortedTagEntries = $sortedTagEntries | append (dict + "name" $tagName + "label" $resolvedLabel + ) }} +{{ end }} +{{ $sortedTagEntries = sort $sortedTagEntries "label" }} +{{ $orderedTags = slice }} +{{ range $sortedTagEntries }} + {{ $orderedTags = $orderedTags | append .name }} +{{ end }} + +{{ $normalizedOperations := slice }} +{{ range $operations }} + {{ $normalizedOperations = $normalizedOperations | append (merge . (dict "tagLabel" ((index $tagLabels .tag) | default .tagLabel))) }} +{{ end }} +{{ $operations = $normalizedOperations }} + {{ if gt (len $operations) 0 }}