Skip to content

Instantly share code, notes, and snippets.

@crandles
crandles / crd2jsonschema.sh
Created April 18, 2024 14:43 — forked from rawc0der/crd2jsonschema.sh
Extract openapi JSON schema from Kubernetes CRD manifest
#!/bin/bash
# Small utility function based on yq to extract openAPIV3Schema from CRD
# example: crd2jsonschema.sh ./crd-alertmanager.yaml
set -e
function crd2jsonschema() {
set -e
local xkgroup="x-kubernetes-group-version-kind"
local document="$1"
local openAPIV3Schema=$(mktemp -u)