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

Comments

Projects
None yet
4 participants
@felixonmars
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

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Sep 10, 2017

Owner

Thanks, what GHC version is this ?

Owner

simonmichael commented Sep 10, 2017

Thanks, what GHC version is this ?

@felixonmars

This comment has been minimized.

Show comment
Hide comment
@felixonmars

felixonmars Sep 10, 2017

Contributor

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

Contributor

felixonmars commented Sep 10, 2017

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

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Sep 10, 2017

Owner

Oh right I get you. Thanks.

Owner

simonmichael commented Sep 10, 2017

Oh right I get you. Thanks.

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Sep 13, 2017

Owner

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

Owner

simonmichael commented Sep 13, 2017

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

@simonmichael

This comment has been minimized.

Show comment
Hide comment
Owner

simonmichael commented Sep 13, 2017

@fizruk

This comment has been minimized.

Show comment
Hide comment
@fizruk

fizruk 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

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

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Sep 19, 2017

Owner

Noted, thank you!

Owner

simonmichael commented Sep 19, 2017

Noted, thank you!

@juhp

This comment has been minimized.

Show comment
Hide comment
@juhp

juhp Sep 22, 2017

2.1.6 is out

juhp commented Sep 22, 2017

2.1.6 is out

simonmichael added a commit that referenced this issue Sep 22, 2017

@simonmichael simonmichael reopened this Sep 22, 2017

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Sep 22, 2017

Owner

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

Owner

simonmichael commented Sep 22, 2017

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

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Sep 25, 2017

Owner

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

Owner

simonmichael commented Sep 25, 2017

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

@simonmichael simonmichael reopened this Sep 25, 2017

simonmichael added a commit that referenced this issue Sep 27, 2017

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