Hi, is there a CLI version of the OpenAPI generato...
# http4k
c
Hi, is there a CLI version of the OpenAPI generator? https://toolbox.http4k.org/openapi
d
yes - you can install it from the command line using brew.
see the instructions in https://toolbox.http4k.org/
c
Ah, interesting, so would that install it a webapp to use like we do here https://toolbox.http4k.org/openapi or a CLI tool?
d
no - it's a command line
c
Grand, thanks!
d
image.png
c
Excellent, thank you so much!
So I've been testing this with the PetStore example: https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v3.0/petstore.yaml It doesn't seem to generate the model though. For
Pet.kt
we simply get an empty file with the package name and nothing else
Copy code
package com.test
It seems to work with this though https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml The only difference I can spot as relevant though is the fact that
Pet
is under
components.schemas
in the former and
components.requestBodies
in the latter
I take it that means the generator only treats certain
schema
elements?
d
@Cosmin Marginean There are many reasons for the OpenApi generator to fail - some of these are limitations, but others are to do with illegal/invalid usages of the OpenAPI specification. The generator is quite strict about these. As a way of example - the use of complex values inside a query parameter - this is described as an "object" when in actuality it's a string.
c
Yes, it seems so. Trying to replicate that petstore structure see if it gets me any closer
d
if you try and run it through the web version you should get a bunch of output in the response about where it failed
c
Ah, yeah, tried that. In essence it says it worked (green response message) but the content isn't there for models. So yeah, I guess more diagnosis would be helpful for this tool.
d
we're constantly making changes to it.. I've actually done a couple recently and it seems like thst's fixed that particular one
let me release it and you can try again..
🙌 1
(I know there is another compile failure in addPet with a duplicate parameter but that's not new.. another thing to tweak )