Skip to content

Commit 2827f60

Browse files
committed
refactor(spec): port the OpenAPI spec to TypeSpec
api/openapi-spec/v1.0.yaml becomes a build artefact compiled from spec/*.tsp; every client pipeline runs the compile step before generating, and a Makefile + scripts cover local generation. Sibling endpoints share templated operations (DriveItemOps, PermissionsOps, LibreGraphOps) so identical routes cannot drift apart. Pins TypeSpec 1.13.0. Semantic changes against the previous YAML: - add GET /v1.0/drives/{drive-id}/root/children and GET /v1.0/drives/{drive-id}/items/{item-id}/children - CreateInvitation's request body is now required - invitation ops gained the missing 'default: odata.error' response - example blocks fixed to match their schemas (grantedToV2 as single object, parentReference.driveId casing, @UI.Hidden, onPremisesSamAccountName, {value: [...]} collection wrappers) Generated Go and TypeScript clients are structurally unchanged.
1 parent d194036 commit 2827f60

35 files changed

Lines changed: 7565 additions & 6273 deletions

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
composer.lock
22
vendor
3-
tmp
3+
tmp
4+
5+
# Generated by `make spec` (`scripts/compile-spec.sh`).
6+
api/openapi-spec/v1.0.yaml
7+
8+
# Local build artefacts.
9+
build/
10+
spec/build/
11+
spec/node_modules/

.woodpecker/build-cpp-qt.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
variables:
33
- &alpine_image 'owncloudci/alpine:latest'
4+
- &node_image 'node:22-alpine'
45
- &generator_image 'openapitools/openapi-generator-cli:v7.13.0@sha256:52b4b2bb6129b086b0f12614e98c884d378a84349fa114b07e20515702a793c5'
56
- &environment
67
HTTP_PROXY:
@@ -21,20 +22,17 @@ steps:
2122
ref: HEAD
2223
path: libre-graph-api-cpp-qt-client
2324
remote: https://github.com/opencloud-eu/libre-graph-api-cpp-qt-client.git
25+
compile-spec:
26+
image: *node_image
27+
environment: *environment
28+
commands:
29+
- sh scripts/compile-spec.sh
2430
generate-cpp-qt:
2531
image: *generator_image
2632
environment: *environment
2733
commands:
2834
- rm -Rf libre-graph-api-cpp-qt-client/*
29-
- '/usr/local/bin/docker-entrypoint.sh generate
30-
--enable-post-process-file
31-
-i api/openapi-spec/v1.0.yaml
32-
--additional-properties=packageName=libregraph
33-
--git-user-id=opencloud-eu
34-
--git-repo-id=libre-graph-api-cpp-qt-client
35-
-g cpp-qt-client
36-
-t templates/cpp-qt-client
37-
-o libre-graph-api-cpp-qt-client'
35+
- sh scripts/generate-cpp-qt-client.sh
3836
- cp LICENSE libre-graph-api-cpp-qt-client/LICENSE
3937
diff:
4038
image: *alpine_image

.woodpecker/build-go.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
variables:
33
- &alpine_image 'owncloudci/alpine:latest'
4+
- &node_image 'node:22-alpine'
45
- &generator_image 'openapitools/openapi-generator-cli:v7.13.0@sha256:52b4b2bb6129b086b0f12614e98c884d378a84349fa114b07e20515702a793c5'
56
- &environment
67
HTTP_PROXY:
@@ -21,20 +22,17 @@ steps:
2122
ref: HEAD
2223
path: libre-graph-api-go
2324
remote: https://github.com/opencloud-eu/libre-graph-api-go.git
25+
compile-spec:
26+
image: *node_image
27+
environment: *environment
28+
commands:
29+
- sh scripts/compile-spec.sh
2430
generate-go:
2531
image: *generator_image
2632
environment: *environment
2733
commands:
2834
- rm -Rf libre-graph-api-go/*
29-
- '/usr/local/bin/docker-entrypoint.sh generate
30-
--enable-post-process-file
31-
-i api/openapi-spec/v1.0.yaml
32-
--additional-properties=packageName=libregraph
33-
--git-user-id=opencloud-eu
34-
--git-repo-id=libre-graph-api-go
35-
-g go
36-
-o libre-graph-api-go
37-
--api-name-suffix Api'
35+
- sh scripts/generate-go.sh
3836
- cp LICENSE libre-graph-api-go/LICENSE
3937
diff:
4038
image: *alpine_image

.woodpecker/build-php.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
variables:
33
- &alpine_image 'owncloudci/alpine:latest'
4+
- &node_image 'node:22-alpine'
45
- &generator_image 'openapitools/openapi-generator-cli:v7.13.0@sha256:52b4b2bb6129b086b0f12614e98c884d378a84349fa114b07e20515702a793c5'
56
- &environment
67
HTTP_PROXY:
@@ -21,20 +22,17 @@ steps:
2122
ref: HEAD
2223
path: libre-graph-api-php
2324
remote: https://github.com/opencloud-eu/libre-graph-api-php.git
25+
compile-spec:
26+
image: *node_image
27+
environment: *environment
28+
commands:
29+
- sh scripts/compile-spec.sh
2430
generate-php:
2531
image: *generator_image
2632
environment: *environment
2733
commands:
2834
- rm -Rf libre-graph-api-php/*
29-
- '/usr/local/bin/docker-entrypoint.sh generate
30-
--enable-post-process-file
31-
-i api/openapi-spec/v1.0.yaml
32-
--additional-properties=packageName=libregraph
33-
--git-user-id=opencloud-eu
34-
--git-repo-id=libre-graph-api-php
35-
-g php-nextgen
36-
-t templates/php-nextgen
37-
-o libre-graph-api-php'
35+
- sh scripts/generate-php.sh
3836
- cp LICENSE libre-graph-api-php/LICENSE
3937
diff:
4038
image: *alpine_image

.woodpecker/build-typescript-axios.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
variables:
33
- &alpine_image 'owncloudci/alpine:latest'
4+
- &node_image 'node:22-alpine'
45
- &generator_image 'openapitools/openapi-generator-cli:v7.13.0@sha256:52b4b2bb6129b086b0f12614e98c884d378a84349fa114b07e20515702a793c5'
56
- &environment
67
HTTP_PROXY:
@@ -21,20 +22,17 @@ steps:
2122
ref: HEAD
2223
path: libre-graph-api-typescript-axios
2324
remote: https://github.com/opencloud-eu/libre-graph-api-typescript-axios.git
25+
compile-spec:
26+
image: *node_image
27+
environment: *environment
28+
commands:
29+
- sh scripts/compile-spec.sh
2430
generate-typescript-axios:
2531
image: *generator_image
2632
environment: *environment
2733
commands:
2834
- rm -Rf libre-graph-api-typescript-axios/*
29-
- '/usr/local/bin/docker-entrypoint.sh generate
30-
--enable-post-process-file
31-
-i api/openapi-spec/v1.0.yaml
32-
--additional-properties=packageName=libregraph
33-
--git-user-id=opencloud-eu
34-
--git-repo-id=libre-graph-api-typescript-axios
35-
-g typescript-axios
36-
-o libre-graph-api-typescript-axios
37-
--api-name-suffix Api'
35+
- sh scripts/generate-typescript-axios.sh
3836
- cp LICENSE libre-graph-api-typescript-axios/LICENSE
3937
diff:
4038
image: *alpine_image

.woodpecker/docs.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
---
2+
variables:
3+
- &node_image 'node:22-alpine'
4+
25
when:
36
- event: push
47
branch: ${CI_REPO_DEFAULT_BRANCH}
58
- event: [ manual, tag]
69

710
steps:
11+
- name: compile-spec
12+
image: *node_image
13+
commands:
14+
- sh scripts/compile-spec.sh
815
- name: deploy-staging
916
image: debian:latest
1017
environment:
@@ -22,7 +29,7 @@ steps:
2229
- ssh-keyscan -t rsa $REMOTE_HOST >> $HOME/.ssh/known_hosts
2330
- echo "$SSH_KEY" > "$HOME/.ssh/id_rsa"
2431
- chmod 0600 $HOME/.ssh/id_rsa
25-
- rsync -a --exclude '.git' --delete . $REMOTE_HOST:/var/swagger/libre-graph-api
32+
- rsync -a --exclude '.git' --exclude 'spec/node_modules' --exclude 'spec/build' --exclude 'build' --delete . $REMOTE_HOST:/var/swagger/libre-graph-api
2633
- name: deploy-production
2734
image: debian:latest
2835
environment:
@@ -39,4 +46,4 @@ steps:
3946
- ssh-keyscan -t rsa $REMOTE_HOST >> $HOME/.ssh/known_hosts
4047
- echo "$SSH_KEY" > "$HOME/.ssh/id_rsa"
4148
- chmod 0600 $HOME/.ssh/id_rsa
42-
- rsync -a --exclude '.git' --delete . woodpeckersyncer@$REMOTE_HOST:/var/swagger/libre-graph-api
49+
- rsync -a --exclude '.git' --exclude 'spec/node_modules' --exclude 'spec/build' --exclude 'build' --delete . woodpeckersyncer@$REMOTE_HOST:/var/swagger/libre-graph-api

Makefile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# libre-graph-api local build entry points.
2+
#
3+
# `make` (or `make spec`) compiles the TypeSpec sources under spec/ into
4+
# api/openapi-spec/v1.0.yaml. Per-language client generation targets pull the
5+
# matching openapi-generator-cli image straight out of the woodpecker pipeline
6+
# file for that language, so renovatebot remains the single source of truth
7+
# for the generator version.
8+
9+
SPEC := api/openapi-spec/v1.0.yaml
10+
SPEC_SOURCES := $(wildcard spec/*.tsp) spec/tspconfig.yaml spec/package.json spec/package-lock.json
11+
NODE_IMAGE := node:22-alpine
12+
13+
# Extract `openapitools/openapi-generator-cli:<tag>@sha256:<digest>` from the
14+
# .woodpecker pipeline file for the given language.
15+
# $(call generator_image,go)
16+
# $(call generator_image,typescript-axios)
17+
generator_image = $(shell grep -oE "openapitools/openapi-generator-cli:[A-Za-z0-9._@:-]+" .woodpecker/build-$(1).yaml | head -n1)
18+
19+
DOCKER_RUN = docker run --rm \
20+
--user $(shell id -u):$(shell id -g) \
21+
-v "$(CURDIR):/work" \
22+
-w /work
23+
24+
.PHONY: all spec go typescript-axios php cpp-qt-client clean help
25+
26+
all: spec
27+
28+
help: ## Show this help
29+
@echo "Common commands:"
30+
@echo ""
31+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
32+
33+
spec: $(SPEC) ## Compile TypeSpec sources into api/openapi-spec/v1.0.yaml
34+
35+
$(SPEC): $(SPEC_SOURCES)
36+
$(DOCKER_RUN) -e HOME=/tmp -e npm_config_cache=/tmp/.npm $(NODE_IMAGE) sh scripts/compile-spec.sh
37+
38+
go: $(SPEC) ## Generate the Go client into build/clients/go
39+
$(DOCKER_RUN) -e OUTPUT_DIR=build/clients/go $(call generator_image,go) sh scripts/generate-go.sh
40+
41+
typescript-axios: $(SPEC) ## Generate the TypeScript-Axios client into build/clients/typescript-axios
42+
$(DOCKER_RUN) -e OUTPUT_DIR=build/clients/typescript-axios $(call generator_image,typescript-axios) sh scripts/generate-typescript-axios.sh
43+
44+
php: $(SPEC) ## Generate the PHP client into build/clients/php
45+
$(DOCKER_RUN) -e OUTPUT_DIR=build/clients/php $(call generator_image,php) sh scripts/generate-php.sh
46+
47+
cpp-qt-client: $(SPEC) ## Generate the C++/Qt client into build/clients/cpp-qt-client
48+
$(DOCKER_RUN) -e OUTPUT_DIR=build/clients/cpp-qt-client $(call generator_image,cpp-qt) sh scripts/generate-cpp-qt-client.sh
49+
50+
clean: ## Remove build artefacts and the generated spec
51+
rm -rf build/ spec/build/ $(SPEC)

0 commit comments

Comments
 (0)