git.iko.soy/typeable/openapi3
on master help sign in
fix wrong prop type test
commit49b1f9b43858db7969f295ca56f46036190cd603 authorBen Weitzman <benweitzman@gmail.com> dateWed 15 Aug 2018, 09:18 (8 years ago) parent357f72d
2 files changed+5−4
src/Data/Swagger/Schema/Generator.hs+2−1 test/Data/Swagger/Schema/GeneratorSpec.hs+3−3
src/Data/Swagger/Schema/Generator.hs+2−1
@@ -71,7 +71,8 @@ schemaGen defns schema =
7171 reqKeys = S.fromList $ schema ^. required
7272 allKeys = S.fromList . M.keys $ schema ^. properties
7373 optionalKeys = allKeys S.\\ reqKeys
74− minProps' = fromMaybe 0 $ fromInteger <$> schema ^. minProperties
74+ minProps' = fromMaybe (length reqKeys) $
75+ fromInteger <$> schema ^. minProperties
7576 maxProps' = fromMaybe size $ fromInteger <$> schema ^. maxProperties
7677 shuffledOptional <- shuffle $ S.toList optionalKeys
7778 numProps <- choose (minProps', max minProps' maxProps')
test/Data/Swagger/Schema/GeneratorSpec.hs+3−3
@@ -150,7 +150,7 @@ instance ToSchema MissingProperty where
150150 & required .~ ["propC"]
151151
152152data WrongPropType = WrongPropType
153− { propE :: Bool
153+ { propE :: String
154154 }
155155
156156instance FromJSON WrongPropType where
@@ -160,8 +160,8 @@ instance FromJSON WrongPropType where
160160
161161instance ToSchema WrongPropType where
162162 declareNamedSchema _ = do
163− boolSchema <- declareSchemaRef (Proxy :: Proxy WrongPropType)
164− return . NamedSchema (Just "MissingRequired") $
163+ boolSchema <- declareSchemaRef (Proxy :: Proxy Bool)
164+ return . NamedSchema (Just "WrongPropType") $
165165 mempty
166166 & type_ .~ SwaggerObject
167167 & properties .~ [("propE", boolSchema)]