Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/openapi-generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Update gem from OpenAPI Spec

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'

jobs:
openapi-generate:
runs-on: ubuntu-latest
env:
INPUT_SPEC_VERSION: v4.0
steps:
- uses: actions/checkout@v5
- name: Set up system
run: sudo apt install -y xq
- name: OpenAPI Generate
run: bin/openapi-generate
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
add-paths: |
.openapi-generator
docs
lib
README.md
spec
commit-message: Update nutanix_clustermgmt gem
branch: openapi_generate
author: ManageIQ Bot <bot@manageiq.org>
committer: ManageIQ Bot <bot@manageiq.org>
delete-branch: true
labels: enhancement
assignees: agrare
push-to-fork: miq-bot/nutanix_clustermgmt-sdk-ruby
title: Update nutanix_clustermgmt gem
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
token: ${{ secrets.PR_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ build/

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

openapi-generator-cli-*.jar
5 changes: 5 additions & 0 deletions .openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

.gitlab-ci.yml
.gitignore
.travis.yml
Gemfile
15 changes: 15 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "nutanix_clustermgmt"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

require "irb"
IRB.start(__FILE__)
26 changes: 26 additions & 0 deletions bin/openapi-generate
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

if [ -z "$INPUT_SPEC_VERSION" ]; then
echo "ERROR: INPUT_SPEC_VERSION must be set"
exit 1
fi

if [ -z "$OPENAPI_GENERATOR_JAR" ]; then
# Detect the latest version of the openapi-generator-cli package
version=`wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/maven-metadata.xml -O - 2>/dev/null | xq -x "//metadata/versioning/latest"`
OPENAPI_GENERATOR_JAR=openapi-generator-cli-$version.jar

# Download the openapi-generator-cli jar if we don't already have it locally
if [ ! -f "$OPENAPI_GENERATOR_JAR" ]; then
echo "Downloading '$OPENAPI_GENERATOR_JAR'..."
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$version/$OPENAPI_GENERATOR_JAR
fi
fi

# Clear out any existing files in paths that are autogenerated to prevent deleted files
# from remaining after running the generate
rm -rf ./docs ./lib ./spec

# Generate the gem from the current openapi-spec
input_spec=https://developers.nutanix.com/api/v1/namespaces/clustermgmt/versions/$INPUT_SPEC_VERSION/yaml
java -jar $OPENAPI_GENERATOR_JAR generate --input-spec $input_spec --skip-validate-spec --generator-name ruby --config .openapi-config.json
Loading