Skip to content
Open
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
71 changes: 39 additions & 32 deletions src/OpenApi/Generate.elm
Original file line number Diff line number Diff line change
Expand Up @@ -1970,39 +1970,46 @@ multipartContent mediaType =
CliMonad.fail "Missing schema"

Just schema ->
SchemaUtils.schemaToType [] (OpenApi.Schema.get schema)
|> CliMonad.andThen
(\{ type_ } ->
case type_ of
Common.Object { fields } ->
fields
|> List.map
(\( fieldName, field ) ->
{ name = fieldName
, required = field.required
, part =
case field.type_ of
Common.Basic Common.String { format } ->
case format of
Just "binary" ->
BytesPart

_ ->
StringPart

Common.Bytes ->
BytesPart

_ ->
JsonPart field.type_
}
)
|> MultipartContent
|> CliMonad.succeed
let
finishMultipart : { type_ : Common.Type, documentation : Maybe String } -> CliMonad ContentSchema
finishMultipart { type_ } =
case type_ of
Common.Object { fields } ->
fields
|> List.map
(\( fieldName, field ) ->
{ name = fieldName
, required = field.required
, part =
case field.type_ of
Common.Basic Common.String { format } ->
case format of
Just "binary" ->
BytesPart

_ ->
StringPart

Common.Bytes ->
BytesPart

_ ->
JsonPart field.type_
}
)
|> MultipartContent
|> CliMonad.succeed

_ ->
CliMonad.fail ("Schema with a type of " ++ SchemaUtils.typeToString type_ ++ " not supported")
)
Common.Ref ref ->
SchemaUtils.getSchema ref
|> CliMonad.andThen (SchemaUtils.schemaToType [])
|> CliMonad.andThen finishMultipart

_ ->
CliMonad.fail ("Schema with a type of " ++ SchemaUtils.typeToString type_ ++ " not supported")
in
SchemaUtils.schemaToType [] (OpenApi.Schema.get schema)
|> CliMonad.andThen finishMultipart


toConfigParamAnnotation :
Expand Down
Loading