View Source mix absinthe.schema.json (absinthe v1.7.0)
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.Schemamodule 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.jsonWrite to default path ./schema.json using the MySchema schema:
mix absinthe.schema.json --schema MySchemaWrite to path /path/to/schema.json using the MySchema schema, with pretty-printing:
mix absinthe.schema.json --schema MySchema --pretty /path/to/schema.jsonWrite to default path ./schema.json using the MySchema schema and a custom JSON codec, MyCodec:
mix absinthe.schema.json --schema MySchema --json-codec MyCodecCustom Codecs
Any module that provides encode!/2 can be used as a custom codec:
encode!(value, options)valuewill be provided as a Map containing the generated schema.optionswill be a keyword list with a:prettyboolean, 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.