haskell-servant / servant-swagger-ui

Provide embedded swagger UI for servant and swagger
46 stars 34 forks source link

No instance for (ToSchema (SwaggerUiHtml) #105

Closed tempuku closed 1 year ago

tempuku commented 1 year ago

When trying to configure specs:

todoSwagger :: Swagger
todoSwagger = toSwagger appAPI
  & info.title   .~ "Registry API"

The same error was with Data.Swagger.Internal.Swagger itself, but it was resolved with

instance ToSchema Swagger where
  declareNamedSchema _ = pure $ NamedSchema (Just "Swagger") mempty

when after deriving SwaggerUiHtml it requires instance ToSchema Value which end up with

Cannot derive Generic-based Swagger Schema for Value
  Value 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.
tempuku commented 1 year ago

I passed to toSwagger function extended version of API with swagger endpoint. It occurred the error.