https://kotlinlang.org logo
#http4k
Title
# http4k
c

Cosmin Marginean

03/01/2024, 3:45 PM
Hi, is there a CLI version of the OpenAPI generator? https://toolbox.http4k.org/openapi
d

dave

03/01/2024, 4:38 PM
yes - you can install it from the command line using brew.
see the instructions in https://toolbox.http4k.org/
c

Cosmin Marginean

03/01/2024, 4:40 PM
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

dave

03/01/2024, 4:41 PM
no - it's a command line
c

Cosmin Marginean

03/01/2024, 4:41 PM
Grand, thanks!
d

dave

03/01/2024, 4:42 PM
image.png
c

Cosmin Marginean

03/01/2024, 4:43 PM
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

dave

03/06/2024, 1:49 PM
@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

Cosmin Marginean

03/06/2024, 1:52 PM
Yes, it seems so. Trying to replicate that petstore structure see if it gets me any closer
d

dave

03/06/2024, 2:21 PM
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

Cosmin Marginean

03/06/2024, 2:29 PM
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

dave

03/06/2024, 2:40 PM
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 )