Skip to content

Commit fe7465b

Browse files
committed
Merge pull request #12 from Fryguy/openapi-generate
Add GitHub Action to autogenerate from the openapi spec
2 parents 2790d82 + 429fe83 commit fe7465b

File tree

6 files changed

+86
-25015
lines changed

6 files changed

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

.openapi-generator-ignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@
2121
#docs/*.md
2222
# Then explicitly reverse the ignore rule for a single file:
2323
#!docs/README.md
24+
25+
.gitlab-ci.yml
26+
.gitignore
27+
.travis.yml
28+
Gemfile

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