homebrew-core/Formula/swagger-codegen.rb
2019-04-05 12:25:21 +02:00

45 lines
1.5 KiB
Ruby

class SwaggerCodegen < Formula
desc "Generate clients, server stubs, and docs from an OpenAPI spec"
homepage "https://swagger.io/swagger-codegen/"
url "https://github.com/swagger-api/swagger-codegen/archive/v3.0.7.tar.gz"
sha256 "4df70e638d1ce9023165c909827dd1cd02bbec1ae5756a4bb7891a0747886d66"
head "https://github.com/swagger-api/swagger-codegen.git"
bottle do
cellar :any_skip_relocation
sha256 "0eb645afb58b06afe4f9c18baa1faf08350e1399fb8bf2379daf335ae5975eb6" => :mojave
sha256 "f7ed8982e21a3885e5dc8177805da17ce0c3a2c877d63afbd66584877b8d0e7d" => :high_sierra
sha256 "4cfd927b51718bc2683b4404a96bc316f41a4211621db294ce319d767db43885" => :sierra
end
depends_on "maven" => :build
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
system "mvn", "clean", "package"
libexec.install "modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
bin.write_jar_script libexec/"swagger-codegen-cli.jar", "swagger-codegen"
end
test do
(testpath/"minimal.yaml").write <<~EOS
---
openapi: 3.0.0
info:
version: 0.0.0
title: Simple API
paths:
/:
get:
responses:
200:
description: OK
EOS
system "#{bin}/swagger-codegen", "generate", "-i", "minimal.yaml", "-l", "html"
assert_includes File.read(testpath/"index.html"), "<h1>Simple API</h1>"
end
end