homebrew-core/Formula/openapi-generator.rb

54 lines
1.5 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.3.1/openapi-generator-cli-4.3.1.jar"
sha256 "f438cd16bc1db28d3363e314cefb59384f252361db9cb1a04a322e7eb5b331c1"
license "Apache-2.0"
head do
url "https://github.com/OpenAPITools/openapi-generator.git"
depends_on "maven" => :build
end
bottle :unneeded
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