Haskell-OpenAPI-Code-Generator / Haskell-OpenAPI-Client-Code-Generator

Generate Haskell client code from an OpenAPI 3 specification
46 stars 19 forks source link

install broken #92

Closed haroldcarr closed 8 months ago

haroldcarr commented 8 months ago

If I do cabal install openapi3-code-generator or NIXPKGS_ALLOW_BROKEN=1 nix-shell -p haskellPackages.openapi3-code-generator I get compilation error in the OpenAPI code.

Here is the output from using nix. The compile errors from cabal install are the same.

> 515 o2023 haskell-client> nix-shell -p haskellPackages.openapi3-code-generator
error:
       ...
       error: Package ‘openapi3-code-generator-0.1.0.7’ in /nix/store/nlm3wz58fjzcbf7d9csf2czxmrvsk65k-nixpkgs/nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix:219920 is marked as broken, refusing to evaluate.

> NIXPKGS_ALLOW_BROKEN=1 nix-shell -p haskellPackages.openapi3-code-generator
...
building '/nix/store/qmx8iijm91ankqnlhg2512hvcxkhidkr-openapi3-code-generator-0.1.0.7.drv'...
...
Using Cabal-3.8.1.0 compiled by ghc-9.4
Using compiler: ghc-9.4.8
...
Using gcc version 16.0.6 given by user at:
/nix/store/3fpl3hs6ii820yxp0rbafx5phnmj8ng7-clang-wrapper-16.0.6/bin/clang
Using ghc version 9.4.8 found on system at:
/nix/store/1rb28dyrfz8f4b82p2dxchivh0qrkj55-ghc-9.4.8/bin/ghc
Using ghc-pkg version 9.4.8 found on system at:
/nix/store/1rb28dyrfz8f4b82p2dxchivh0qrkj55-ghc-9.4.8/bin/ghc-pkg-9.4.8
...
building
Preprocessing library for openapi3-code-generator-0.1.0.7..
Building library for openapi3-code-generator-0.1.0.7..
[ 1 of 25] Compiling OpenAPI.Common   ( src/OpenAPI/Common.hs, dist/build/OpenAPI/Common.o, dist/build/OpenAPI/Common.dyn_o )

src/OpenAPI/Common.hs:258:58: error:
    • Couldn't match type: Data.Aeson.KeyMap.KeyMap Aeson.Value
                     with: HMap.HashMap Text Aeson.Value
      Expected: HMap.HashMap Text Aeson.Value
        Actual: Aeson.Object
    • In the first argument of ‘HMap.toList’, namely ‘object’
      In the first argument of ‘(>>=)’, namely ‘HMap.toList object’
      In the expression:
        HMap.toList object >>= uncurry jsonToFormDataFlat
    |
258 | jsonToFormDataFlat _ (Aeson.Object object) = HMap.toList object >>= uncurry jsonToFormDataFlat
    |                                                          ^^^^^^

src/OpenAPI/Common.hs:293:15: error:
    • Couldn't match type: Data.Aeson.KeyMap.KeyMap Aeson.Value
                     with: HMap.HashMap Text Aeson.Value
      Expected: HMap.HashMap Text Aeson.Value
        Actual: Aeson.Object
    • In the first argument of ‘HMap.toList’, namely ‘object’
      In the first argument of ‘(>>=)’, namely ‘HMap.toList object’
      In the expression:
        HMap.toList object >>= uncurry jsonToFormDataPrefixed
    |
293 |   HMap.toList object >>= uncurry jsonToFormDataPrefixed
    |               ^^^^^^

src/OpenAPI/Common.hs:295:15: error:
    • Couldn't match type: Data.Aeson.KeyMap.KeyMap Aeson.Value
                     with: HMap.HashMap Text Aeson.Value
      Expected: HMap.HashMap Text Aeson.Value
        Actual: Aeson.Object
    • In the first argument of ‘HMap.toList’, namely ‘object’
      In the first argument of ‘(>>=)’, namely ‘HMap.toList object’
      In the expression:
        HMap.toList object
          >>=
            (\ (x, y) -> jsonToFormDataPrefixed (prefix <> "[" <> x <> "]") y)
    |
295 |   HMap.toList object >>= (\(x, y) -> jsonToFormDataPrefixed (prefix <> "[" <> x <> "]") y)
    |               ^^^^^^
