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
21 changes: 12 additions & 9 deletions src/Common.elm
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Common exposing
( BasicType(..)
( AdditionalProperties(..)
, BasicType(..)
, Component(..)
, ConstValue(..)
, Field
, Module(..)
, Object
, OneOfData
, Package(..)
, RefTo
Expand Down Expand Up @@ -447,7 +447,11 @@ initialUppercaseWordToLowercase input =

type Type
= Nullable Type
| Object { isRecursive : Maybe UnsafeName } Object
| Object
{ isRecursive : Maybe UnsafeName
, additionalProperties : AdditionalProperties
, fields : List ( UnsafeName, Field )
}
| Basic
-- This is separate for easier pattern matching
BasicType
Expand All @@ -459,8 +463,6 @@ type Type
| List Type
| Tuple Type Type
| Triple Type Type Type
-- The type declared in additionalProperties, and a list of normal properties
| Dict { type_ : Type, documentation : Maybe String } Object
| OneOf TypeName ( OneOfData, List OneOfData )
| Enum ( UnsafeName, List UnsafeName )
| Value
Expand All @@ -469,6 +471,11 @@ type Type
| Unit


type AdditionalProperties
= AdditionalPropertiesAllowed { type_ : Type, documentation : Maybe String }
| AdditionalPropertiesDisallowed


type RefTo r
= RefTo Component UnsafeName

Expand Down Expand Up @@ -511,10 +518,6 @@ basicTypeToString basicType =
"number"


type alias Object =
List ( UnsafeName, Field )


type alias OneOfData =
{ name : UnsafeName
, type_ : Type
Expand Down
2 changes: 1 addition & 1 deletion src/JsonSchema/Generate.elm
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ nonEnumToDeclarations component name schema documentation type_ =
isRecursive : Bool
isRecursive =
case type_ of
Common.Object r _ ->
Common.Object r ->
r.isRecursive == Just name

_ ->
Expand Down
6 changes: 3 additions & 3 deletions src/OpenApi/Generate.elm
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,7 @@ multipartContent mediaType =
|> CliMonad.andThen
(\{ type_ } ->
case type_ of
Common.Object _ fields ->
Common.Object { fields } ->
fields
|> List.map
(\( fieldName, field ) ->
Expand Down Expand Up @@ -2207,7 +2207,7 @@ queryParameterToUrlBuilderArgument param =
Gen.Maybe.map build value
in
case type_ of
Common.Nullable (Common.Object _ fields) ->
Common.Nullable (Common.Object { fields }) ->
fields
|> CliMonad.combineMap
(\( fieldName, field ) ->
Expand All @@ -2219,7 +2219,7 @@ queryParameterToUrlBuilderArgument param =
|> CliMonad.withPath (Common.UnsafeName "query params (object)")
)

Common.Object _ fields ->
Common.Object { fields } ->
fields
|> CliMonad.combineMap
(\( fieldName, field ) ->
Expand Down
Loading
Loading