Skip to content

Commit 7ccbee4

Browse files
committed
Add GitHub Action to autogenerate from the openapi spec
1 parent 2790d82 commit 7ccbee4

File tree

5 files changed

+76
-25015
lines changed

5 files changed

+76
-25015
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Update gem from OpenAPI Spec
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * 0'
7+
8+
jobs:
9+
openapi-generate:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v5
13+
- name: Set up system
14+
run: sudo apt install -y xq
15+
- name: OpenAPI Generate
16+
run: bin/openapi-generate
17+
- name: Create Pull Request
18+
uses: peter-evans/create-pull-request@v7
19+
with:
20+
add-paths: |
21+
.openapi-generator
22+
docs
23+
lib
24+
README.md
25+
spec
26+
commit-message: Update nutanix_clustermgmt gem
27+
branch: openapi_generate
28+
author: ManageIQ Bot <bot@manageiq.org>
29+
committer: ManageIQ Bot <bot@manageiq.org>
30+
delete-branch: true
31+
labels: enhancement
32+
assignees: agrare
33+
push-to-fork: miq-bot/nutanix_clustermgmt-sdk-ruby
34+
title: Update nutanix_clustermgmt gem
35+
body: Update the nutanix_clustermgmt-sdk-ruby gem from the nutanix_clustermgmt openapi-spec https://developers.nutanix.com/api/v1/namespaces/clustermgmt/versions/v4.0/yaml
36+
token: ${{ secrets.PR_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ build/
3737

3838
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
3939
.rvmrc
40+
41+
openapi-generator-cli-*.jar

bin/console

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require "bundler/setup"
5+
require "nutanix_clustermgmt"
6+
7+
# You can add fixtures and/or initialization code here to make experimenting
8+
# with your gem easier. You can also use a different console, if you like.
9+
10+
# (If you use this, don't forget to add pry to your Gemfile!)
11+
# require "pry"
12+
# Pry.start
13+
14+
require "irb"
15+
IRB.start(__FILE__)

bin/openapi-generate

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
if [ -z "$OPENAPI_GENERATOR_JAR" ]; then
4+
# Detect the latest version of the openapi-generator-cli package
5+
version=`wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/maven-metadata.xml -O - 2>/dev/null | xq -x "//metadata/versioning/latest"`
6+
OPENAPI_GENERATOR_JAR=openapi-generator-cli-$version.jar
7+
8+
# Download the openapi-generator-cli jar if we don't already have it locally
9+
if [ ! -f "$OPENAPI_GENERATOR_JAR" ]; then
10+
echo "Downloading '$OPENAPI_GENERATOR_JAR'..."
11+
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$version/$OPENAPI_GENERATOR_JAR
12+
fi
13+
fi
14+
15+
# Clear out any existing files in paths that are autogenerated to prevent deleted files
16+
# from remaining after running the generate
17+
rm -rf ./docs ./lib ./spec
18+
19+
# Generate the gem from the current openapi-spec
20+
input_spec_version=v4.0
21+
input_spec=https://developers.nutanix.com/api/v1/namespaces/clustermgmt/versions/$input_spec_version/yaml
22+
23+
java -jar $OPENAPI_GENERATOR_JAR generate --input-spec $input_spec --skip-validate-spec --generator-name ruby --config .openapi-config.json

0 commit comments

Comments
 (0)