Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"mdgriffith/elm-codegen": "5.2.0",
"miniBill/elm-fast-dict": "1.2.4",
"myrho/yaml": "1.0.0",
"robinheghan/murmur3": "1.0.0",
"turboMaCk/non-empty-list-alias": "1.4.0",
"wolfadex/elm-ansi": "3.0.0",
"wolfadex/elm-open-api": "2.0.0"
Expand Down Expand Up @@ -55,7 +56,6 @@
"myrho/elm-parser-extras": "1.0.1",
"noahzgordon/elm-color-extra": "1.0.2",
"robinheghan/fnv1a": "1.0.0",
"robinheghan/murmur3": "1.0.0",
"rtfeldman/elm-css": "18.0.0",
"rtfeldman/elm-hex": "1.0.0",
"rtfeldman/elm-iso8601-date-strings": "1.1.4",
Expand Down
1 change: 1 addition & 0 deletions elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"json-tools/json-schema": "1.0.0 <= v < 2.0.0",
"mdgriffith/elm-codegen": "5.2.0 <= v < 6.0.0",
"miniBill/elm-fast-dict": "1.2.0 <= v < 2.0.0",
"robinheghan/murmur3": "1.0.0 <= v < 2.0.0",
"turboMaCk/non-empty-list-alias": "1.4.0 <= v < 2.0.0",
"wolfadex/elm-open-api": "2.0.0 <= v < 3.0.0"
},
Expand Down
15 changes: 12 additions & 3 deletions src/SchemaUtils.elm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import Json.Decode
import Json.Encode
import Json.Schema.Definitions
import Maybe.Extra
import Murmur3
import OpenApi
import OpenApi.Common.Internal
import OpenApi.Components
Expand Down Expand Up @@ -510,12 +511,20 @@ oneOfType types =
names : List Common.UnsafeName
names =
List.map .name sortedVariants

readableName : String
readableName =
names
|> List.map fixOneOfName
|> String.join "_Or_"
in
{ type_ =
Common.OneOf
(names
|> List.map fixOneOfName
|> String.join "_Or_"
(if String.length readableName > 200 then
"OneOf" ++ String.fromInt (Murmur3.hashString 1234 readableName)

else
readableName
)
sortedVariants
, documentation =
Expand Down