Skip to content

Instantly share code, notes, and snippets.

@goatfryed
goatfryed / sort-openapi.sh
Created August 13, 2024 19:27
sort openapi specs with yq
#!/usr/bin/env bash
set -e
INPUT=$1
# the order of keys. unmentioned keys are sorted ascending after it
TOP_LEVEL_ORDER=(openapi info servers tags paths components)
COMPONENTS_ORDER=(schemas headers parameters requestBodies responses securitySchemes examples)
PROPERTIES_ORDER=(id href title name description status)
sort_by_key_args() {