Merge pull request #25 from scarf-sh/support/example

This commit is contained in:
Christian Gill 2022-06-13 15:16:59 +02:00 committed by GitHub
commit 2c4c9f216a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 7 deletions

View File

@ -1,3 +1,7 @@
<div align="center">
<img src="/assets/tie.svg" width="200" />
</div>
<h1 align="center">Tie</h1>
Tie allows generation of Haskell server stubs from
@ -7,7 +11,32 @@ If you are looking for a generator for Haskell client code, check out the
[Haskell-OpenAPI-Client-Code-Generator](https://github.com/Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator)
project.
## Building Tie
## Usage
```
$ tie --help
tie - openapi3 server code generator
Usage: tie [-o|--output DIR] [--module-name MODULE] [--package-name PACKAGE]
[--extra-package PACKAGE] FILE
Generate a Haskell server from an OpenAPI3 specification
Available options:
-o,--output DIR The directory output (default: "out")
--module-name MODULE Name of the generated top level module
(default: "OpenAPI")
--package-name PACKAGE Name of the generated cabal project
(default: "open-api")
--extra-package PACKAGE Extra packages to include in the generated cabal
project
FILE OpenAPI specification file
-h,--help Show this help text
```
## Insallation
### Building from source
Below are the steps to install Tie using the Cabal build tool.
@ -40,7 +69,7 @@ $ cabal install .
## Community & Contact
Feel free to join on us on our
[community Slack](https://tinyurl.com/scarf-community-slack) (#tie channel)!
[community Slack](https://tinyurl.com/scarf-community-slack) (`#tie` channel)!
## License

6
assets/tie.svg Normal file
View File

@ -0,0 +1,6 @@
<svg viewBox="0 0 90 39" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M79.505 16.403H72.45c-.762-3.078-2.97-5.484-6.163-6.612-3.096-1.092-7.584-.96-10.902 2.694l-1.02 1.122-3.307-2.04a3.673 3.673 0 0 0-.444-.276l-2.262-1.392 1.89-2.082c2.383-2.622 5.437-4.41 8.827-5.167a17.265 17.265 0 0 1 9.529.594c3.006 1.062 5.616 2.905 7.548 5.317 1.8 2.256 2.946 4.944 3.36 7.842ZM79.211 23.34c-.3 1.362-.75 2.688-1.338 3.966a19.844 19.844 0 0 1-4.878 6.595c-2.7 2.4-6.06 3.81-9.72 4.068-.39.03-.78.042-1.17.042-3.157 0-6.32-.888-9.013-2.556L41.18 28.11l4.746-5.22 10.807 6.666c3.726 2.298 8.52 1.956 11.647-.828a13.068 13.068 0 0 0 3.618-5.382h7.212v-.006Z" fill="#509CF4"/>
<path d="M84.348 19.872c0-1.8 1.362-3.283 3.114-3.469h-25.73a9.992 9.992 0 0 1-5.244-1.488l-2.124-1.314-3.307-2.04a3.486 3.486 0 0 1 .924 4.662 3.504 3.504 0 0 1-2.97 1.656 3.485 3.485 0 0 1-3.486-3.486c0-1.134.54-2.136 1.374-2.778a3.461 3.461 0 0 1 2.112-.714c.576 0 1.122.138 1.602.39l-2.262-1.392-11.91-7.345A17.25 17.25 0 0 0 26.258.04c-3.66.258-7.027 1.662-9.72 4.068a19.906 19.906 0 0 0-4.88 6.595 20.186 20.186 0 0 0-1.337 3.966h7.212a13.067 13.067 0 0 1 3.618-5.382c1.747-1.554 4.009-2.346 6.313-2.346 1.83 0 3.69.498 5.34 1.518l10.807 6.666-3.69 4.063-4.747 5.22-1.02 1.122c-3.318 3.654-7.806 3.786-10.902 2.694-3.193-1.128-5.4-3.534-6.163-6.612h-7.056c.414 2.898 1.56 5.586 3.36 7.836 1.932 2.418 4.542 4.254 7.548 5.316a17.453 17.453 0 0 0 5.815 1.003c1.248 0 2.49-.138 3.714-.408 3.39-.757 6.438-2.545 8.827-5.167l1.89-2.082 4.746-5.22 3.672-4.044-.084-.079 3.33 2.053a16.919 16.919 0 0 0 8.887 2.52h25.73a3.487 3.487 0 0 1-3.12-3.468Z" fill="#0073F5"/>
<path d="m39.92 19.181-4.746 5.22-2.13-1.313A9.993 9.993 0 0 0 27.8 21.6H2.538a3.487 3.487 0 0 0 3.114-3.469c0-1.8-1.362-3.282-3.114-3.468H27.8c3.144 0 6.216.87 8.887 2.52l3.234 1.998Z" fill="#509CF4"/>
<path d="M90 19.872a2.169 2.169 0 0 1-2.166 2.166 2.17 2.17 0 0 1-2.166-2.166c0-1.195.972-2.167 2.166-2.167S90 18.677 90 19.872ZM51.177 14.393a2.177 2.177 0 0 1-2.172 2.166 2.169 2.169 0 0 1-2.166-2.166 2.16 2.16 0 0 1 1.062-1.86 2.169 2.169 0 0 1 1.11-.306 2.161 2.161 0 0 1 2.166 2.166ZM4.338 18.137a2.17 2.17 0 0 1-2.166 2.167c-.162 0-.318-.018-.468-.054A2.156 2.156 0 0 1 0 18.137a2.169 2.169 0 1 1 4.338 0Z" fill="#0073F5"/>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -47,6 +47,7 @@ options =
<> metavar "DIR"
<> showDefault
<> value "out"
<> help "The directory output"
)
<*> option
str
@ -54,6 +55,7 @@ options =
<> metavar "MODULE"
<> showDefault
<> value "OpenAPI"
<> help "Name of the generated top level module"
)
<*> option
str
@ -61,16 +63,19 @@ options =
<> metavar "PACKAGE"
<> showDefault
<> value "open-api"
<> help "Name of the generated cabal project"
)
<*> many
( option
str
( long "extra-package"
<> metavar "PACKAGE"
<> help "Extra packages to include in the generated cabal project"
)
)
<*> strArgument
( metavar "FILE"
<> help "OpenAPI specification file"
)
main :: IO ()

View File

@ -1,6 +1,6 @@
{ mkDerivation, aeson, base, bytestring, containers, directory
, filepath, hspec, insert-ordered-containers, lens, lib, mtl
, openapi3, optparse-applicative, prettyprinter, relude, tasty
, filepath, hspec, http-media, insert-ordered-containers, lens, lib
, mtl, openapi3, optparse-applicative, prettyprinter, relude, tasty
, tasty-discover, tasty-golden, tasty-hspec, tasty-hunit, text
, unordered-containers, yaml
}:
@ -12,7 +12,7 @@ mkDerivation {
isExecutable = true;
enableSeparateDataOutput = true;
libraryHaskellDepends = [
aeson base bytestring containers directory filepath
aeson base bytestring containers directory filepath http-media
insert-ordered-containers lens mtl openapi3 prettyprinter relude
text unordered-containers yaml
];
@ -23,6 +23,6 @@ mkDerivation {
tasty-golden tasty-hspec tasty-hunit text yaml
];
testToolDepends = [ tasty-discover ];
license = "unknown";
hydraPlatforms = lib.platforms.none;
description = "Tie allows generation of Haskell server stubs from OpenAPI (v 3.x) specifications.";
license = lib.licenses.asl20;
}