Skip to content

Commit 390aa4f

Browse files
committed
change linter and add openai tests
1 parent c0e530d commit 390aa4f

File tree

18 files changed

+4918
-236
lines changed

18 files changed

+4918
-236
lines changed

.eslintrc.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/assets/logo.webp

315 KB
Binary file not shown.

.github/workflows/test.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
name: Tests
22
on:
33
push:
4-
branches: [ main ]
4+
branches: [main]
55
pull_request:
6-
branches: [ main ]
6+
branches: [main]
77
jobs:
88
test:
99
timeout-minutes: 60
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v4
13-
- uses: actions/setup-node@v4
14-
with:
15-
node-version: '20.x'
16-
- name: Install dependencies
17-
run: npm install
18-
- name: Run tests
19-
run: npm test
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: 20.x
16+
- name: Install dependencies
17+
run: npm install
18+
- name: Run tests
19+
run: npm test

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
3+
}

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
![Types for your OpenAPI](.github/assets/logo.webp 'Types for your OpenAPI')
2+
13
# openapi-box
24
Generate [TypeBox](https://github.com/sinclairzx81/typebox) types from OpenApi `V3` IDL + End-to-end typesafe HTTP client library.
35

46
> It works for TypeScript and JavaScript.
57
68
![Tests](https://github.com/geut/openapi-box/actions/workflows/test.yml/badge.svg)
7-
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat)](https://standardjs.com)
9+
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard--ext-05ae89.svg)](https://github.com/tinchoz49/eslint-config-standard-ext)
810
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat)](https://github.com/RichardLitt/standard-readme)
911

1012
[![Made by GEUT][geut-badge]][geut-url]
@@ -17,16 +19,15 @@ $ npm install @geut/openapi-box @sinclair/typebox
1719

1820
## Usage
1921

20-
2122
1. Generate the schema from an OpenApi url (it can a be filepath too):
2223
```bash
2324
$ openapi-box https://petstore3.swagger.io/api/v3/openapi.json
2425
```
2526

2627
2. Load your schemas into the End-to-end typesafe `fetch` client:
2728
```js
28-
import { createClient } from './src/client.js'
2929
import { schema } from './schema.js'
30+
import { createClient } from './src/client.js'
3031

3132
const client = createClient({
3233
schema,

bin/cli.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env node
2-
import { writeFile } from 'fs/promises'
3-
import ora from 'ora'
2+
import { writeFile } from 'node:fs/promises'
3+
44
import meow from 'meow'
5+
import ora from 'ora'
6+
57
import { write } from '../src/writer.js'
68

79
const cli = meow(`
@@ -26,22 +28,22 @@ const cli = meow(`
2628
output: {
2729
type: 'string',
2830
shortFlag: 'o',
29-
default: 'schema.js'
31+
default: 'schema.js',
3032
},
3133
header: {
3234
type: 'string',
3335
shortFlag: 'h',
34-
isMultiple: true
36+
isMultiple: true,
3537
},
3638
cjs: {
3739
type: 'boolean',
38-
default: false
40+
default: false,
3941
},
4042
removePrefix: {
4143
type: 'string',
42-
shortFlag: 'r'
43-
}
44-
}
44+
shortFlag: 'r',
45+
},
46+
},
4547
})
4648

4749
if (cli.input.length === 0) {
@@ -53,7 +55,7 @@ const input = cli.input[0]
5355
const spinner = ora(`Generating schema from ${input}`).start()
5456

5557
const headers = {}
56-
cli.flags.header.forEach(header => {
58+
cli.flags.header.forEach((header) => {
5759
const splitIdx = header.indexOf('=')
5860
if (splitIdx === -1) {
5961
spinner.fail('Fetch: the header provided is not valid, it must be: key=value')
@@ -69,7 +71,7 @@ try {
6971
schema = await write(input, {
7072
cjs: cli.flags.cjs,
7173
headers,
72-
removePrefix: cli.flags.removePrefix
74+
removePrefix: cli.flags.removePrefix,
7375
})
7476
} catch (err) {
7577
spinner.fail(err.message)

eslint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { standard } from 'eslint-config-standard-ext'
2+
3+
export default standard()

package.json

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,51 @@
11
{
22
"name": "@geut/openapi-box",
3+
"type": "module",
34
"version": "4.0.0",
45
"description": "Generate TypeBox types from OpenApi IDL + End-to-end typesafe HTTP client library.",
5-
"type": "module",
66
"browser": "./dist/client.cjs",
7-
"main": "./dist/client.cjs",
8-
"bin": "./bin/cli.js",
7+
"author": {
8+
"name": "GEUT",
9+
"email": "[email protected]"
10+
},
11+
"license": "MIT",
12+
"homepage": "https://github.com/geut/openapi-box#readme",
13+
"repository": {
14+
"type": "git",
15+
"url": "git+https://github.com/geut/openapi-box.git"
16+
},
17+
"bugs": {
18+
"url": "https://github.com/geut/openapi-box/issues"
19+
},
20+
"keywords": [
21+
"create",
22+
"geut",
23+
"module"
24+
],
925
"exports": {
1026
".": {
11-
"require": "./dist/client.cjs",
12-
"import": "./dist/client.js"
27+
"import": "./dist/client.js",
28+
"require": "./dist/client.cjs"
1329
},
1430
"./writer": {
15-
"require": "./dist/writer.cjs",
16-
"import": "./dist/writer.js"
31+
"import": "./dist/writer.js",
32+
"require": "./dist/writer.cjs"
1733
},
1834
"./package.json": "./package.json"
1935
},
36+
"main": "./dist/client.cjs",
37+
"bin": "./bin/cli.js",
2038
"files": [
21-
"src",
39+
"bin",
2240
"dist",
23-
"bin"
41+
"src"
2442
],
2543
"scripts": {
2644
"start": "node index.js",
2745
"build": "tsup src/client.js src/writer.js --dts --format esm,cjs",
2846
"test": "node --test",
2947
"posttest": "npm run lint",
30-
"lint": "eslint",
48+
"lint": "eslint .",
3149
"test:types": "tsc",
3250
"prepublishOnly": "npm test && npm run build"
3351
},
@@ -49,6 +67,7 @@
4967
"@sinclair/typebox": "^0.31.17",
5068
"@types/node": "^20.6.2",
5169
"eslint": "^8.46.0",
70+
"eslint-config-standard-ext": "^0.0.27",
5271
"eslint-plugin-jsdoc": "^46.8.1",
5372
"expect-type": "^0.16.0",
5473
"fastify": "^4.21.0",
@@ -64,24 +83,6 @@
6483
"browser"
6584
]
6685
},
67-
"repository": {
68-
"type": "git",
69-
"url": "git+https://github.com/geut/openapi-box.git"
70-
},
71-
"keywords": [
72-
"create",
73-
"geut",
74-
"module"
75-
],
76-
"author": {
77-
"name": "GEUT",
78-
"email": "[email protected]"
79-
},
80-
"license": "MIT",
81-
"bugs": {
82-
"url": "https://github.com/geut/openapi-box/issues"
83-
},
84-
"homepage": "https://github.com/geut/openapi-box#readme",
8586
"publishConfig": {
8687
"access": "public"
8788
}

0 commit comments

Comments
 (0)