mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 17:31:56 +03:00
b094947239
This PR expands the set of codecs for source metadata to include `TableMetadata`, `FunctionMetadata`, and various permission types. This fills out more detail in the generated OpenAPI document. See the [generated OpenAPI spec](https://gist.github.com/hallettj/783d06a926cbc854eececa4964e8aa5b) based on this PR. See also the [generated TypeScript types](https://github.com/hasura/graphql-engine-mono/files/9448102/client-typescript.tar.gz) based on that spec. Ticket: https://hasurahq.atlassian.net/browse/MM-66 PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5664 GitOrigin-RevId: b6e1f32c669368cd6150e6f69fc36b78b748d9bb
32 lines
1.4 KiB
Haskell
32 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 HM
|
|
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 $ HM.fromList [(fromMaybe "MetadataDTO" mName, codecSchema)]
|
|
pure codecSchema
|