Code assistance for API calls
In this article, we'll be discussing how to start to write Flow API requests with the help of Visual Studio Code. This editor is not strictly required, you can use any other editor that supports an LSP JSON server.
The first step is to create a new JSON file with a reference to the Flow payload schema we are interested in.
The URL of the reference schema is composed of the Flow OpenApi JSON URL, followed by the fragment #/components/schemas/
and the name of the payload we are interested in.
For example, for the CreateDraft
payload, we would have:
{
"$schema" : "http://json-schema.org/draft-07/schema#",
"$ref": "https://scrive.com/experimental/flow/documentation/openapi/api.json#/components/schemas/CreateDraft"
}
For using it, what we need to do is to create a new JSON file and specify the key "$schema"
with, as value, the file URI of the schema we have created. For example, if the path of the JSON schema is /home/user/CreateDraft.json
, we would have:
{
"$schema": "file:///home/user/CreateDraft.json"
}
The editor should now give back suggestions and basic validation functionalities while writing the desired payload.