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

Add instances for new Servant.API.Range type #106

Open
kutyel opened this issue Feb 18, 2025 · 0 comments
Open

Add instances for new Servant.API.Range type #106

kutyel opened this issue Feb 18, 2025 · 0 comments

Comments

@kutyel
Copy link

kutyel commented Feb 18, 2025

When this is merged, I have the code ready to have the ToSchema and ToParamSchema instances derived for free based on this code:

instance (KnownNat min, KnownNat max) => ToSchema (BoundedNat min max) where
  declareNamedSchema _ =
    pure . NamedSchema Nothing $
      mempty
        & #type ?~ OpenApiInteger
        & #minimum ?~ fromIntegral (minBound @(BoundedNat min max)).unBoundedNat
        & #maximum ?~ fromIntegral (maxBound @(BoundedNat min max)).unBoundedNat

instance (KnownNat min, KnownNat max) => ToParamSchema (BoundedNat min max) where
  toParamSchema = toSchema
@kutyel kutyel changed the title Add instances for new Servant.API.Range type Add instances for new Servant.API.Range type Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant