asyncapi3-1.0.0.0: src/Data/AsyncAPI/Optics.hs
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
-- | Field optics and prisms for the AsyncAPI 3.1.0 model, built with
-- @optics-th@. Field labels are named after the JSON keys (usable as
-- @#title@ with @OverloadedLabels@); prisms carry the constructor names.
--
-- Fields whose JSON keys are Haskell keywords get underscore-suffixed labels
-- (@type_@, @if_@, @then_@, @else_@, @default_@); for 'SecurityScheme' the
-- keyword label is the bare @in@ (generated by 'makeFieldLabels'). The three
-- keyword-heavy records enumerate their labels explicitly via
-- 'makeFieldLabelsFor'; all other records use 'makeFieldLabels'. The
-- generated 'Optics.Label.LabelOptic' instances are intentionally orphan
-- (label optics must be declared where they are used).
module Data.AsyncAPI.Optics
( module Data.AsyncAPI.Optics,
module Data.AsyncAPI.Internal,
module Data.AsyncAPI.Internal.Schema,
)
where
import Data.AsyncAPI.Internal
import Data.AsyncAPI.Internal.FieldNames (parameterFields, schemaObjFields, serverVariableFields)
import Data.AsyncAPI.Internal.Schema
import Optics.TH (makeFieldLabels, makeFieldLabelsFor, makePrisms)
-- Root
makeFieldLabels ''AsyncAPI
makeFieldLabels ''Info
makeFieldLabels ''Contact
makeFieldLabels ''License
makeFieldLabels ''Server
makeFieldLabels ''Channel
makeFieldLabels ''Tag
makeFieldLabels ''ExternalDocumentation
makeFieldLabels ''Reference
makeFieldLabels ''Components
-- Security
makeFieldLabels ''SecurityScheme
makeFieldLabels ''OAuthFlows
makeFieldLabels ''OAuthFlow
-- Bindings
makeFieldLabels ''ServerBindings
makeFieldLabels ''ChannelBindings
makeFieldLabels ''OperationBindings
makeFieldLabels ''MessageBindings
-- Schemas
makeFieldLabels ''MultiFormatSchema
makeFieldLabelsFor schemaObjFields ''SchemaObj
makeFieldLabelsFor serverVariableFields ''ServerVariable
makeFieldLabelsFor parameterFields ''Parameter
-- Messages
makeFieldLabels ''Message
makeFieldLabels ''MessageTrait
makeFieldLabels ''MessageExample
makeFieldLabels ''CorrelationId
-- Operations
makeFieldLabels ''Operation
makeFieldLabels ''OperationTrait
makeFieldLabels ''OperationReply
makeFieldLabels ''OperationReplyAddress
-- Prisms for sum types
makePrisms ''Referenced
makePrisms ''Schema
makePrisms ''SchemaType
makePrisms ''ItemsSchema
makePrisms ''AdditionalProperties
makePrisms ''SchemaDefinition
makePrisms ''SecuritySchemeType
makePrisms ''ApiKeyLocation
makePrisms ''OperationAction
makePrisms ''JsonType