homebrew-core/Formula/openapi-generator.rb

61 lines
1.8 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/6.2.1/openapi-generator-cli-6.2.1.jar"
sha256 "f2c8600f2c23ee1123eebf47ef0f40db386627e75b0340ca16182c10f4174fa9"
license "Apache-2.0"
livecheck do
url "https://search.maven.org/remotecontent?filepath=org/openapitools/openapi-generator-cli/maven-metadata.xml"
regex(%r{<version>v?(\d+(?:\.\d+)+)</version>}i)
end
bottle do
sha256 cellar: :any_skip_relocation, all: "fad081a6f34421c33e1343b037858616fbaf565314846980ed899d603d7b38fc"
end
head do
url "https://github.com/OpenAPITools/openapi-generator.git", branch: "master"
depends_on "maven" => :build
end
depends_on "openjdk"
def install
if build.head?
system "mvn", "clean", "package", "-Dmaven.javadoc.skip=true"
libexec.install "modules/openapi-generator-cli/target/openapi-generator-cli.jar"
else
libexec.install "openapi-generator-cli-#{version}.jar" => "openapi-generator-cli.jar"
end
(bin/"openapi-generator").write <<~EOS
#!/bin/bash
exec "#{Formula["openjdk"].opt_bin}/java" $JAVA_OPTS -jar "#{libexec}/openapi-generator-cli.jar" "$@"
EOS
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