File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- module JsonSchema.Generate exposing (schemaToDeclarations )
1+ module JsonSchema.Generate exposing (multipartFormDataRequestBodyToDeclarations , schemaToDeclarations )
22
33import CliMonad exposing (CliMonad )
44import Common
@@ -16,6 +16,43 @@ import NonEmpty
1616import SchemaUtils
1717
1818
19+ multipartFormDataRequestBodyToDeclarations : Common .UnsafeName -> Json .Schema .Definitions .Schema -> CliMonad (List CliMonad .Declaration )
20+ multipartFormDataRequestBodyToDeclarations name schema =
21+ SchemaUtils . schemaToType [] schema
22+ |> CliMonad . andThen
23+ ( \ { type_, documentation } ->
24+ type_
25+ |> SchemaUtils . typeToAnnotationWithNullable
26+ |> CliMonad . map
27+ ( \ annotation ->
28+ let
29+ typeName : Common . TypeName
30+ typeName =
31+ Common . toTypeName name
32+ in
33+ if ( Elm . ToString . annotation annotation) . signature == typeName then
34+ []
35+
36+ else
37+ [ { moduleName = Common . Types Common . RequestBody
38+ , name = typeName
39+ , declaration =
40+ Elm . alias typeName annotation
41+ |> ( case documentation of
42+ Nothing ->
43+ identity
44+
45+ Just doc ->
46+ Elm . withDocumentation doc
47+ )
48+ |> Elm . expose
49+ , group = " Aliases"
50+ }
51+ ]
52+ )
53+ )
54+
55+
1956schemaToDeclarations : Common .Component -> Common .UnsafeName -> Json .Schema .Definitions .Schema -> CliMonad (List CliMonad .Declaration )
2057schemaToDeclarations component name schema =
2158 SchemaUtils . schemaToType [] schema
You can’t perform that action at this time.
0 commit comments