Skip to content

Commit d7937f5

Browse files
wing328roydekleijn
andauthored
Add typescript-wright client generator (#19038)
* add typescript-wright generator * add api, model tests * Typescript playwright (#25282) * adding openapi to playwright typescript support * fixes * [typescript-playwright] address PR review feedback - runtime: resolve BASE_PATH from the BASE_URL env var at runtime so the target server can actually be overridden (previously ignored) - runtime/apis: build form and multipart bodies from a FormData so collectionFormat=multi array fields emit one repeated field per element; file parts are appended as Blobs and object parts as application/json (via a JSONPart wrapper) instead of untyped text - runtime: JSON-encode bare-primitive request bodies when the Content-Type is JSON (Playwright otherwise sends the string verbatim) - generated specs: escape operation summaries and enum example values so titles containing apostrophes/backslashes/newlines produce valid TypeScript - package.json: only emit "private": true when no npmRepository is set, and require TypeScript >= 4.7 to match the ES2021 compile target - README: correct layout note (one describe block per API, one test per operation) - regenerate petstore sample * [CI] fix invalid samples-r workflow `working-directory` is only valid on `run` steps; on the setup-r-dependencies action it must be passed as a `with` input. This fixes the "Unexpected value 'working-directory'" parse error that marks the workflow invalid on every PR. * [CI] add typescript-playwright client sample workflow * remove accidentally committed effective-pom.xml * [CI] run typescript-playwright tests against echo server * [CI] wait for echo server readiness before running playwright tests * remove invalid code * update samples, docs --------- Co-authored-by: Roy de Kleijn <dekleijn.roy@gmail.com>
1 parent 31c062f commit d7937f5

60 files changed

Lines changed: 5410 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/samples-r.yaml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ jobs:
5252

5353
- uses: r-lib/actions/setup-r-dependencies@v2
5454
with:
55+
cache-version: 2
56+
working-directory: ${{ matrix.sample }}
57+
58+
- name: Install curl
59+
run: sudo apt-get install -y r-cran-curl
60+
61+
- name: build and test
5562
working-directory: ${{ matrix.sample }}
5663
extra-packages: any::rcmdcheck
5764
needs: check
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Samples TypeScript Playwright Client
2+
3+
on:
4+
push:
5+
paths:
6+
- samples/client/petstore/typescript-playwright/**
7+
- .github/workflows/samples-typescript-playwright.yaml
8+
pull_request:
9+
paths:
10+
- samples/client/petstore/typescript-playwright/**
11+
- .github/workflows/samples-typescript-playwright.yaml
12+
jobs:
13+
build:
14+
name: Build TypeScript Playwright client
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
node:
20+
- "18.x"
21+
- "20.x"
22+
- "22.x"
23+
sample:
24+
- samples/client/petstore/typescript-playwright/
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Use Node.js ${{ matrix.node }}
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: ${{ matrix.node }}
31+
- name: Run echo server
32+
# The generated tests issue real HTTP requests and assert on the response
33+
# status. Point them at wing328's echo server (which answers 200 to any
34+
# request) so the Playwright client is exercised at runtime, deterministically.
35+
run: |
36+
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
37+
cd http-echo-server
38+
git checkout 15a684c41d4de692878636f47fcc1670af309a0f
39+
npm install
40+
# Background only the server itself; it keeps running for later steps.
41+
npm start &
42+
# Wait until it is actually listening before moving on, so the test
43+
# step never races server startup.
44+
for i in $(seq 1 30); do
45+
if curl --fail --silent http://localhost:3000 >/dev/null; then
46+
echo "Echo server is ready"
47+
exit 0
48+
fi
49+
sleep 1
50+
done
51+
echo "Echo server did not become ready" >&2
52+
exit 1
53+
- name: npm install
54+
working-directory: ${{ matrix.sample }}
55+
run: npm install
56+
- name: Type-check generated client and tests
57+
working-directory: ${{ matrix.sample }}
58+
run: npm run typecheck
59+
- name: Test
60+
working-directory: ${{ matrix.sample }}
61+
env:
62+
BASE_URL: http://localhost:3000
63+
run: npm test
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
generatorName: typescript-playwright
2+
outputDir: samples/client/petstore/typescript-playwright
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/typescript-playwright

‎docs/generators.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ The following generators are available:
8282
* [typescript-jquery](generators/typescript-jquery.md)
8383
* [typescript-nestjs (experimental)](generators/typescript-nestjs.md)
8484
* [typescript-node](generators/typescript-node.md)
85+
* [typescript-playwright](generators/typescript-playwright.md)
8586
* [typescript-redux-query](generators/typescript-redux-query.md)
8687
* [typescript-rxjs](generators/typescript-rxjs.md)
8788
* [xojo-client](generators/xojo-client.md)

0 commit comments

Comments
 (0)