self(auto)- documenting encoders and decoders
Go to file
2021-11-11 13:27:03 +01:00
.github upgrade ci 2021-11-06 12:47:58 +01:00
autodocodec rename toContextVia for extra clarity 2021-11-11 13:22:43 +01:00
autodocodec-api-usage tests for roundtrips through json bytes and back 2021-11-11 13:27:03 +01:00
autodocodec-openapi3 fix the swagger todo 2021-11-06 22:06:32 +01:00
autodocodec-schema Fixed more TODOs 2021-11-06 18:52:27 +01:00
autodocodec-swagger2 A function for named codecs 2021-11-08 14:49:13 +01:00
autodocodec-yaml Encoding yaml values with ToYaml for ordered keys 2021-11-11 00:34:12 +01:00
nix working around an old ghc bug 2021-11-08 16:21:35 +01:00
.gitignore trying a thing 2021-10-20 17:59:50 +02:00
.hlint.yaml a finite recursive schema 2021-10-29 19:56:07 +02:00
ci.nix build fewer versions on ci because the haddocks are quite stupid about it 2021-10-30 13:00:37 +02:00
default.nix Trying to set up CI 2021-10-24 19:21:59 +02:00
LICENSE trying a thing 2021-10-24 19:29:57 +02:00
README.md mention the yaml functionality in the readme 2021-11-11 13:24:38 +01:00
shell.nix test failure 2021-10-24 19:34:17 +02:00
stack.yaml rename autodocodec-aeson-schema to autodocodec-schema 2021-11-06 15:06:32 +01:00

Autodocodec

Autodocodec is short for "self(auto)- documenting encoder and decoder".

In short: You write a single instance, of the 'Codec' type-class, for your type, and you get:

See the golden test directory directory for example outputs.

Features

  • ✓ Correct-by-construction encoding and decoding, without generating code.
  • ✓ Generate automatically-correct documentation from code.
  • ✓ Support for recursive types.

State of this project

This project is ready to try out!

data Example = Example
  { exampleTextField :: !Text,
    exampleIntField :: !Int
  }
  deriving stock (Show, Eq, Generic)
  deriving
    ( FromJSON, -- <- FromJSON instance for free.
      ToJSON, -- <- ToJSON instance for free.
      Swagger.ToSchema, -- <- Swagger schema for free.
      OpenAPI.ToSchema -- <- OpenAPI schema for free.
    )
    via (Autodocodec Example)

instance HasCodec Example where
  codec =
    object "Example" $
      Example
        <$> requiredField "text" "documentation for the text field" .= exampleTextField
        <*> requiredField "int" "documentation for the int field" .= exampleIntField

Tests

While we don't provide any actual guarantees, we do have tests for the following properties that we would like to maintain: