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.2.3/openapi-generator-cli-4.2.3.jar"
sha256 "dcd70b7017f57c767f9752f7db526b3c351597bb0c661db6430ff73b6e0c4c8d"
revision 1
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