Skip to content

Commit

Permalink
chore: code samples are ordered (#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRooney committed Sep 6, 2024
1 parent ab8acf1 commit fa8ff7f
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions internal/codesamples/codesamples.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import (
"bytes"
"context"
"fmt"
"github.com/speakeasy-api/speakeasy-core/yamlutil"
"github.com/speakeasy-api/speakeasy/internal/usagegen"
"os"
"path/filepath"

"github.com/speakeasy-api/openapi-overlay/pkg/overlay"
"github.com/speakeasy-api/speakeasy-core/yamlutil"
"github.com/speakeasy-api/speakeasy/internal/config"
"github.com/speakeasy-api/speakeasy/internal/log"
"github.com/speakeasy-api/speakeasy/internal/usagegen"
"gopkg.in/yaml.v3"
"os"
"path/filepath"
"sort"
)

type CodeSamplesStyle int
Expand Down Expand Up @@ -61,13 +61,19 @@ func GenerateOverlay(ctx context.Context, schema, header, token, configPath, ove
}

var actions []overlay.Action
for target, snippets := range targetToCodeSamples {
targets := []string{}
for target := range targetToCodeSamples {
targets = append(targets, target)
}
sort.Strings(targets)

for _, target := range targets {
snippets := targetToCodeSamples[target]
actions = append(actions, overlay.Action{
Target: target,
Update: *rootCodeSampleNode(snippets, style, isJSON),
})
}

extends := schema
title := fmt.Sprintf("CodeSamples overlay for %s", schema)
abs, err := filepath.Abs(schema)
Expand Down

0 comments on commit fa8ff7f

Please sign in to comment.