mix absinthe.schema.json (absinthe v1.6.4) View Source
Generate a schema.json
file
Usage
mix absinthe.schema.json [OPTIONS] [FILENAME]
The JSON codec to be used needs to be included in your mix.exs
dependencies. If using the default codec,
see the Jason installation instructions.
Options
--schema
- The name of theAbsinthe.Schema
module defining the schema to be generated. Default: As configured for:absinthe
:schema
--json-codec
- Codec to use to generate the JSON file (see Custom Codecs). Default:Jason
--pretty
- Whether to pretty-print. Default:false
Examples
Write to default path ./schema.json
using the :schema
configured for the :absinthe
application:
mix absinthe.schema.json
Write to default path ./schema.json
using the MySchema
schema:
mix absinthe.schema.json --schema MySchema
Write to path /path/to/schema.json
using the MySchema
schema, with pretty-printing:
mix absinthe.schema.json --schema MySchema --pretty /path/to/schema.json
Write to default path ./schema.json
using the MySchema
schema and a custom JSON codec, MyCodec
:
mix absinthe.schema.json --schema MySchema --json-codec MyCodec
Custom Codecs
Any module that provides encode!/2
can be used as a custom codec:
encode!(value, options)
value
will be provided as a Map containing the generated schema.options
will be a keyword list with a:pretty
boolean, indicating whether the user requested pretty-printing.
The function should return a string to be written to the output file.
Link to this section Summary
Functions
Callback implementation for Mix.Task.run/1
, which receives a list of command-line args.
Link to this section Functions
Specs
Callback implementation for Mix.Task.run/1
, which receives a list of command-line args.