From f30ff1f21ee7b52ab345e30bb077712766e0a25b Mon Sep 17 00:00:00 2001 From: Kabir Oberai Date: Mon, 21 Jul 2025 04:15:53 -0400 Subject: [PATCH 1/2] Pin ASC spec --- Makefile | 34 ++++++++++++++++++--------- Package.swift | 2 +- Sources/DeveloperAPI/spec-version.txt | 2 ++ 3 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 Sources/DeveloperAPI/spec-version.txt diff --git a/Makefile b/Makefile index cdad256f..b184285d 100644 --- a/Makefile +++ b/Makefile @@ -143,7 +143,11 @@ $(SWIFTLINT_BIN): @mv .tmp/swiftlint/swiftlint $@ @ln -s swiftlint-$(SWIFTLINT_VERSION) .tmp/swiftlint/swiftlint -SPEC_URL = https://developer.apple.com/sample-code/app-store-connect/app-store-connect-openapi-specification.zip +SPEC_STRING = $(shell cat Sources/DeveloperAPI/spec-version.txt) +SPEC_COMMIT = $(word 1,$(SPEC_STRING)) +SPEC_VERSION = $(word 2,$(SPEC_STRING)) +SPEC_URL = https://raw.githubusercontent.com/EvanBacon/App-Store-Connect-OpenAPI-Spec/$(SPEC_COMMIT)/specs/$(SPEC_VERSION).json +SPEC_BASE = openapi/base-$(SPEC_VERSION).json .PHONY: api # Regenerate the OpenAPI client code @@ -159,14 +163,22 @@ api: openapi/openapi.json .PHONY: update-api # Update OpenAPI spec and regenerate the client code update-api: - @+$(MAKE) -B api - -openapi/openapi.json: openapi/base.json Sources/DeveloperAPI/patch.js - node Sources/DeveloperAPI/patch.js < openapi/base.json > openapi/openapi.json - -openapi/base.json: + @+$(MAKE) update-api-version + @+$(MAKE) api + +.PHONY: update-api-version +# Just update the OpenAPI spec version +update-api-version: + latest_commit=$$(curl -fsSL 'https://api.github.com/repos/EvanBacon/App-Store-Connect-OpenAPI-Spec/commits?per_page=1' \ + | jq -r '.[0].sha'); \ + echo "$$latest_commit" > Sources/DeveloperAPI/spec-version.txt; \ + curl -fsSL "https://raw.githubusercontent.com/EvanBacon/App-Store-Connect-OpenAPI-Spec/$$latest_commit/specs/latest.json" \ + | jq -r '.info.version' >> Sources/DeveloperAPI/spec-version.txt + +openapi/openapi.json: $(SPEC_BASE) Sources/DeveloperAPI/patch.js + node Sources/DeveloperAPI/patch.js < $(SPEC_BASE) > openapi/openapi.json + +$(SPEC_BASE): @mkdir -p openapi -# piping curl|bsdtar concatenates xattrs into the JSON :thonk: - curl -fsSL "$(SPEC_URL)" -o openapi/spec.zip - bsdtar -xO -f openapi/spec.zip > openapi/base.json - rm -f openapi/spec.zip + @rm -f openapi/base*.json + curl -fsSL "$(SPEC_URL)" -o "$@" diff --git a/Package.swift b/Package.swift index 4a702eec..9018fdfa 100644 --- a/Package.swift +++ b/Package.swift @@ -88,7 +88,7 @@ let package = Package( dependencies: [ .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"), ], - exclude: ["openapi-generator-config.yaml", "patch.js"] + exclude: ["openapi-generator-config.yaml", "patch.js", "spec-version.txt"] ), .target( name: "XKit", diff --git a/Sources/DeveloperAPI/spec-version.txt b/Sources/DeveloperAPI/spec-version.txt new file mode 100644 index 00000000..9e195742 --- /dev/null +++ b/Sources/DeveloperAPI/spec-version.txt @@ -0,0 +1,2 @@ +a210f7e8a6591416fbf6c2d718783ba27d9e050a +4.0.0 From b5739d8b4895e553dd7eea401a210895ea6eb175 Mon Sep 17 00:00:00 2001 From: Kabir Oberai Date: Mon, 21 Jul 2025 04:19:01 -0400 Subject: [PATCH 2/2] Make tweaks --- Makefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index b184285d..e5933d2a 100644 --- a/Makefile +++ b/Makefile @@ -143,10 +143,11 @@ $(SWIFTLINT_BIN): @mv .tmp/swiftlint/swiftlint $@ @ln -s swiftlint-$(SWIFTLINT_VERSION) .tmp/swiftlint/swiftlint -SPEC_STRING = $(shell cat Sources/DeveloperAPI/spec-version.txt) +SPEC_STRING := $(shell cat Sources/DeveloperAPI/spec-version.txt) SPEC_COMMIT = $(word 1,$(SPEC_STRING)) SPEC_VERSION = $(word 2,$(SPEC_STRING)) -SPEC_URL = https://raw.githubusercontent.com/EvanBacon/App-Store-Connect-OpenAPI-Spec/$(SPEC_COMMIT)/specs/$(SPEC_VERSION).json +SPEC_URL_BASE = https://raw.githubusercontent.com/EvanBacon/App-Store-Connect-OpenAPI-Spec +SPEC_URL = $(SPEC_URL_BASE)/$(SPEC_COMMIT)/specs/$(SPEC_VERSION).json SPEC_BASE = openapi/base-$(SPEC_VERSION).json .PHONY: api @@ -169,10 +170,11 @@ update-api: .PHONY: update-api-version # Just update the OpenAPI spec version update-api-version: - latest_commit=$$(curl -fsSL 'https://api.github.com/repos/EvanBacon/App-Store-Connect-OpenAPI-Spec/commits?per_page=1' \ + latest_commit=$$(curl -fsSL \ + 'https://api.github.com/repos/EvanBacon/App-Store-Connect-OpenAPI-Spec/commits?per_page=1' \ | jq -r '.[0].sha'); \ echo "$$latest_commit" > Sources/DeveloperAPI/spec-version.txt; \ - curl -fsSL "https://raw.githubusercontent.com/EvanBacon/App-Store-Connect-OpenAPI-Spec/$$latest_commit/specs/latest.json" \ + curl -fsSL "$(SPEC_URL_BASE)/$$latest_commit/specs/latest.json" \ | jq -r '.info.version' >> Sources/DeveloperAPI/spec-version.txt openapi/openapi.json: $(SPEC_BASE) Sources/DeveloperAPI/patch.js