Skip to content

Commit 4819f37

Browse files
committed
Merge pull request #2018 from wing328/haskell_model_notfound
[Haskell] minor fix to template location for haskell-servant
2 parents 3322b0e + 743a533 commit 4819f37

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/HaskellServantCodegen.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public HaskellServantCodegen() {
7474
* Template Location. This is the location which templates will be read from. The generator
7575
* will use the resource stream to attempt to read the templates.
7676
*/
77-
embeddedTemplateDir = templateDir = "haskell";
77+
embeddedTemplateDir = templateDir = "haskell-servant";
7878

7979
/**
8080
* Api Package. Optional, if needed, this can be used in templates
@@ -342,4 +342,4 @@ public CodegenOperation fromOperation(String resourcePath, String httpMethod, Op
342342
return op;
343343
}
344344

345-
}
345+
}

samples/server/petstore/haskell-servant/client/Main.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import Model.Pet
2121
import Model.Tag
2222
import Model.Order
2323
import Api.UserApi
24-
import Api.StoreApi
2524
import Api.PetApi
25+
import Api.StoreApi
2626

2727
-- userClient :: IO ()
2828
-- userClient = do

samples/server/petstore/haskell-servant/haskell-servant-codegen.cabal

+2-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: haskell-servant-codegen
22
version: 0.1.0.0
33
synopsis: Swagger-codegen example for Haskell servant
44
description: Please see README.md
5-
homepage: http://github.com/algas/haskell-servant-codegen#readme
5+
homepage: https://github.com/swagger-api/swagger-codegen#readme
66
license: Apache-2.0
77
license-file: LICENSE
88
author: Masahiro Yamauchi
@@ -22,8 +22,8 @@ library
2222
, Model.Tag
2323
, Model.Order
2424
, Api.UserApi
25-
, Api.StoreApi
2625
, Api.PetApi
26+
, Api.StoreApi
2727
, Apis
2828
ghc-options: -Wall
2929
build-depends: base
@@ -62,7 +62,3 @@ executable server
6262
, servant-mock
6363
, haskell-servant-codegen
6464
default-language: Haskell2010
65-
66-
source-repository head
67-
type: git
68-
location: https://github.com/algas/haskell-servant-codegen

samples/server/petstore/haskell-servant/lib/Api/PetApi.hs

+9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ module Api.PetApi (
1414
, updatePetWithForm
1515
, deletePet
1616
, uploadFile
17+
, getPetByIdWithByteArray
18+
, addPetUsingByteArray
1719
, proxyPetApi
1820
, PetApi
1921
) where
@@ -30,6 +32,7 @@ import qualified Data.Text as T
3032
import Utils
3133
import Test.QuickCheck
3234
import Model.Pet
35+
import Model.Binary
3336

3437

3538

@@ -62,6 +65,8 @@ instance Arbitrary FormadditionalMetadatafile where
6265
arbitrary = FormadditionalMetadatafile <$> arbitrary <*> arbitrary
6366

6467

68+
69+
6570
type PetApi = "pet" :> ReqBody '[JSON] Pet :> Put '[JSON] () -- updatePet
6671
:<|> "pet" :> ReqBody '[JSON] Pet :> Post '[JSON] () -- addPet
6772
:<|> "pet" :> "findByStatus" :> QueryParam "status" [String] :> Get '[JSON] [Pet] -- findPetsByStatus
@@ -70,6 +75,8 @@ type PetApi = "pet" :> ReqBody '[JSON] Pet :> Put '[JSON] () -- updatePet
7075
:<|> "pet" :> Capture "petId" String :> ReqBody '[FormUrlEncoded] Formnamestatus :> Post '[JSON] () -- updatePetWithForm
7176
:<|> "pet" :> Capture "petId" Integer :> Header "api_key" String :> Delete '[JSON] () -- deletePet
7277
:<|> "pet" :> Capture "petId" Integer :> "uploadImage" :> ReqBody '[FormUrlEncoded] FormadditionalMetadatafile :> Post '[JSON] () -- uploadFile
78+
:<|> "pet" :> Capture "petId" Integer?testing_byte_array=true :> Get '[JSON] Binary -- getPetByIdWithByteArray
79+
:<|> "pet?testing_byte_array=true" :> ReqBody '[JSON] Binary :> Post '[JSON] () -- addPetUsingByteArray
7380

7481
proxyPetApi :: Proxy PetApi
7582
proxyPetApi = Proxy
@@ -101,4 +108,6 @@ updatePet
101108
:<|> updatePetWithForm
102109
:<|> deletePet
103110
:<|> uploadFile
111+
:<|> getPetByIdWithByteArray
112+
:<|> addPetUsingByteArray
104113
= client proxyPetApi $ BaseUrl Http host port

samples/server/petstore/haskell-servant/lib/Apis.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ module Apis (
99
) where
1010

1111
import Api.UserApi (UserApi)
12-
import Api.StoreApi (StoreApi)
1312
import Api.PetApi (PetApi)
13+
import Api.StoreApi (StoreApi)
1414

1515
import Data.Proxy
1616
import Servant.API
1717
import Test.QuickCheck
1818
import qualified Data.Map as Map
1919
import Utils
2020

21-
type API = UserApi :<|> StoreApi :<|> PetApi
21+
type API = UserApi :<|> PetApi :<|> StoreApi
2222

2323
api :: Proxy API
2424
api = Proxy

0 commit comments

Comments
 (0)