[ 2 of 25] Compiling OpenAPI.Generate.Doc ( src/OpenAPI/Generate/Doc.hs, dist/build/OpenAPI/Generate/Doc.o, dist/build/OpenAPI/Generate/Doc.dyn_o )
[ 3 of 25] Compiling OpenAPI.Generate.Internal.Embed ( src/OpenAPI/Generate/Internal/Embed.hs, dist/build/OpenAPI/Generate/Internal/Embed.o, dist/build/OpenAPI/Generate/Internal/Embed.dyn_o )
[ 4 of 25] Compiling OpenAPI.Generate.Log ( src/OpenAPI/Generate/Log.hs, dist/build/OpenAPI/Generate/Log.o, dist/build/OpenAPI/Generate/Log.dyn_o )
[ 5 of 25] Compiling OpenAPI.Generate.OptParse.Configuration ( src/OpenAPI/Generate/OptParse/Configuration.hs, dist/build/OpenAPI/Generate/OptParse/Configuration.o, dist/build/OpenAPI/Generate/OptParse/Configuration.dyn_o )
[ 6 of 25] Compiling OpenAPI.Generate.OptParse.Flags ( src/OpenAPI/Generate/OptParse/Flags.hs, dist/build/OpenAPI/Generate/OptParse/Flags.o, dist/build/OpenAPI/Generate/OptParse/Flags.dyn_o )
[ 7 of 25] Compiling OpenAPI.Generate.OptParse ( src/OpenAPI/Generate/OptParse.hs, dist/build/OpenAPI/Generate/OptParse.o, dist/build/OpenAPI/Generate/OptParse.dyn_o )

src/OpenAPI/Generate/OptParse.hs:174:38: error:
    • Couldn't match expected type ‘bytestring-0.11.5.3:Data.ByteString.Internal.Type.ByteString’
                  with actual type ‘Text’
    • In the second argument of ‘($)’, namely
        ‘renderColouredSchemaViaCodec @Configuration’
      In the second argument of ‘($)’, namely
        ‘TE.decodeUtf8 $ renderColouredSchemaViaCodec @Configuration’
      In the expression:
        T.unpack
          $ TE.decodeUtf8 $ renderColouredSchemaViaCodec @Configuration
    |
174 |           T.unpack $ TE.decodeUtf8 $ renderColouredSchemaViaCodec @Configuration
    |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ 8 of 25] Compiling OpenAPI.Generate.Types.ExternalDocumentation ( src/OpenAPI/Generate/Types/ExternalDocumentation.hs, dist/build/OpenAPI/Generate/Types/ExternalDocumentation.o, dist/build/OpenAPI/Generate/Types/ExternalDocumentation.dyn_o )
[ 9 of 25] Compiling OpenAPI.Generate.Types.Referencable ( src/OpenAPI/Generate/Types/Referencable.hs, dist/build/OpenAPI/Generate/Types/Referencable.o, dist/build/OpenAPI/Generate/Types/Referencable.dyn_o )
[10 of 25] Compiling OpenAPI.Generate.Types.Schema ( src/OpenAPI/Generate/Types/Schema.hs, dist/build/OpenAPI/Generate/Types/Schema.o, dist/build/OpenAPI/Generate/Types/Schema.dyn_o )
[11 of 25] Compiling OpenAPI.Generate.Types ( src/OpenAPI/Generate/Types.hs, dist/build/OpenAPI/Generate/Types.o, dist/build/OpenAPI/Generate/Types.dyn_o )

src/OpenAPI/Generate/Types.hs:249:27: error:
    • Couldn't match type: Data.Aeson.KeyMap.KeyMap Value
                     with: HMap.HashMap Text Value
      Expected: HMap.HashMap Text Value
        Actual: Object
    • In the first argument of ‘HMap.toList’, namely ‘o’
      In the second argument of ‘($)’, namely ‘HMap.toList o’
      In the second argument of ‘mapM’, namely
        ‘(Map.fromList
            . filter (\ (code, _) -> code >= 100 && code < 600)
                . Maybe.mapMaybe
                    (\ (code, response)
                       -> fmap (, response) . readMaybe . T.unpack $ code)
            $ HMap.toList o)’
    |
