mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 20:41:49 +03:00
e0c0043e76
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9284 GitOrigin-RevId: 2f2cf2ad01900a54e4bdb970205ac0ef313c7e00
33 lines
1.4 KiB
Haskell
33 lines
1.4 KiB
Haskell
-- | This module exports an OpenAPI specification for the GraphQL Engine
|
|
-- metadata API.
|
|
--
|
|
-- The OpenAPI specification for metadata is experimental and incomplete. Please
|
|
-- do not incorporate it into essential workflows at this time.
|
|
module Hasura.Server.MetadataOpenAPI (metadataOpenAPI) where
|
|
|
|
import Autodocodec.OpenAPI (declareNamedSchemaViaCodec)
|
|
import Data.HashMap.Strict.InsOrd qualified as InsOrdHashMap
|
|
import Data.OpenApi (Components (..), NamedSchema (..), OpenApi (..))
|
|
import Data.OpenApi.Declare (MonadDeclare (declare), runDeclare)
|
|
import Data.Proxy (Proxy (..))
|
|
import Hasura.Metadata.DTO.Metadata (MetadataDTO)
|
|
import Hasura.Prelude
|
|
|
|
-- | An OpenApi document includes \"schemas\" that describe the data that may be
|
|
-- produced or consumed by an API. It can also include \"paths\" which describe
|
|
-- REST endpoints, and the document can include other API metadata. This example
|
|
-- only includes schemas.
|
|
--
|
|
-- The OpenAPI specification for metadata is experimental and incomplete. Please
|
|
-- do not incorporate it into essential workflows at this time.
|
|
metadataOpenAPI :: OpenApi
|
|
metadataOpenAPI =
|
|
mempty {_openApiComponents = mempty {_componentsSchemas = definitions}}
|
|
where
|
|
definitions = fst
|
|
$ flip runDeclare mempty
|
|
$ do
|
|
NamedSchema mName codecSchema <- declareNamedSchemaViaCodec (Proxy @MetadataDTO)
|
|
declare $ InsOrdHashMap.fromList [(fromMaybe "MetadataDTO" mName, codecSchema)]
|
|
pure codecSchema
|