tie/example
2023-09-08 12:45:58 +02:00
..
app Change spelling in example app 2022-06-29 11:52:29 +02:00
generated Petstore example 2022-06-26 12:06:01 +02:00
cabal.project Petstore example 2022-06-26 12:06:01 +02:00
petstore-example.cabal restore compatibility between petstore-example and petstore-api 2023-09-08 12:45:58 +02:00
petstore.yaml Petstore example 2022-06-26 12:06:01 +02:00
README.md Update README.md 2022-06-26 12:09:22 +02:00

Hi! This is a full top-to-bottom example for using Tie.

Run the example with Cabal

Run the following command from the example/ directory of the Tie repository:

$ cabal run

This will build and launch a webserver on port 8080.

Re-generate the api code

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.

Structure of the generated code

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 the operationId 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 for Pet and Pets as well as Error 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 generated Api type and spins up a Warp webserver.