(t *testing.T)
| 157 | } |
| 158 | |
| 159 | func 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 | |
| 185 | func TestSortedSchemaKeysWithXOrderFromParsed(t *testing.T) { |
| 186 | rawSpec := `--- |
nothing calls this directly
no test coverage detected
searching dependent graphs…