cabal-version: 3.0
name: json-spec-openapi
version: 1.2.0.3
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-1.2.0.0)
specification.
= Example
Given this data type:
> data User = User
> { name :: Text
> , lastLogin :: Maybe UTCTime
> }
> deriving ToSchema via (EncodingSchema User) -- <-- ToSchema instance defined here
> instance HasJsonEncodingSpec User where
> type EncodingSpec User =
> JsonObject
> '[ Required "name" JsonString
> , Optional "last-login" JsonDateTime
> ]
> toJSONStructure user =
> (Field @"name" (name user),
> (fmap (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"
> ],
> "type": "object"
> }
homepage: https://github.com/owensmurray/json-spec-openapi
license: MIT
license-file: LICENSE
author: Rick Owens
maintainer: rick@owensmurray.com
copyright: 2026 Owens Murray, LLC.
category: JSON, OpenApi
build-type: Simple
extra-doc-files:
README.md
LICENSE
CHANGELOG.md
common dependencies
build-depends:
, aeson >= 2.2.1.0 && < 2.3
, base >= 4.19.2.0 && < 4.23
, json-spec >= 1.3.0.0 && < 1.4
, lens >= 5.2.3 && < 5.4
, openapi3 >= 3.2.5 && < 3.3
, text >= 2.1 && < 2.2
common warnings
ghc-options:
-Wmissing-deriving-strategies
-Wmissing-export-lists
-Wmissing-import-lists
-Wredundant-constraints
-Wall
-Wunused-packages
library
import: dependencies, warnings
exposed-modules:
Data.JsonSpec.OpenApi
other-modules:
Data.JsonSpec.OpenApi.Rename
-- 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
, hspec >= 2.11.1 && < 2.12
, time >= 1.12.2 && < 1.15