Hi! This is a full top-to-bottom example for using Tie.
Run the following command from the example/
directory of the Tie repository:
$ cabal run
This will build and launch a webserver on port 8080.
Run the following command from the example/
directory of the Tie repository:
$ tie --output generated --module-name Petstore.API --package-name petstore-api petstore.yaml
This will generate a Cabal package into the generated
directory.
The generated code will placed in generated
. The modules are placed under the Petstore.API
(PetStore/API
) Haskell module namespace.
-
generated/Petstore/API/Api.hs
contains the API definition for the Petstore. This file is derived from the operations defined in the OpenAPI specification. In particular, the operation names are derived from theoperationId
property of the Operations as defined in the specification. -
generated/Petstore/API/Schemas
is where the schema definitions are being placed by Tie. You can find the definition forPet
andPets
as well asError
in here. -
generated/Petstore/API/Response
is where Tie places the response types for the individual operations. You will find a Haskell module for each operation in the OpenAPI specification here. -
app/Main.hs
is the entry point of the example Petstore application. It provides an implementation for the generatedApi
type and spins up a Warp webserver.