Skip to content

Commit 4ecc013

Browse files
committed
feature: add v3-next client exports
1 parent 4f38f12 commit 4ecc013

15 files changed

Lines changed: 61722 additions & 9 deletions

File tree

.github/workflows/update-client-dev.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ jobs:
4040
4141
- name: Update OpenAPI ⬇️
4242
run: |
43-
yarn nx run @mittwald/api-client:build:fetch-openapi-dev
43+
yarn nx run @mittwald/api-client:build:fetch-openapi-v2-dev
44+
yarn nx run @mittwald/api-client:build:fetch-openapi-v3-next-dev
4445
if [ $(git status --porcelain . | wc -l) -gt 0 ] ; then
45-
yarn nx run @mittwald/api-client:build:client-dev
46+
yarn nx run @mittwald/api-client:build:client-v2-dev
47+
yarn nx run @mittwald/api-client:build:client-v3-next-dev
4648
git add .
4749
yarn test
4850
git commit -m "chore: update generated development client";

.github/workflows/update-client.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ jobs:
4040
- name: Update OpenAPI ⬇️
4141
if: github.ref == 'refs/heads/master'
4242
run: |
43-
yarn nx run @mittwald/api-client:build:fetch-openapi-prod
43+
yarn nx run @mittwald/api-client:build:fetch-openapi-v2-prod
44+
yarn nx run @mittwald/api-client:build:fetch-openapi-v3-next-prod
4445
if [ $(git status --porcelain . | wc -l) -gt 0 ] ; then
45-
yarn nx run @mittwald/api-client:build:client-prod
46+
yarn nx run @mittwald/api-client:build:client-v2-prod
47+
yarn nx run @mittwald/api-client:build:client-v3-next-prod
4648
git add .
4749
yarn test
4850
git commit -m "feat: update generated client";

