Closed paulyoung closed 4 years ago
I'm currently working around this with:
main :: IO ()
main = putStrLn . read . show . encode $ mySwagger
where
encode :: Swagger -> LByteString
encode = Aeson.encode . addPathsField . Aeson.toJSON
addPathsField :: Aeson.Value -> Aeson.Value
addPathsField value
| (Aeson.Object kvs) <- value =
Aeson.Object $ HashMap.alter (Just . fromMaybe (Aeson.object [])) "paths" kvs
| otherwise = value
Looks like a valid issue to me.
I did the easy part, and then I found that there is a lot of generics business going on in the aeson instances. Would you like to give it a shot?
no, wait, i have something.
I think #213 is a good enough fix now. Wasn't too hard if you value simplicity over elegance. :)
According to the Swagger 2 spec, the
paths
field is required, and some tooling considers it to be an error when the field is omitted.It's possible to generate such JSON using swagger2. I think
"paths": {}
should be emitted in the case where there are no paths.