biocad / openapi3

OpenAPI 3.0 data model
BSD 3-Clause "New" or "Revised" License
39 stars 53 forks source link

add `ToSchema Schema` instance #92

Open teto opened 8 months ago

teto commented 8 months ago

I am trying to return a Json schema in my servant endpoint. I tried to derive generically ToSchema Schema but it failed because of orderedmaps I tried a manual instance but it doesn't pass the openapi validators ofc.

instance ToSchema Schema where
  declareNamedSchema _ =
      pure $ NamedSchema Nothing $ mempty
        & properties .~ [
          ("required", Inline $ toSchema (Proxy @Int))
          , ("properties", Inline $ toSchema (Proxy @Int))
          , ("example", Inline $ mempty & type_ ?~ OpenApiObject)
          ]

I wish the instance would live in openapi3.