api: fix schema not referencing errors correctly
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
8b4a7666f0
commit
0ff2ac7dc2
|
@ -139,7 +139,7 @@ jobs:
|
||||||
working-directory: web
|
working-directory: web
|
||||||
run: |
|
run: |
|
||||||
npm ci
|
npm ci
|
||||||
make -C .. gen-client-web
|
make -C .. gen-client-ts
|
||||||
npm run build
|
npm run build
|
||||||
- name: run e2e
|
- name: run e2e
|
||||||
run: |
|
run: |
|
||||||
|
@ -173,7 +173,7 @@ jobs:
|
||||||
working-directory: web/
|
working-directory: web/
|
||||||
run: |
|
run: |
|
||||||
npm ci
|
npm ci
|
||||||
make -C .. gen-client-web
|
make -C .. gen-client-ts
|
||||||
npm run build
|
npm run build
|
||||||
- name: run e2e
|
- name: run e2e
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -23,7 +23,7 @@ jobs:
|
||||||
- working-directory: web/
|
- working-directory: web/
|
||||||
run: npm ci
|
run: npm ci
|
||||||
- name: Generate API
|
- name: Generate API
|
||||||
run: make gen-client-web
|
run: make gen-client-ts
|
||||||
- name: Eslint
|
- name: Eslint
|
||||||
working-directory: web/
|
working-directory: web/
|
||||||
run: npm run lint
|
run: npm run lint
|
||||||
|
@ -39,7 +39,7 @@ jobs:
|
||||||
- working-directory: web/
|
- working-directory: web/
|
||||||
run: npm ci
|
run: npm ci
|
||||||
- name: Generate API
|
- name: Generate API
|
||||||
run: make gen-client-web
|
run: make gen-client-ts
|
||||||
- name: prettier
|
- name: prettier
|
||||||
working-directory: web/
|
working-directory: web/
|
||||||
run: npm run prettier-check
|
run: npm run prettier-check
|
||||||
|
@ -60,7 +60,7 @@ jobs:
|
||||||
cd node_modules/@goauthentik
|
cd node_modules/@goauthentik
|
||||||
ln -s ../../src/ web
|
ln -s ../../src/ web
|
||||||
- name: Generate API
|
- name: Generate API
|
||||||
run: make gen-client-web
|
run: make gen-client-ts
|
||||||
- name: lit-analyse
|
- name: lit-analyse
|
||||||
working-directory: web/
|
working-directory: web/
|
||||||
run: npm run lit-analyse
|
run: npm run lit-analyse
|
||||||
|
@ -86,7 +86,7 @@ jobs:
|
||||||
- working-directory: web/
|
- working-directory: web/
|
||||||
run: npm ci
|
run: npm ci
|
||||||
- name: Generate API
|
- name: Generate API
|
||||||
run: make gen-client-web
|
run: make gen-client-ts
|
||||||
- name: build
|
- name: build
|
||||||
working-directory: web/
|
working-directory: web/
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
|
@ -16,7 +16,7 @@ jobs:
|
||||||
node-version: '16'
|
node-version: '16'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
- name: Generate API Client
|
- name: Generate API Client
|
||||||
run: make gen-client-web
|
run: make gen-client-ts
|
||||||
- name: Publish package
|
- name: Publish package
|
||||||
working-directory: gen-ts-api/
|
working-directory: gen-ts-api/
|
||||||
run: |
|
run: |
|
||||||
|
|
34
Makefile
34
Makefile
|
@ -49,24 +49,44 @@ lint:
|
||||||
bandit -r authentik tests lifecycle -x node_modules
|
bandit -r authentik tests lifecycle -x node_modules
|
||||||
golangci-lint run -v
|
golangci-lint run -v
|
||||||
|
|
||||||
|
migrate:
|
||||||
|
python -m lifecycle.migrate
|
||||||
|
|
||||||
|
run:
|
||||||
|
go run -v cmd/server/main.go
|
||||||
|
|
||||||
i18n-extract: i18n-extract-core web-extract
|
i18n-extract: i18n-extract-core web-extract
|
||||||
|
|
||||||
i18n-extract-core:
|
i18n-extract-core:
|
||||||
ak makemessages --ignore web --ignore internal --ignore web --ignore web-api --ignore website -l en
|
ak makemessages --ignore web --ignore internal --ignore web --ignore web-api --ignore website -l en
|
||||||
|
|
||||||
|
#########################
|
||||||
|
## API Schema
|
||||||
|
#########################
|
||||||
|
|
||||||
gen-build:
|
gen-build:
|
||||||
AUTHENTIK_DEBUG=true ak make_blueprint_schema > blueprints/schema.json
|
AUTHENTIK_DEBUG=true ak make_blueprint_schema > blueprints/schema.json
|
||||||
AUTHENTIK_DEBUG=true ak spectacular --file schema.yml
|
AUTHENTIK_DEBUG=true ak spectacular --file schema.yml
|
||||||
|
|
||||||
|
gen-diff:
|
||||||
|
git show $(shell git tag -l | tail -n 1):schema.yml > old_schema.yml
|
||||||
|
docker run \
|
||||||
|
--rm -v ${PWD}:/local \
|
||||||
|
--user ${UID}:${GID} \
|
||||||
|
docker.io/openapitools/openapi-diff:2.0.1 \
|
||||||
|
--markdown /local/diff.md \
|
||||||
|
/local/old_schema.yml /local/schema.yml
|
||||||
|
rm old_schema.yml
|
||||||
|
|
||||||
gen-clean:
|
gen-clean:
|
||||||
rm -rf web/api/src/
|
rm -rf web/api/src/
|
||||||
rm -rf api/
|
rm -rf api/
|
||||||
|
|
||||||
gen-client-web:
|
gen-client-ts:
|
||||||
docker run \
|
docker run \
|
||||||
--rm -v ${PWD}:/local \
|
--rm -v ${PWD}:/local \
|
||||||
--user ${UID}:${GID} \
|
--user ${UID}:${GID} \
|
||||||
openapitools/openapi-generator-cli:v6.0.0 generate \
|
docker.io/openapitools/openapi-generator-cli:v6.0.0 generate \
|
||||||
-i /local/schema.yml \
|
-i /local/schema.yml \
|
||||||
-g typescript-fetch \
|
-g typescript-fetch \
|
||||||
-o /local/gen-ts-api \
|
-o /local/gen-ts-api \
|
||||||
|
@ -84,7 +104,7 @@ gen-client-go:
|
||||||
docker run \
|
docker run \
|
||||||
--rm -v ${PWD}:/local \
|
--rm -v ${PWD}:/local \
|
||||||
--user ${UID}:${GID} \
|
--user ${UID}:${GID} \
|
||||||
openapitools/openapi-generator-cli:v6.0.0 generate \
|
docker.io/openapitools/openapi-generator-cli:v6.0.0 generate \
|
||||||
-i /local/schema.yml \
|
-i /local/schema.yml \
|
||||||
-g go \
|
-g go \
|
||||||
-o /local/gen-go-api \
|
-o /local/gen-go-api \
|
||||||
|
@ -95,13 +115,7 @@ gen-client-go:
|
||||||
gen-dev-config:
|
gen-dev-config:
|
||||||
python -m scripts.generate_config
|
python -m scripts.generate_config
|
||||||
|
|
||||||
gen: gen-build gen-clean gen-client-web
|
gen: gen-build gen-clean gen-client-ts
|
||||||
|
|
||||||
migrate:
|
|
||||||
python -m lifecycle.migrate
|
|
||||||
|
|
||||||
run:
|
|
||||||
go run -v cmd/server/main.go
|
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
## Web
|
## Web
|
||||||
|
|
|
@ -18,13 +18,13 @@ class AppSerializer(PassiveSerializer):
|
||||||
|
|
||||||
|
|
||||||
class AppsViewSet(ViewSet):
|
class AppsViewSet(ViewSet):
|
||||||
"""Read-only view set list all installed apps"""
|
"""Read-only view list all installed apps"""
|
||||||
|
|
||||||
permission_classes = [IsAdminUser]
|
permission_classes = [IsAdminUser]
|
||||||
|
|
||||||
@extend_schema(responses={200: AppSerializer(many=True)})
|
@extend_schema(responses={200: AppSerializer(many=True)})
|
||||||
def list(self, request: Request) -> Response:
|
def list(self, request: Request) -> Response:
|
||||||
"""List current messages and pass into Serializer"""
|
"""Read-only view list all installed apps"""
|
||||||
data = []
|
data = []
|
||||||
for app in sorted(get_apps(), key=lambda app: app.name):
|
for app in sorted(get_apps(), key=lambda app: app.name):
|
||||||
data.append({"name": app.name, "label": app.verbose_name})
|
data.append({"name": app.name, "label": app.verbose_name})
|
||||||
|
|
|
@ -60,8 +60,28 @@ def postprocess_schema_responses(result, generator, **kwargs): # noqa: W0613
|
||||||
|
|
||||||
for path in result["paths"].values():
|
for path in result["paths"].values():
|
||||||
for method in path.values():
|
for method in path.values():
|
||||||
method["responses"].setdefault("400", validation_error.ref)
|
method["responses"].setdefault(
|
||||||
method["responses"].setdefault("403", generic_error.ref)
|
"400",
|
||||||
|
{
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": validation_error.ref,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
method["responses"].setdefault(
|
||||||
|
"403",
|
||||||
|
{
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": generic_error.ref,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
result["components"] = generator.registry.build(spectacular_settings.APPEND_COMPONENTS)
|
result["components"] = generator.registry.build(spectacular_settings.APPEND_COMPONENTS)
|
||||||
|
|
||||||
|
|
7058
schema.yml
7058
schema.yml
File diff suppressed because it is too large
Load Diff
|
@ -14,10 +14,10 @@ The generated files are stored in `/api` in the root of the repository.
|
||||||
|
|
||||||
## Building the Web Client
|
## Building the Web Client
|
||||||
|
|
||||||
The web client is used by the web-interface and web-FlowExecutor to communicate with authentik. To build the client, run `make gen-client-web`.
|
The web client is used by the web-interface and web-FlowExecutor to communicate with authentik. To build the client, run `make gen-client-ts`.
|
||||||
|
|
||||||
Since the client is normally distributed as an npm package, running `make gen-client-web` will overwrite the locally installed client with the newly built one.
|
Since the client is normally distributed as an npm package, running `make gen-client-ts` will overwrite the locally installed client with the newly built one.
|
||||||
|
|
||||||
:::warning
|
:::warning
|
||||||
Running `npm i` in the `/web` folder after using `make gen-client-web` will overwrite the custom client and revert to the upstream client.
|
Running `npm i` in the `/web` folder after using `make gen-client-ts` will overwrite the custom client and revert to the upstream client.
|
||||||
:::
|
:::
|
||||||
|
|
Reference in New Issue