Skip to content
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

hledger-api doesn't build with swagger2 2.1.5 #612

Closed
felixonmars opened this issue Sep 10, 2017 · 10 comments
Closed

hledger-api doesn't build with swagger2 2.1.5 #612

felixonmars opened this issue Sep 10, 2017 · 10 comments
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. old:api The hledger-api tool, deprecated in 2019.

Comments

@felixonmars
Copy link
Contributor

felixonmars commented Sep 10, 2017

[1 of 1] Compiling Main             ( hledger-api.hs, dist/build/hledger-api/hledger-api-tmp/Main.dyn_o )

hledger-api.hs:220:10: error:
    • Cannot derive Generic-based Swagger Schema for Price
      Price is a mixed sum type (has both unit and non-unit constructors).
      Swagger does not have a good representation for these types.
      Use genericDeclareNamedSchemaUnrestricted if you want to derive schema
      that matches aeson's Generic-based toJSON,
      but that's not supported by some Swagger tools.
    • In the expression:
        Data.Swagger.Internal.Schema.$dmdeclareNamedSchema @Price
      In an equation for ‘declareNamedSchema’:
          declareNamedSchema
            = Data.Swagger.Internal.Schema.$dmdeclareNamedSchema @Price
      In the instance declaration for ‘ToSchema Price’
    |
220 | instance ToSchema Price
    |          ^^^^^^^^^^^^^^
@simonmichael simonmichael added A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. old:api The hledger-api tool, deprecated in 2019. labels Sep 10, 2017
@simonmichael
Copy link
Owner

Thanks, what GHC version is this ?

@felixonmars
Copy link
Contributor Author

It's GHC 8.2.1. It builds fine with swagger2 2.1.4.1.

@simonmichael
Copy link
Owner

Oh right I get you. Thanks.

@simonmichael
Copy link
Owner

PS we do still need a to fix this for swagger 2.1.5 in the future, help welcome.

@simonmichael
Copy link
Owner

@fizruk
Copy link

fizruk commented Sep 19, 2017

@simonmichael the error message was designed to guide migration process.

    • Cannot derive Generic-based Swagger Schema for Price
      Price is a mixed sum type (has both unit and non-unit constructors).
      Swagger does not have a good representation for these types.
      Use genericDeclareNamedSchemaUnrestricted if you want to derive schema
      that matches aeson's Generic-based toJSON,
      but that's not supported by some Swagger tools.

Specifically this part:

      Use genericDeclareNamedSchemaUnrestricted ...

So you just need this change:

- instance ToSchema Price
+ instance ToSchema Price where
+   declareNamedSchema = genericDeclareNamedSchemaUnrestricted defaultSchemaOptions

@simonmichael
Copy link
Owner

Noted, thank you!

@juhp
Copy link

juhp commented Sep 22, 2017

2.1.6 is out

@simonmichael
Copy link
Owner

Reopening this as a reminder to follow through with GetShopTV/swagger2#122 .

@simonmichael
Copy link
Owner

hledger-api got removed from stackage, remember to re-add it when 1.4 is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. old:api The hledger-api tool, deprecated in 2019.
Projects
None yet
Development

No branches or pull requests

4 participants