diff --git a/autodocodec-aeson-schema/src/Autodocodec/Aeson/Schema.hs b/autodocodec-aeson-schema/src/Autodocodec/Aeson/Schema.hs index cd2c228..ad00d29 100644 --- a/autodocodec-aeson-schema/src/Autodocodec/Aeson/Schema.hs +++ b/autodocodec-aeson-schema/src/Autodocodec/Aeson/Schema.hs @@ -34,10 +34,12 @@ import Data.Validity.Containers () import Data.Validity.Text () import GHC.Generics (Generic) --- TODO think about putting this value in a separate package or directly in autodocodec +-- | A JSON Schema -- -- http://json-schema.org/understanding-json-schema/reference/index.html -- +-- Contrary to a 'Codec', values of this type should be finite. +-- -- NOTE: This schema roundtrips to JSON, but it cannot expres everything that a fully-featured json-schema may be able to express. data JSONSchema = AnySchema @@ -295,7 +297,7 @@ jsonSchemaVia = (`evalState` S.empty) . go s <- go c pure [(k, (Optional (Just (hr, toJSONVia c mr)), s, mdoc))] MapCodec _ _ c -> goObject c - PureCodec _ -> pure [] -- TODO show something ? + PureCodec _ -> pure [] ApCodec oc1 oc2 -> liftA2 (++) (goObject oc1) (goObject oc2) uncurry3 :: (a -> b -> c -> d) -> ((a, b, c) -> d) diff --git a/autodocodec-api-usage/src/Autodocodec/Usage.hs b/autodocodec-api-usage/src/Autodocodec/Usage.hs index 37cc48f..9b085dd 100644 --- a/autodocodec-api-usage/src/Autodocodec/Usage.hs +++ b/autodocodec-api-usage/src/Autodocodec/Usage.hs @@ -108,7 +108,7 @@ instance FromJSON Example where -- -- 1. We can define recursive types -- 2. We can encode, decode, and document a recursive type finitely. --- 3. TODO We can roundtrip its json schema through json. +-- 3. We can roundtrip its json schema through json. data Recursive = Base Int | Recurse Recursive diff --git a/autodocodec/src/Autodocodec/Codec.hs b/autodocodec/src/Autodocodec/Codec.hs index d18f56f..b0c2a7c 100644 --- a/autodocodec/src/Autodocodec/Codec.hs +++ b/autodocodec/src/Autodocodec/Codec.hs @@ -53,7 +53,6 @@ data Codec context input output where -- | Encode 'Scientific' to a @number@ value, and decode a @number@ value as a 'Scientific'. -- -- NOTE: We use 'Scientific' here because that is what aeson uses. - -- TODO: Can we do this without 'Scientific'? It has too many footguns. NumberCodec :: -- | Name of the @number@, for error messages and documentation. !(Maybe Text) -> @@ -247,7 +246,7 @@ showCodecABit = ($ "") . (`evalState` S.empty) . go 0 RequiredKeyCodec k c mdoc -> (\s -> showParen (d > 10) $ showString "RequiredKeyCodec " . showsPrec d k . showString " " . showsPrec d mdoc . showString " " . s) <$> go 11 c OptionalKeyCodec k c mdoc -> (\s -> showParen (d > 10) $ showString "OptionalKeyCodec " . showsPrec d k . showString " " . showsPrec d mdoc . showString " " . s) <$> go 11 c OptionalKeyWithDefaultCodec k c shownDefault _ mdoc -> (\s -> showParen (d > 10) $ showString "OptionalKeyWithDefaultCodec " . showsPrec d k . showString " " . s . showString " " . showsPrec d shownDefault . showString " " . showsPrec d mdoc) <$> go 11 c - PureCodec _ -> pure $ showString "PureCodec" -- TODO add show instance? + PureCodec _ -> pure $ showString "PureCodec" ApCodec oc1 oc2 -> (\s1 s2 -> showParen (d > 10) $ showString "ApCodec " . s1 . showString " " . s2) <$> go 11 oc1 <*> go 11 oc2 -- | Map the output part of a codec