git.iko.soy/typeable/openapi3
on master help sign in
fix wrong prop type test
49b1f9bBen Weitzman
src/Data/Swagger/Schema/Generator.hs+2−1
@@ -71,7 +71,8 @@ schemaGen defns schema =
71 reqKeys = S.fromList $ schema ^. required
71 reqKeys = S.fromList $ schema ^. required
72 allKeys = S.fromList . M.keys $ schema ^. properties
72 allKeys = S.fromList . M.keys $ schema ^. properties
73 optionalKeys = allKeys S.\\ reqKeys
73 optionalKeys = allKeys S.\\ reqKeys
74+ minProps' = fromMaybe (length reqKeys) $
74− minProps' = fromMaybe 0 $ fromInteger <$> schema ^. minProperties
75+ fromInteger <$> schema ^. minProperties
75 maxProps' = fromMaybe size $ fromInteger <$> schema ^. maxProperties
76 maxProps' = fromMaybe size $ fromInteger <$> schema ^. maxProperties
76 shuffledOptional <- shuffle $ S.toList optionalKeys
77 shuffledOptional <- shuffle $ S.toList optionalKeys
77 numProps <- choose (minProps', max minProps' maxProps')
78 numProps <- choose (minProps', max minProps' maxProps')
test/Data/Swagger/Schema/GeneratorSpec.hs+3−3
@@ -150,7 +150,7 @@ instance ToSchema MissingProperty where
150 & required .~ ["propC"]
150 & required .~ ["propC"]
151
151
152data WrongPropType = WrongPropType
152data WrongPropType = WrongPropType
153− { propE :: Bool
153+ { propE :: String
154 }
154 }
155
155
156instance FromJSON WrongPropType where
156instance FromJSON WrongPropType where
@@ -160,8 +160,8 @@ instance FromJSON WrongPropType where
160
160
161instance ToSchema WrongPropType where
161instance ToSchema WrongPropType where
162 declareNamedSchema _ = do
162 declareNamedSchema _ = do
163− boolSchema <- declareSchemaRef (Proxy :: Proxy WrongPropType)
163+ boolSchema <- declareSchemaRef (Proxy :: Proxy Bool)
164− return . NamedSchema (Just "MissingRequired") $
164+ return . NamedSchema (Just "WrongPropType") $
165 mempty
165 mempty
166 & type_ .~ SwaggerObject
166 & type_ .~ SwaggerObject
167 & properties .~ [("propE", boolSchema)]
167 & properties .~ [("propE", boolSchema)]