249 |             $ HMap.toList o
    |                           ^
[25 of 25] Compiling Paths_openapi3_code_generator ( dist/build/autogen/Paths_openapi3_code_generator.hs, dist/build/Paths_openapi3_code_generator.o, dist/build/Paths_openapi3_code_generator.dyn_o )
error: builder for '/nix/store/qmx8iijm91ankqnlhg2512hvcxkhidkr-openapi3-code-generator-0.1.0.7.drv' failed with exit code 1;
       last 25 log lines:
       > 174 |           T.unpack $ TE.decodeUtf8 $ renderColouredSchemaViaCodec @Configuration
       >     |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       > [ 8 of 25] Compiling OpenAPI.Generate.Types.ExternalDocumentation ( src/OpenAPI/Generate/Types/ExternalDocumentation.hs, dist/build/OpenAPI/Generate/Types/ExternalDocumentation.o, dist/build/OpenAPI/Generate/Types/ExternalDocumentation.dyn_o )
       > [ 9 of 25] Compiling OpenAPI.Generate.Types.Referencable ( src/OpenAPI/Generate/Types/Referencable.hs, dist/build/OpenAPI/Generate/Types/Referencable.o, dist/build/OpenAPI/Generate/Types/Referencable.dyn_o )
       > [10 of 25] Compiling OpenAPI.Generate.Types.Schema ( src/OpenAPI/Generate/Types/Schema.hs, dist/build/OpenAPI/Generate/Types/Schema.o, dist/build/OpenAPI/Generate/Types/Schema.dyn_o )
       > [11 of 25] Compiling OpenAPI.Generate.Types ( src/OpenAPI/Generate/Types.hs, dist/build/OpenAPI/Generate/Types.o, dist/build/OpenAPI/Generate/Types.dyn_o )
       >
       > src/OpenAPI/Generate/Types.hs:249:27: error:
       >     • Couldn't match type: Data.Aeson.KeyMap.KeyMap Value
       >                      with: HMap.HashMap Text Value
       >       Expected: HMap.HashMap Text Value
       >         Actual: Object
       >     • In the first argument of ‘HMap.toList’, namely ‘o’
       >       In the second argument of ‘($)’, namely ‘HMap.toList o’
       >       In the second argument of ‘mapM’, namely
       >         ‘(Map.fromList
       >             . filter (\ (code, _) -> code >= 100 && code < 600)
       >                 . Maybe.mapMaybe
       >                     (\ (code, response)
       >                        -> fmap (, response) . readMaybe . T.unpack $ code)
       >             $ HMap.toList o)’
       >     |
       > 249 |             $ HMap.toList o
       >     |                           ^
       > [25 of 25] Compiling Paths_openapi3_code_generator ( dist/build/autogen/Paths_openapi3_code_generator.hs, dist/build/Paths_openapi3_code_generator.o, dist/build/Paths_openapi3_code_generator.dyn_o )
       For full logs, run 'nix-store -l /nix/store/qmx8iijm91ankqnlhg2512hvcxkhidkr-openapi3-code-generator-0.1.0.7.drv'.
haroldcarr commented 8 months ago

Using stack appears to work (but would rather use nix (1st choice) or cabal)

> stack run -- --help
openapi3-code-generator.cabal is up-to-date
Generate Haskell code from OpenAPI 3 specifications

Usage: openapi3-code-generator-exe [--configuration FILEPATH] 
                                   [FILEPATH | --specification FILEPATH] 
NorfairKing commented 8 months ago

@haroldcarr there's a flake. I use that.

NorfairKing commented 8 months ago

Closing this because the installation is not broken. There's a flake and it builds.

haroldcarr commented 8 months ago

@NorfairKing It would be nice to be able to install via nix (besides building from a flake). But it is marked as broken:

nix-shell -p haskellPackages.openapi3-code-generator
error:
       ...

       error: Package ‘openapi3-code-generator-0.1.0.7’ in /nix/store/nlm3wz58fjzcbf7d9csf2czxmrvsk65k-nixpkgs/nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix:219920 is marked as broken, refusing to evaluate.
NorfairKing commented 8 months ago

What you're building is a nixpkgs derivation, which means this belongs on the nixpkgs issue tracker.

haroldcarr commented 8 months ago

Thanks for this package.