45 lines
1.5 KiB
Ruby
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.10.tar.gz"
|
|
sha256 "25bf2a99a3cac8fc9e215a056d5b5238f9f9543a0133eb1886d6f782f227cb4a"
|
|
head "https://github.com/swagger-api/swagger-codegen.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "dc52ce0b0d78034c9bbb0ce2ccaa4796402bf6d780a2baef870f7ffe07dcd2f4" => :mojave
|
|
sha256 "90dad72ced25b5165615971a62c2a02e9456d57cb1c1a754e6cf8e55e1221861" => :high_sierra
|
|
sha256 "64f3be9cba3afe979b5cc2bbb6ea5a5752c0b02ab01642d1d3715ffd508721e8" => :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
|