Search code examples
swaggeropenapi-generator

How do I make OpenapiGenerator to generate models when defined inline?


I tried running java -jar openapi-generator-cli.jar generate -i 'swagger.json' -g scala-akka -o scala_client but it didn't produce any modules (doesn't work with Java nor Clojure).

Running java -jar openapi-generator-cli.jar generate -c config.yaml -i 'swagger.json' -g scala-akka -o scala_client --generate-alias-as-model (also without config and/or without --generate-alias-as-model), doesn't produce any model libs either.

Removing "additionalProperties": false, from the inline schema def makes it generate model classes. What also works is to define the schema using definitions + "$ref" : "..." - but neither of those are feasible with the library I'm using for my server.

I don't quite understand why it won't generate the models. Can't seem to find an answer anywhere, am I missing something simple?

My swagger.json

Any help would be much appreciated.


Solution

  • I think the only issue is that your are using a 2.0 version of the OpenAPI-Specification. One can easily migrate to version 3.* (try THIS for example), then the models will be generated (for me it worked with scala-akka and java-spring)

    transformed_to_3.0.0.json