polytropos-openapi3: OpenAPI 3.0 schema generation for polytropos open records and variants

[ library, web ] [ Propose Tags ] [ Report a vulnerability ]

Automatic OpenAPI 3.0 specification and JSON Schema generation for polytropos open records and variants via openapi3.

Generates Data.OpenApi.Schema.ToSchema instances without GHC.Generics tree explosion: open records yield schema objects with typed properties and required lists, while open variants yield Data.OpenApi.Lens.oneOf tagged-union schemas.

Start at the front door module Polytropos.OpenApi for complete documentation, schema customizing options, and worked examples.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.2
Change log CHANGELOG.md
Dependencies base (>=4.14 && <5), lens (>=5.2 && <5.4), openapi3 (>=3.2 && <3.3), polytropos-core (>=0.1 && <0.2), polytropos-plugin (>=0.1 && <0.2), text (>=1.2 && <2.2) [details]
License (EUPL-1.2 OR Apache-2.0)
Author Nadia Yvette Chambers
Maintainer nadia.yvette.chambers@ik.me
Uploaded by nyc at 2026-10-21T21:34:27Z
Category Web
Home page https://github.com/NadiaYvette/polytropos
Bug tracker https://github.com/NadiaYvette/polytropos/issues
Source repo head: git clone https://github.com/NadiaYvette/polytropos(packages/polytropos-openapi3)
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 3 total (3 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-10-22 [all 1 reports]

Readme for polytropos-openapi3-0.1.0.2

[back to package description]

polytropos-openapi3

Automatic OpenAPI 3.0 specification and JSON Schema generation for polytropos open records and variants via openapi3.

Overview

polytropos-openapi3 synthesizes ToSchema instances for open records and variants:

  • Open records generate object schemas with typed properties and required field lists.
  • Open variants generate oneOf tagged-union schemas with discriminator objects.

Features

  • No Generics Blowup: Direct type-level row inspection without generic binary tree expansion.
  • Full OpenAPI 3.0 Compliance: Emits schemas directly consumed by Swagger UI, Redoc, and OpenAPI code generators.
  • Customizable Schemas: Combine with custom descriptions, examples, and formats.

Quick Example

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fplugin=Polytropos.Plugin #-}

import Data.OpenApi (toSchema, Schema)
import Data.Proxy (Proxy (..))
import Polytropos
import Polytropos.OpenApi

type User = Record '["id" ':= Int, "name" ':= String]

user :: User
user = REC { id = 1, name = "Alice" }

-- Generate OpenAPI 3.0 schema directly from the row specification
userSchema :: Schema
userSchema = toSchema (Proxy @User)

License

Dual-licensed under EUPL-1.2 OR Apache-2.0.