homebrew-core/Formula/openapi-generator.rb
William Cheng 3e683a271e
openapi-generator 4.2.2
Closes #47383.

Signed-off-by: Sean Molenaar <smillerdev@me.com>
2019-12-02 12:33:30 +01:00

52 lines
1.6 KiB
Ruby

class OpenapiGenerator < Formula
desc "Generate clients, server & docs from an OpenAPI spec (v2, v3)"
homepage "https://openapi-generator.tech/"
url "https://search.maven.org/remotecontent?filepath=org/openapitools/openapi-generator-cli/4.2.2/openapi-generator-cli-4.2.2.jar"
sha256 "2e7a81f2bcd37598550e2e4f57a85fa666fbc0b4eb025444b977502a06d94edd"
head do
url "https://github.com/OpenAPITools/openapi-generator.git"
depends_on "maven" => :build
end
bottle :unneeded
depends_on :java => "1.8+"
def install
# Need to set JAVA_HOME manually since maven overrides 1.8 with 1.7+
cmd = Language::Java.java_home_cmd("1.8")
ENV["JAVA_HOME"] = Utils.popen_read(cmd).chomp
if build.head?
system "mvn", "clean", "package", "-Dmaven.javadoc.skip=true"
libexec.install "modules/openapi-generator-cli/target/openapi-generator-cli.jar"
bin.write_jar_script libexec/"openapi-generator-cli.jar", "openapi-generator", "$JAVA_OPTS"
else
libexec.install "openapi-generator-cli-#{version}.jar"
bin.write_jar_script libexec/"openapi-generator-cli-#{version}.jar", "openapi-generator", "$JAVA_OPTS"
end
end
test do
(testpath/"minimal.yaml").write <<~EOS
---
swagger: '2.0'
info:
version: 0.0.0
title: Simple API
host: localhost
basePath: /v2
schemes:
- http
paths:
/:
get:
operationId: test_operation
responses:
200:
description: OK
EOS
system bin/"openapi-generator", "generate", "-i", "minimal.yaml", "-g", "openapi", "-o", "./"
end
end