openapi.yaml
openapi: 3.0.2 info: version: 0.1.0 title: example servers: - url: 'http://192.168.56.10:8080/example' paths: /hello: get: description: Hello World responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Hello' tags: - example components: schemas: Hello: type: object properties: message: type: string example: 'Hello World' x-tags: - example
application.yaml
inputSpec: 'openapi.yaml' generatorName: spring outputDir: modules/application additionalProperties: configPackage: 'com.mamezou_tech.example.controller.configuration' modelPackage: 'com.mamezou_tech.example.controller.model' apiPackage: 'com.mamezou_tech.example.controller.api' invokerPackage: 'com.mamezou_tech.example.controller.api' groupId: 'com.mamezou_tech.example-service' dateLibrary: java8 java8: true library: spring-boot artifactId: 'example-application' artifactVersion: '0.1.0' snapshotVersion: 'true' useTags: true
$ sudo docker run -it –rm -v `pwd`:/build -v example:/root/.m2 maven:3.8-eclipse-temurin-17-focal bash
$ curl -L https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.0.0/openapi-generator-cli-6.0.0.jar -o /tmp/openapi-generator-cli.jar
$ cd /build
$ java -DsupportingFiles -jar /tmp/openapi-generator-cli.jar batch application.yaml
[main] INFO o.o.codegen.cmd.GenerateBatch – Batch generation using up to 4 threads.
Includes: /build
Root: /build
[pool-1-thread-1] Generating spring (outputs to /build/modules/application)…
################################################################################
# Thanks for using OpenAPI Generator. #
# Please consider donation to help us maintain this project 🙏 #
# https://opencollective.com/openapi_generator/donate #
################################################################################
[pool-1-thread-1] Finished generating spring…
[SUCCESS] Batch generation finished 1 generators successfully.
$ cd modules/application
$ mvn install
なんだろう、spring bootが多いな