Skip to content

[Haskell] README.md instructions don't work OOTB #5101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mandrean opened this issue Mar 17, 2017 · 3 comments
Open

[Haskell] README.md instructions don't work OOTB #5101

mandrean opened this issue Mar 17, 2017 · 3 comments

Comments

@mandrean
Copy link
Contributor

mandrean commented Mar 17, 2017

Description

The example instructions for creating a client and a server in README.md don't work OOTB. Not for client nor server.

Swagger-codegen version

v2.2.2 or latest master, doesn't matter.

Swagger declaration file content or url

Tried with both a large/complex company-private Swagger, and the Petstore sample:
sh ./bin/haskell-servant-petstore.sh
cd samples/server/petstore/haskell-servant

Same results either way.

Steps to reproduce
  1. git clone https://github.com/swagger-api/swagger-codegen && cd swagger-codegen
  2. git checkout origin master && git pull origin master --rebase
  3. mvn clean package
  4. sh ./bin/haskell-servant-petstore.sh
  5. cd samples/server/petstore/haskell-servant
  6. stack install
  7. Create a Main.hs file and try to import/use the generated client or server using the example code from the README.md, i.e:
{-# LANGUAGE RecordWildCards #-}

module Main where

import SwaggerPetstore.API

main :: IO ()
main = do
  SwaggerPetstoreBackend{..} <- createSwaggerPetstoreClient (ServerConfig "localhost" 8080)
  return ()
Results
Main.hs:9:33:
    Couldn't match expected type ServerConfig
                                  -> IO (SwaggerPetstoreBackend t0)
                with actual type SwaggerPetstoreBackend SwaggerPetstoreClient
    The function createSwaggerPetstoreClient
    is applied to one argument,
    but its type SwaggerPetstoreBackend SwaggerPetstoreClient
    has none
    In a stmt of a 'do' block:
      SwaggerPetstoreBackend {..} <- createSwaggerPetstoreClient
                                       (ServerConfig "localhost" 8080)
    In the expression:
      do { SwaggerPetstoreBackend {..} <- createSwaggerPetstoreClient
                                            (ServerConfig "localhost" 8080);
           return () }
@wing328
Copy link
Contributor

wing328 commented Mar 17, 2017

When I run stack install with the latest master, I didn't get the error. Here is what I got:

haskell-servant|master⚡ ⇒ stack install
swagger-petstore-0.1.0.0: build (lib)
Preprocessing library swagger-petstore-0.1.0.0...
[2 of 2] Compiling SwaggerPetstore.API ( lib/SwaggerPetstore/API.hs, .stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/SwaggerPetstore/API.o )
In-place registering swagger-petstore-0.1.0.0...
swagger-petstore-0.1.0.0: copy/register
Installing library in
/Users/williamcheng/Code/jan2017/swagger-codegen/samples/server/petstore/haskell-servant/.stack-work/install/x86_64-osx/lts-5.11/7.10.3/lib/x86_64-osx-ghc-7.10.3/swagger-petstore-0.1.0.0-IxSHpn14xIc0AqRoIN1bwh
Registering swagger-petstore-0.1.0.0...

@mandrean
Copy link
Contributor Author

mandrean commented Mar 17, 2017

@wing328 Sorry, forgot the last step to reproduce. Updated initial post now.

This issue isn't about stack install failing, that was fixed recently in #5097 and merged to master.

This issue is about actually using the generated client/server library in your code, and the README.md example for doing that is broken.

@wing328
Copy link
Contributor

wing328 commented Mar 17, 2017

@mandrean thanks for clarifying.

After the fix, we should leverage Travis CI to test the Haskell client/server for Petstore.

Ref: https://docs.haskellstack.org/en/stable/travis_ci/

cc @algas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants