*: replace swagger with openapi

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-05-16 14:13:07 +02:00
parent 0bac738090
commit cac1f242dc
12 changed files with 15 additions and 16 deletions

View File

@ -30,7 +30,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: prepare ts api client - name: prepare ts api client
run: | 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 - name: Building Docker Image
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
@ -53,7 +53,7 @@ jobs:
run: | run: |
cd outpost cd outpost
go get -u github.com/go-swagger/go-swagger/cmd/swagger 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 go build -v ./cmd/proxy/server.go
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1.1.0 uses: docker/setup-qemu-action@v1.1.0
@ -93,7 +93,7 @@ jobs:
run: | run: |
cd outpost cd outpost
go get -u github.com/go-swagger/go-swagger/cmd/swagger 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 go build -v ./cmd/ldap/server.go
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1.1.0 uses: docker/setup-qemu-action@v1.1.0

View File

@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: prepare ts api client - name: prepare ts api client
run: | 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 - name: Pre-release test
run: | run: |
sudo apt-get install -y pwgen sudo apt-get install -y pwgen

View File

@ -26,7 +26,7 @@ lint:
pylint authentik tests lifecycle pylint authentik tests lifecycle
gen: gen:
./manage.py spectacular --file schema.yaml --validate --fail-on-warn ./manage.py spectacular --file schema.yml
docker run \ docker run \
--rm -v ${PWD}:/local \ --rm -v ${PWD}:/local \
openapitools/openapi-generator-cli generate \ openapitools/openapi-generator-cli generate \

View File

@ -13,10 +13,7 @@ class SwaggerView(TemplateView):
def get_context_data(self, **kwargs: Any) -> dict[str, Any]: def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
path = self.request.build_absolute_uri( path = self.request.build_absolute_uri(
reverse( reverse(
"authentik_api:schema-json", "authentik_api:schema",
kwargs={
"format": ".json",
},
) )
) )
return super().get_context_data(path=path, **kwargs) return super().get_context_data(path=path, **kwargs)

View File

@ -154,6 +154,7 @@ SPECTACULAR_SETTINGS = {
"ENUM_NAME_OVERRIDES": { "ENUM_NAME_OVERRIDES": {
"ChallengeChoices": "authentik.flows.challenge.ChallengeTypes" "ChallengeChoices": "authentik.flows.challenge.ChallengeTypes"
}, },
"ENUM_ADD_EXPLICIT_BLANK_NULL_CHOICE": False
} }
REST_FRAMEWORK = { REST_FRAMEWORK = {

View File

@ -298,7 +298,7 @@ stages:
displayName: Build static files for e2e displayName: Build static files for e2e
inputs: inputs:
script: | 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/ sudo chmod 777 -R web/api/
cd web cd web
cd api && npm i && cd .. cd api && npm i && cd ..
@ -399,7 +399,7 @@ stages:
- task: CmdLine@2 - task: CmdLine@2
inputs: inputs:
script: | 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 - task: PublishPipelineArtifact@1
inputs: inputs:
targetPath: 'web/api/' targetPath: 'web/api/'

View File

@ -2,7 +2,7 @@ all: clean generate
generate: generate:
go get -u github.com/go-swagger/go-swagger/cmd/swagger 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: run:
go run -v . go run -v .

View File

@ -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 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 sudo chmod +x /usr/local/bin/swagger
mkdir -p $(go env GOPATH) 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/' workingDirectory: 'outpost/'
- task: PublishPipelineArtifact@1 - task: PublishPipelineArtifact@1
inputs: inputs:

View File

@ -20,7 +20,7 @@ stages:
- task: CmdLine@2 - task: CmdLine@2
inputs: inputs:
script: | 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 - task: PublishPipelineArtifact@1
inputs: inputs:
targetPath: 'web/api/' targetPath: 'web/api/'

View File

@ -44,7 +44,7 @@ If you want to generate the client without installing anything, run this command
docker run \ docker run \
--rm -v $(pwd):/local \ --rm -v $(pwd):/local \
openapitools/openapi-generator-cli generate \ openapitools/openapi-generator-cli generate \
-i /local/swagger.yaml \ -i /local/schema.yml \
-g typescript-fetch \ -g typescript-fetch \
-o /local/web/api \ -o /local/web/api \
--additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=authentik-api,npmVersion=1.0.0 --additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=authentik-api,npmVersion=1.0.0

View File

@ -10,7 +10,7 @@ function APIBrowser() {
return ( return (
<Layout title="API Browser" description={siteConfig.tagline}> <Layout title="API Browser" description={siteConfig.tagline}>
<rapi-doc <rapi-doc
spec-url={useBaseUrl("swagger.yaml")} spec-url={useBaseUrl("schema.yml")}
allow-try="false" allow-try="false"
show-header="false" show-header="false"
theme="dark" theme="dark"

1
website/static/schema.yaml Symbolic link
View File

@ -0,0 +1 @@
../../schema.yml