From cac1f242dce33a2be03e6f9817f23234cf5d1ef6 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 16 May 2021 14:13:07 +0200 Subject: [PATCH] *: replace swagger with openapi Signed-off-by: Jens Langhammer --- .github/workflows/release.yml | 6 +++--- .github/workflows/tag.yml | 2 +- Makefile | 2 +- authentik/api/views.py | 5 +---- authentik/root/settings.py | 1 + azure-pipelines.yml | 4 ++-- outpost/Makefile | 2 +- outpost/azure-pipelines.yml | 2 +- web/azure-pipelines.yml | 2 +- website/developer-docs/local-dev-environment.md | 2 +- website/src/pages/api.jsx | 2 +- website/static/schema.yaml | 1 + 12 files changed, 15 insertions(+), 16 deletions(-) create mode 120000 website/static/schema.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7eb016d5e..c4e444916 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,7 +30,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: prepare ts api client run: | - docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli generate -i /local/swagger.yaml -g typescript-fetch -o /local/web/api --additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=authentik-api,npmVersion=1.0.0 + docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli generate -i /local/schema.yml -g typescript-fetch -o /local/web/api --additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=authentik-api,npmVersion=1.0.0 - name: Building Docker Image uses: docker/build-push-action@v2 with: @@ -53,7 +53,7 @@ jobs: run: | cd outpost go get -u github.com/go-swagger/go-swagger/cmd/swagger - swagger generate client -f ../swagger.yaml -A authentik -t pkg/ + swagger generate client -f ../schema.yml -A authentik -t pkg/ go build -v ./cmd/proxy/server.go - name: Set up QEMU uses: docker/setup-qemu-action@v1.1.0 @@ -93,7 +93,7 @@ jobs: run: | cd outpost go get -u github.com/go-swagger/go-swagger/cmd/swagger - swagger generate client -f ../swagger.yaml -A authentik -t pkg/ + swagger generate client -f ../schema.yml -A authentik -t pkg/ go build -v ./cmd/ldap/server.go - name: Set up QEMU uses: docker/setup-qemu-action@v1.1.0 diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 2f03dc694..609fea503 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v2 - name: prepare ts api client run: | - docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli generate -i /local/swagger.yaml -g typescript-fetch -o /local/web/api --additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=authentik-api,npmVersion=1.0.0 + docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli generate -i /local/schema.yml -g typescript-fetch -o /local/web/api --additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=authentik-api,npmVersion=1.0.0 - name: Pre-release test run: | sudo apt-get install -y pwgen diff --git a/Makefile b/Makefile index 5c8b41fd1..9d2a0c53b 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ lint: pylint authentik tests lifecycle gen: - ./manage.py spectacular --file schema.yaml --validate --fail-on-warn + ./manage.py spectacular --file schema.yml docker run \ --rm -v ${PWD}:/local \ openapitools/openapi-generator-cli generate \ diff --git a/authentik/api/views.py b/authentik/api/views.py index 580050ba6..736586cd7 100644 --- a/authentik/api/views.py +++ b/authentik/api/views.py @@ -13,10 +13,7 @@ class SwaggerView(TemplateView): def get_context_data(self, **kwargs: Any) -> dict[str, Any]: path = self.request.build_absolute_uri( reverse( - "authentik_api:schema-json", - kwargs={ - "format": ".json", - }, + "authentik_api:schema", ) ) return super().get_context_data(path=path, **kwargs) diff --git a/authentik/root/settings.py b/authentik/root/settings.py index 011f037af..ea24c745d 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -154,6 +154,7 @@ SPECTACULAR_SETTINGS = { "ENUM_NAME_OVERRIDES": { "ChallengeChoices": "authentik.flows.challenge.ChallengeTypes" }, + "ENUM_ADD_EXPLICIT_BLANK_NULL_CHOICE": False } REST_FRAMEWORK = { diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 971ef6db2..c72006a8a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -298,7 +298,7 @@ stages: displayName: Build static files for e2e inputs: script: | - docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli generate -i /local/swagger.yaml -g typescript-fetch -o /local/web/api --additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=authentik-api,npmVersion=1.0.0 + docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli generate -i /local/schema.yml -g typescript-fetch -o /local/web/api --additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=authentik-api,npmVersion=1.0.0 sudo chmod 777 -R web/api/ cd web cd api && npm i && cd .. @@ -399,7 +399,7 @@ stages: - task: CmdLine@2 inputs: script: | - docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli generate -i /local/swagger.yaml -g typescript-fetch -o /local/web/api --additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=authentik-api,npmVersion=1.0.0 + docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli generate -i /local/schema.yml -g typescript-fetch -o /local/web/api --additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=authentik-api,npmVersion=1.0.0 - task: PublishPipelineArtifact@1 inputs: targetPath: 'web/api/' diff --git a/outpost/Makefile b/outpost/Makefile index d4eaa5f5c..b211789e9 100644 --- a/outpost/Makefile +++ b/outpost/Makefile @@ -2,7 +2,7 @@ all: clean generate generate: go get -u github.com/go-swagger/go-swagger/cmd/swagger - swagger generate client -f ../swagger.yaml -A authentik -t pkg/ + swagger generate client -f ../schema.yml -A authentik -t pkg/ run: go run -v . diff --git a/outpost/azure-pipelines.yml b/outpost/azure-pipelines.yml index b3c39d43b..181a07926 100644 --- a/outpost/azure-pipelines.yml +++ b/outpost/azure-pipelines.yml @@ -28,7 +28,7 @@ stages: sudo wget -O /usr/local/bin/swagger https://github.com/go-swagger/go-swagger/releases/latest/download/swagger_linux_amd64 sudo chmod +x /usr/local/bin/swagger mkdir -p $(go env GOPATH) - swagger generate client -f ../swagger.yaml -A authentik -t pkg/ + swagger generate client -f ../schema.yml -A authentik -t pkg/ workingDirectory: 'outpost/' - task: PublishPipelineArtifact@1 inputs: diff --git a/web/azure-pipelines.yml b/web/azure-pipelines.yml index e7d99859b..248221ad1 100644 --- a/web/azure-pipelines.yml +++ b/web/azure-pipelines.yml @@ -20,7 +20,7 @@ stages: - task: CmdLine@2 inputs: script: | - docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli generate -i /local/swagger.yaml -g typescript-fetch -o /local/web/api --additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=authentik-api,npmVersion=1.0.0 + docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli generate -i /local/schema.yml -g typescript-fetch -o /local/web/api --additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=authentik-api,npmVersion=1.0.0 - task: PublishPipelineArtifact@1 inputs: targetPath: 'web/api/' diff --git a/website/developer-docs/local-dev-environment.md b/website/developer-docs/local-dev-environment.md index 771570e65..52ac61b17 100644 --- a/website/developer-docs/local-dev-environment.md +++ b/website/developer-docs/local-dev-environment.md @@ -44,7 +44,7 @@ If you want to generate the client without installing anything, run this command docker run \ --rm -v $(pwd):/local \ openapitools/openapi-generator-cli generate \ - -i /local/swagger.yaml \ + -i /local/schema.yml \ -g typescript-fetch \ -o /local/web/api \ --additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=authentik-api,npmVersion=1.0.0 diff --git a/website/src/pages/api.jsx b/website/src/pages/api.jsx index fb50a8548..8652c682e 100644 --- a/website/src/pages/api.jsx +++ b/website/src/pages/api.jsx @@ -10,7 +10,7 @@ function APIBrowser() { return (