-
-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Expand file tree
/
Copy pathopenapi-generator.rb
More file actions
68 lines (60 loc) · 2.4 KB
/
openapi-generator.rb
File metadata and controls
68 lines (60 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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/7.22.0/openapi-generator-cli-7.22.0.jar"
sha256 "3f1e6ce5c6ad4f15242c6170ab43aad4bad771622617eeece4a7d4f72ffaf329"
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: "f1192a13a4b9a3191372eb4f8d7188fda1feec67acc2dd072ee146c26546196e"
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.write_jar_script libexec/"openapi-generator-cli.jar", "openapi-generator"
end
test do
# From the OpenAPI Spec website
# https://web.archive.org/web/20230505222426/https://swagger.io/docs/specification/basic-structure/
(testpath/"minimal.yaml").write <<~YAML
---
openapi: 3.0.3
info:
version: 0.0.0
title: Sample API
servers:
- url: http://api.example.com/v1
description: Optional server description, e.g. Main (production) server
- url: http://staging-api.example.com
description: Optional server description, e.g. Internal staging server for testing
paths:
/users:
get:
summary: Returns a list of users.
responses:
'200':
description: A JSON array of user names
content:
application/json:
schema:
type: array
items:
type: string
YAML
system bin/"openapi-generator", "generate", "-i", "minimal.yaml", "-g", "openapi", "-o", "./"
# Python is broken for (at least) Java 20
system bin/"openapi-generator", "generate", "-i", "minimal.yaml", "-g", "python", "-o", "./"
end
end