nx.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,22 @@
1212
"cache": true,
1313
"dependsOn": ["^build"]
1414
},
15+
"build:client-v2-prod": {
16+
"cache": true,
17+
"dependsOn": ["^build"]
18+
},
19+
"build:client-v3-next-prod": {
20+
"cache": true,
21+
"dependsOn": ["^build"]
22+
},
1523
"build:client-dev": {
1624
"cache": true,
1725
"dependsOn": ["^build"]
1826
},
27+
"build:client-v2-dev": {
28+
"cache": true,
29+
"dependsOn": ["^build"]
30+
},
1931
"build:write-version-file": {
2032
"cache": true,
2133
"dependsOn": ["build"]

packages/mittwald/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ see the [LICENSE](../../LICENSE) file for details.
1414

1515
- [Installing](#installing)
1616
- [Usage](#usage)
17+
- [Using the v3-next client](#using-the-v3-next-client)
1718
- [Setting request parameters](#setting-request-parameters)
1819
- [Path parameters](#path-parameters)
1920
- [Headers, query parameters and request body](#headers-query-parameters-and-request-body)
@@ -58,6 +59,34 @@ different types of authentication:
5859
Have a look at our [API introduction][api-getting-started] for more information
5960
on how to obtain an API token and how to get started with the API.
6061

62+
### Using the v3-next client
63+
64+
The default import path exposes the v2 client. To use the production
65+
`v3-next` client, import it from the `@mittwald/api-client/v3-next` subpath:
66+
67+
```typescript
68+
import { MittwaldAPIClient } from "@mittwald/api-client/v3-next";
69+
70+
const mittwaldApi = MittwaldAPIClient.newWithToken("your-access-token");
71+
```
72+
73+
The React client is available from the matching React subpath:
74+
75+
```typescript
76+
import { MittwaldAPIClientReact } from "@mittwald/api-client/v3-next/react";
77+
```
78+
79+
TypeScript request and response types are exported through the
80+
`MittwaldAPIV3Next` namespace:
81+
82+
```typescript
83+
import { MittwaldAPIV3Next } from "@mittwald/api-client/v3-next";
84+
```
85+
86+
This uses the published, non-development `v3-next` client. The package does not
87+
expose a `@mittwald/api-client/v3-next-dev` import path; the `v3-next-dev`
88+
OpenAPI spec is only used for generating development builds.
89+
6190
### Setting request parameters
6291

6392
API requests may require these type of parameters:

packages/mittwald/package.json

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@
2525
"./react": {
2626
"types": "./dist/types/react.d.ts",
2727
"import": "./dist/esm/react.js"
28+
},
29+
"./v2": {
30+
"types": "./dist/types/v2/index.d.ts",
31+
"import": "./dist/esm/v2/index.js"
32+
},
33+
"./v2/react": {
34+
"types": "./dist/types/v2/react.d.ts",
35+
"import": "./dist/esm/v2/react.js"
36+
},
37+
"./v3-next": {
38+
"types": "./dist/types/v3-next/index.d.ts",
39+
"import": "./dist/esm/v3-next/index.js"
40+
},
41+
"./v3-next/react": {
42+
"types": "./dist/types/v3-next/react.d.ts",
43+
"import": "./dist/esm/v3-next/react.js"
2844
}
2945
},
3046
"files": [
@@ -33,11 +49,21 @@
3349
"scripts": {
3450
"build": "run build:clean && run tsc",
3551
"build:clean": "run rimraf dist",
36-
"build:client-base": "run acg generate --name MittwaldAPIV2 /dev/stdin src/generated/v2 --optionalHeader x-access-token",
37-
"build:client-dev": "bash -e -o pipefail -c 'spec/transform-openapi.sh < spec/openapi-dev.json | run build:client-base'",
38-
"build:client-prod": "bash -e -o pipefail -c 'spec/transform-openapi.sh < spec/openapi.json | run build:client-base'",
39-
"build:fetch-openapi-dev": "curl --location --fail --silent https://developer.mittwald.de/specs/openapi-v2-dev.json > spec/openapi-dev.json",
40-
"build:fetch-openapi-prod": "curl --location --fail --silent 'https://api.mittwald.de/v2/openapi.json?withExperimental=true' > spec/openapi.json",
52+
"build:client-base": "run build:client-v2-base",
53+
"build:client-dev": "run build:client-v2-dev && run build:client-v3-next-dev",
54+
"build:client-prod": "run build:client-v2-prod && run build:client-v3-next-prod",
55+
"build:client-v2-base": "run acg generate --name MittwaldAPIV2 /dev/stdin src/generated/v2 --optionalHeader x-access-token",
56+
"build:client-v2-dev": "bash -e -o pipefail -c 'spec/transform-openapi.sh < spec/openapi-dev.json | run build:client-v2-base'",
57+
"build:client-v2-prod": "bash -e -o pipefail -c 'spec/transform-openapi.sh < spec/openapi.json | run build:client-v2-base'",
58+
"build:client-v3-next-base": "run acg generate --name MittwaldAPIV3Next /dev/stdin src/generated/v3-next --optionalHeader x-access-token",
59+
"build:client-v3-next-dev": "bash -e -o pipefail -c 'spec/transform-openapi.sh < spec/openapi-v3-next-dev.json | run build:client-v3-next-base'",
60+
"build:client-v3-next-prod": "bash -e -o pipefail -c 'spec/transform-openapi.sh < spec/openapi-v3-next.json | run build:client-v3-next-base'",
61+
"build:fetch-openapi-dev": "run build:fetch-openapi-v2-dev && run build:fetch-openapi-v3-next-dev",
62+
"build:fetch-openapi-prod": "run build:fetch-openapi-v2-prod && run build:fetch-openapi-v3-next-prod",
63+
"build:fetch-openapi-v2-dev": "curl --location --fail --silent https://developer.mittwald.de/specs/openapi-v2-dev.json > spec/openapi-dev.json",
64+
"build:fetch-openapi-v2-prod": "curl --location --fail --silent 'https://api.mittwald.de/v2/openapi.json?withExperimental=true' > spec/openapi.json",
65+
"build:fetch-openapi-v3-next-dev": "curl --location --fail --silent https://developer.mittwald.de/specs/openapi-v3-next-dev.json > spec/openapi-v3-next-dev.json",
66+
"build:fetch-openapi-v3-next-prod": "curl --location --fail --silent 'https://api.mittwald.de/v3-next/openapi.json?withExperimental=true' > spec/openapi-v3-next.json",
4167
"build:write-version-file": "run tsx dev/writeVersion.ts",
4268
"format": "run prettier --write '**/*.{ts,tsx,yaml,yml,json,md,mdx,js}'",
4369
"lint": "run eslint .",

packages/mittwald/spec/openapi-v3-next-dev.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

packages/mittwald/spec/openapi-v3-next.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)