The Fetch Schema is a map of path/url and schema. The path is the url path and the schema is an object with
input, output, query and params keys.
The input key is the schema of the request data. The output key is the schema of the response data. The query key is the schema of the query params. The params key is dynamic path parameters.
The input schema is the schema of the request data. The input key is the schema of the request data. If you defined an input schema, the data will be requeired to be passed as a body of the request.
If you define an input schema, a post method will be used to make the request and if there is no input schema, a get method will be used. See method modifiers section for defining specefic methods.
To make the body optional you can wrap the schema with z.optional.
The output schema is the schema of the response data. The output key is the schema of the response data. If you defined an output schema, the data will be returned as the response body.
The query schema is the schema of the query params. The query key is the schema of the query params. If you defined a query schema, the data will be passed as the query params.
The params schema is the schema of the path params. You can either use the params key to define the paramters or prepend : to the path to make the parameters dynamic.
If you define more than one dynamic path parameter using the string modifier the paramters will be required to be passed as an array of values in the order they are defined.
By default the get and post methods are used to make the request based on weather the input schema is defined or not. You can use the method modifier to define the method to be used.
The method modifiers are @get, @post, @put, @patch, @delete and @head. You prepend the method name to the path to define the method
By default if you define schema better fetch still allows you to make a call to other routes that's not defined on the schema. If you want to enforce only the keys defined to be inferred as valid you can use pass the strict option to the schema.