packages feed

json-spec-openapi-0.1.0.0: json-spec-openapi.cabal

cabal-version:       3.0
name:                json-spec-openapi
version:             0.1.0.0
synopsis:            json-spec-openapi
description:
  This package provides a way to produce
  [`openapi3`](https://hackage.haskell.org/package/openapi3) documentation from a
  [`json-spec`](https://hackage.haskell.org/package/json-spec-0.1.0.0)
  specification.

  = Example

  Given this data type:

  > data User = User
  >   {      name :: Text
  >   , lastLogin :: UTCTime
  >   }
  >   deriving ToSchema via (EncodingSchema User) -- <-- ToSchema instance defined here
  > instance HasJsonEncodingSpec User where
  >   type EncodingSpec User =
  >     JsonObject
  >       '[ '("name", JsonString)
  >        , '("last-login", JsonDateTime)
  >        ]
  >   toJSONStructure user =
  >     (Field @"name" (name user),
  >     (Field @"last-login" (lastLogin user),
  >     ()))

  Calling `Data.Aeson.encode (Data.OpenApi3.toSchema (Proxy :: Proxy User))`
  will produce the following Schema:

  > {
  >   "additionalProperties": false,
  >   "properties": {
  >     "last-login": {
  >       "format": "date-time",
  >       "type": "string"
  >     },
  >     "name": {
  >       "type": "string"
  >     }
  >   },
  >   "required": [
  >     "name",
  >     "last-login"
  >   ],
  >   "type": "object"
  > }
homepage:            https://github.com/owensmurray/json-spec-openapi
license:             MIT
license-file:        LICENSE
author:              Rick Owens
maintainer:          rick@owensmurray.com
copyright:           2022 Rick Owens
category:            JSON, OpenApi
build-type:          Simple
extra-source-files:
  README.md
  LICENSE

common dependencies
  build-depends:
    , base      >= 4.17    && < 4.18
    , json-spec >= 0.1.0.0 && < 0.2
    , lens      >= 5.2.2   && < 5.3
    , openapi3  >= 3.2.3   && < 3.3
    , text      >= 2.0.2   && < 2.1

common warnings
  ghc-options:
    -Wmissing-deriving-strategies
    -Wmissing-export-lists
    -Wmissing-import-lists
    -Wredundant-constraints
    -Wall

library
  import: dependencies, warnings
  exposed-modules:     
    Data.JsonSpec.OpenApi
  -- other-modules:       
  -- other-extensions:    
  hs-source-dirs:      src
  default-language:    Haskell2010

test-suite json-spec-openapi-tests
  import: dependencies, warnings
  main-is: test.hs
  type: exitcode-stdio-1.0
  hs-source-dirs: test
  default-language: Haskell2010
  build-depends:
    , json-spec-openapi

    , aeson      >= 2.1.2.1  && < 2.2
    , bytestring >= 0.11.4.0 && < 0.12
    , hspec      >= 2.11.1   && < 2.12
    , scientific >= 0.3.7.0  && < 0.4
    , time       >= 1.12.2   && < 1.13