mirror of
https://github.com/goauthentik/authentik
synced 2026-05-03 12:52:17 +02:00
root: move API client generation to docker-compose (#17434)
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
committed by
GitHub
parent
296b348bd2
commit
d91dcf4eef
15
scripts/api/docker-compose.yml
Normal file
15
scripts/api/docker-compose.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
services:
|
||||
diff:
|
||||
image: docker.io/openapitools/openapi-diff:2.1.3
|
||||
restart: never
|
||||
network_mode: none
|
||||
volumes:
|
||||
- ../../:/local
|
||||
|
||||
gen:
|
||||
image: docker.io/openapitools/openapi-generator-cli:v7.16.0
|
||||
restart: never
|
||||
network_mode: none
|
||||
volumes:
|
||||
- ../../:/local
|
||||
12
scripts/api/ts-config.yaml
Normal file
12
scripts/api/ts-config.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
templateDir: /local/scripts/api/ts-templates/
|
||||
additionalProperties:
|
||||
typescriptThreePlus: true
|
||||
supportsES6: true
|
||||
npmName: "@goauthentik/api"
|
||||
fileContentDataType: Blob
|
||||
enumUnknownDefaultCase: true
|
||||
useObjectParameters: true
|
||||
files:
|
||||
README.mustache:
|
||||
templateType: SupportingFiles
|
||||
destinationFilename: README.md
|
||||
38
scripts/api/ts-templates/README.mustache
Normal file
38
scripts/api/ts-templates/README.mustache
Normal file
@@ -0,0 +1,38 @@
|
||||
## @goauthentik/api
|
||||
|
||||
This package provides a generated API Client for [authentik](https://goauthentik.io?utm_source=npm-api-package).
|
||||
|
||||
### Building
|
||||
|
||||
See https://docs.goauthentik.io/docs/developer-docs/api/making-schema-changes#building-the-web-client
|
||||
|
||||
### Consuming
|
||||
|
||||
```
|
||||
npm install @goauthentik/api --save
|
||||
```
|
||||
|
||||
Create a configuration:
|
||||
|
||||
```typescript
|
||||
import { Configuration } from "@goauthentik/api";
|
||||
|
||||
export const DEFAULT_CONFIG = new Configuration({
|
||||
// Configure where the API is located
|
||||
// Can be a full host, ensure CORS is configured
|
||||
basePath: "",
|
||||
// Required for POST/PUT/DELETE requests
|
||||
// getCookie function must return the cookie's contents
|
||||
headers: {
|
||||
"X-authentik-CSRF": getCookie("authentik_csrf"),
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Then use the API:
|
||||
|
||||
```typescript
|
||||
import { CoreApi } from "@goauthentik/api";
|
||||
|
||||
const user = await new CoreApi(DEFAULT_CONFIG).coreUsersMeRetrieve();
|
||||
```
|
||||
7
scripts/api/ts-templates/tsconfig.esm.mustache
Normal file
7
scripts/api/ts-templates/tsconfig.esm.mustache
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist/esm",
|
||||
},
|
||||
}
|
||||
23
scripts/api/ts-templates/tsconfig.mustache
Normal file
23
scripts/api/ts-templates/tsconfig.mustache
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"isolatedModules": true,
|
||||
"incremental": true,
|
||||
"baseUrl": ".",
|
||||
"rootDir": "src",
|
||||
"strict": true,
|
||||
"newLine": "lf",
|
||||
"target": "ESNext",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"outDir": "dist",
|
||||
"skipDefaultLibCheck": true,
|
||||
"skipLibCheck": true,
|
||||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
||||
},
|
||||
"exclude": ["node_modules", "./out/**/*", "./dist/**/*"],
|
||||
}
|
||||
Reference in New Issue
Block a user