packages feed

autodocodec-schema 0.2.0.1 → 0.2.0.2

raw patch · 3 files changed

+25/−9 lines, 3 filesdep ~autodocodecPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: autodocodec

API changes (from Hackage documentation)

- Autodocodec.Schema: StringSchema :: JSONSchema
+ Autodocodec.Schema: StringSchema :: !StringBounds -> JSONSchema
- Autodocodec.Schema: jsonObjectSchemaViaCodec :: forall a. HasObjectCodec a => ObjectSchema
+ Autodocodec.Schema: jsonObjectSchemaViaCodec :: HasObjectCodec a => ObjectSchema
- Autodocodec.Schema: jsonSchemaViaCodec :: forall a. HasCodec a => JSONSchema
+ Autodocodec.Schema: jsonSchemaViaCodec :: HasCodec a => JSONSchema

Files

CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog +## [0.2.0.2] - 2026-07-14++### Changed++* Lower bound on `autodocodec >=0.6`+ ## [0.2.0.1] - 2025-02-13  ### Added
autodocodec-schema.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.36.0.+-- This file has been generated from package.yaml by hpack version 0.38.3. -- -- see: https://github.com/sol/hpack  name:           autodocodec-schema-version:        0.2.0.1+version:        0.2.0.2 synopsis:       Autodocodec interpreters for JSON Schema homepage:       https://github.com/NorfairKing/autodocodec#readme bug-reports:    https://github.com/NorfairKing/autodocodec/issues@@ -32,7 +32,7 @@       src   build-depends:       aeson-    , autodocodec >=0.4.0.0+    , autodocodec >=0.6.0.0     , base >=4.7 && <5     , containers     , mtl
src/Autodocodec/Schema.hs view
@@ -56,7 +56,7 @@   = AnySchema   | NullSchema   | BoolSchema-  | StringSchema+  | StringSchema !StringBounds   | IntegerSchema !(Bounds Integer)   | NumberSchema !(Bounds Scientific)   | ArraySchema !JSONSchema@@ -92,7 +92,12 @@         AnySchema -> []         NullSchema -> ["type" JSON..= ("null" :: Text)]         BoolSchema -> ["type" JSON..= ("boolean" :: Text)]-        StringSchema -> ["type" JSON..= ("string" :: Text)]+        StringSchema StringBounds {..} ->+          catMaybes+            [ Just ("type" JSON..= ("string" :: Text)),+              ("maxLength" JSON..=) <$> stringBoundsMaxLength,+              ("minLength" JSON..=) <$> stringBoundsMinLength+            ]         IntegerSchema Bounds {..} ->           catMaybes             [ Just ("type" JSON..= ("integer" :: Text)),@@ -144,7 +149,10 @@     fmap (commentFunc . defsFunc) $ case mt :: Maybe Text of       Just "null" -> pure NullSchema       Just "boolean" -> pure BoolSchema-      Just "string" -> pure StringSchema+      Just "string" -> do+        stringBoundsMinLength <- o JSON..:? "minLength"+        stringBoundsMaxLength <- o JSON..:? "maxLength"+        pure $ StringSchema StringBounds {..}       Just "integer" -> do         boundsLower <- o JSON..:? "minimum"         boundsUpper <- o JSON..:? "maximum"@@ -295,7 +303,7 @@ goValue = \case   NullCodec -> pure NullSchema   BoolCodec mname -> pure $ maybe id CommentSchema mname BoolSchema-  StringCodec mname -> pure $ maybe id CommentSchema mname StringSchema+  StringCodec mname mBounds -> pure $ maybe id CommentSchema mname $ StringSchema mBounds   IntegerCodec mname mBounds -> pure $ maybe id CommentSchema mname $ IntegerSchema mBounds   NumberCodec mname mBounds -> pure $ maybe id CommentSchema mname $ NumberSchema mBounds   ArrayOfCodec mname c -> do@@ -419,8 +427,10 @@   BoolSchema -> pure $ case value of     JSON.Bool _ -> True     _ -> False-  StringSchema -> pure $ case value of-    JSON.String _ -> True+  StringSchema bounds -> pure $ case value of+    JSON.String s -> case checkStringBounds bounds s of+      Left _ -> False+      Right _ -> True     _ -> False   IntegerSchema bounds -> pure $ case value of     JSON.Number s -> case checkBounds (fromInteger <$> bounds) s of