MCPcopy Index your code
hub / github.com/oapi-codegen/oapi-codegen / TestSortedSchemaKeysWithXOrder

Function TestSortedSchemaKeysWithXOrder

pkg/codegen/utils_test.go:159–183  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

157}
158
159func TestSortedSchemaKeysWithXOrder(t *testing.T) {
160 withOrder := func(i float64) *openapi3.SchemaRef {
161 return &openapi3.SchemaRef{
162 Value: &openapi3.Schema{
163 Extensions: map[string]any{"x-order": i},
164 },
165 }
166 }
167 dict := map[string]*openapi3.SchemaRef{
168 "first": withOrder(1),
169 "minusTenth": withOrder(-10),
170 "zero": withOrder(0),
171 "minusHundredth_2": withOrder(-100),
172 "minusHundredth_1": withOrder(-100),
173 "afterFirst": withOrder(2),
174 "last": withOrder(100),
175 "middleA": nil,
176 "middleB": nil,
177 "middleC": nil,
178 }
179
180 expected := []string{"minusHundredth_1", "minusHundredth_2", "minusTenth", "zero", "first", "afterFirst", "middleA", "middleB", "middleC", "last"}
181
182 assert.EqualValues(t, expected, SortedSchemaKeys(dict), "Keys are not sorted properly")
183}
184
185func TestSortedSchemaKeysWithXOrderFromParsed(t *testing.T) {
186 rawSpec := `---

Callers

nothing calls this directly

Calls 1

SortedSchemaKeysFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…