DEV Community

Said Olano
Said Olano

Posted on

Create Java Spring artifacts from an OpenAPI file

To create Java Spring artifacts (such as controllers, models, and configurations) from an OpenAPI file, you can use tools like OpenAPI Generator. This process automates the generation of Spring Boot-based code from an OpenAPI specification (e.g., a YAML or JSON file).

This is a snippet of the command to achieve this output generation:

java -jar openapi-generator-cli.jar generate \
  -i openapi.yaml \
  -g spring \
  -o ./spring-output \
  --additional-properties=java8=true,interfaceOnly=true,dateLibrary=java8
Enter fullscreen mode Exit fullscreen mode

You could have something like this:

And once you integrate the right plugins, you might retrieve as items generated, something like this:

Top comments (0)