Dfx.json schema is finally available!

The much-requested dfx.json schema is finally available! You can find it in the documentation right here.

Starting with dfx 0.11.1, the dfx schema command will be available, which will display the schema for the currently active version of dfx. With the --outfile path/to/file.json flag, it will be possible to output the schema directly to a file.

Of course, the first iteration of the schema will not be perfect. Open topics:

  • Schema improvements. The schema gets auto-generated from our config types (mostly located in this file). Changes to the schema should go through the SDK repo in the mentioned file if you’re willing to do a PR yourself, or through this thread so that I can make the P. The portal repo (where the docs themselves are located at) has no influence over the schema.
  • Publication of the schema. There are ways to publish common schemas, e.g. through schemastore. I will be able to figure out the common places myself, but if someone already knows the best places to publish such a schema, please let me know.
25 Likes

In relation to this schema. Is there a comprehensive documentation for dfx.json? I can find documentation for all dfx command and subcommands but that does not replace documentation for dfx.json itself. Going by the schema and the doc strings in there it looks like there are many interesting things one can do with dfx.json if only one understood them or saw an example.

We don’t really have something nicer at the moment. I tried my best to improve the doc strings, but it’s still not the best. Another sometimes-nice way to figure out what to do with some options is to look at the changelog. In there we have some use cases covered most of the time. Also, if you feel something’s under documented, I’d love to approve a PR :smile:

Wasn’t there a way to specify the compiler version to use for moc inside dfx.json? I can’t find it.

Or is it fixed such that a given version of dfx uses one and only one moc version? Which means I would have to move a different binary to the path ~/.cache/dfinity/versions/<dfx version>/moc to change it.

In dfx.json you can only add arguments to a canister’s compilation. I think the field is called "args" and should work in any canister of type motoko.

To use a different compiler version with dfx, set the env var DFX_MOC_PATH to point to your other moc. I’ll make a PR to add this to the dfx env var docs.

1 Like