I just tried the openapi generator on the website ...
# http4k
p
I just tried the openapi generator on the website (https://toolbox.http4k.org/openapi) with the petstore example from openapi https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml unfortunately it did not work at all. There is reaction in the ui and the network tab just shows a 400 error. Is this a known issue? Is the openapi generator still maintained?
d
Yes - it's definitely maintained, so we expect it to work. Will look at it when we get the chance but it's holiday season for the maintainer season at the moment...
Thanks for letting us know
I've looked into this and it seems that the OpenApi specification that you used (the official spec on in the open api repo!) is actually not really valid! The thing that the generator is blowing up on is that the spec states that the endpoint will take XML, JSON and form parameters for the body. However - one of the fields (category) is actually a complex object with 2 fields - which is not representable in a form encoded form AFAIK. You can see the problem starts here: https://github.com/swagger-api/swagger-petstore/blob/1e0831732ee927238bc5de46607befc2401e18e4/src/main/resources/openapi.yaml#L71 The toolbox error message could be nicer for sure, but if you remove these erroneous examples from the spec, the generation actually works. Previous versions of the spec which didn't have this problem also work out of the box.
m
I just tried took with this OpenAPI spec, and I also got a 400 error. How do you know what's wrong?
Is this tool open source? Is it possible to run it yourself?
d
It's not open source so you can't run it yourself - but having the input openapi spec does really help as we can track down if there are bugs in the parser- so thank you for that! It's not very forgiving for spec violations though and the error messages that are produced by the code are cryptic at best - especially if you don't have the source.
m
The main problem is that I don't see any error messages whatsoever, only the HTTP 400 response.
At first I thought that the tool was completely broken.
d
yes - that is all we can give you - as above, the error message could be improved
we'll look into improving it and seeing where this spec is failing
So I've added some logging and will redeploy with that (so we will see some type of trace on what the generator was trying to do in the 400 response). In this case, there is a case in the spec which isn't actually covered by the generator so we will look at implementing that as well v soon
@Mikael Ståldal ok - this missing feature is now added. we'll look at improving the diagnostics when we get a chance 🙂
m
🙏