Skip to content

Commit e74139d

Browse files
authored
Merge pull request #574 from anagrius/master
Allow skipping validation of custom scalar codecs.
2 parents 208bbb8 + fd8308b commit e74139d

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

generator/src/Main.elm

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ type alias UrlArgs =
6767
, headers : Dict.Dict String String
6868
, scalarCodecsModule : Maybe ModuleName
6969
, skipElmFormat : Bool
70+
, skipValidation : Bool
7071
}
7172

7273

@@ -76,6 +77,7 @@ type alias FileArgs =
7677
, outputPath : String
7778
, scalarCodecsModule : Maybe ModuleName
7879
, skipElmFormat : Bool
80+
, skipValidation : Bool
7981
}
8082

8183

@@ -114,6 +116,7 @@ program =
114116
)
115117
|> with scalarCodecsOption
116118
|> with skipElmFormatOption
119+
|> with skipScalarCodecValidationOption
117120
|> OptionsParser.withDoc "generate files based on the schema at `url`"
118121
|> OptionsParser.map FromUrl
119122
)
@@ -124,6 +127,7 @@ program =
124127
|> with outputPathOption
125128
|> with scalarCodecsOption
126129
|> with skipElmFormatOption
130+
|> with skipScalarCodecValidationOption
127131
|> OptionsParser.map FromIntrospectionFile
128132
)
129133
|> Program.add
@@ -133,6 +137,7 @@ program =
133137
|> with outputPathOption
134138
|> with scalarCodecsOption
135139
|> with skipElmFormatOption
140+
|> with skipScalarCodecValidationOption
136141
|> OptionsParser.map FromSchemaFile
137142
)
138143

@@ -150,6 +155,11 @@ skipElmFormatOption =
150155
Option.flag "skip-elm-format"
151156

152157

158+
skipScalarCodecValidationOption : Option.Option Bool Bool Option.BeginningOption
159+
skipScalarCodecValidationOption =
160+
Option.flag "skip-validation"
161+
162+
153163
outputPathOption : Option.Option (Maybe String) String Option.BeginningOption
154164
outputPathOption =
155165
Option.optionalKeywordArg "output" |> Option.withDefault "./src"
@@ -183,7 +193,12 @@ init flags msg =
183193
, outputPath = options.outputPath
184194
, baseModule = options.base
185195
, headers = options.headers |> Json.Encode.dict identity Json.Encode.string
186-
, customDecodersModule = options.scalarCodecsModule |> Maybe.map ModuleName.toString
196+
, customDecodersModule =
197+
if options.skipValidation then
198+
Nothing
199+
200+
else
201+
options.scalarCodecsModule |> Maybe.map ModuleName.toString
187202
}
188203
)
189204

@@ -193,7 +208,12 @@ init flags msg =
193208
{ introspectionFilePath = options.file
194209
, outputPath = options.outputPath
195210
, baseModule = options.base
196-
, customDecodersModule = options.scalarCodecsModule |> Maybe.map ModuleName.toString
211+
, customDecodersModule =
212+
if options.skipValidation then
213+
Nothing
214+
215+
else
216+
options.scalarCodecsModule |> Maybe.map ModuleName.toString
197217
}
198218
)
199219

@@ -203,7 +223,12 @@ init flags msg =
203223
{ schemaFilePath = options.file
204224
, outputPath = options.outputPath
205225
, baseModule = options.base
206-
, customDecodersModule = options.scalarCodecsModule |> Maybe.map ModuleName.toString
226+
, customDecodersModule =
227+
if options.skipValidation then
228+
Nothing
229+
230+
else
231+
options.scalarCodecsModule |> Maybe.map ModuleName.toString
207232
}
208233
)
209234

0 commit comments

Comments
 (0)