-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ベンチマークの結果(passed/failed)をレスポンスに含める (#28)
* ✨ FinishedBenchmarkにresultを追加 * 🩹 Goのコード生成 * 🚧 フロントエンドのコード生成 * client の openapi 生成に preprocess 処理を嚙ませた * fix(client): type-check * add @types/bun * 🔧 OpenAPIの生成を全部openapi-gen.tsに移動 --------- Co-authored-by: cp-20 <[email protected]>
- Loading branch information
1 parent
b0c0d07
commit 2257d97
Showing
12 changed files
with
274 additions
and
35 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import * as Bun from 'bun' | ||
import * as yaml from 'yaml' | ||
|
||
import openapiTS, { astToString } from 'openapi-typescript' | ||
|
||
// openapi-typescript does not support the combination of oneOf and allOf. | ||
// This is a workaround to strip the discriminator property from the schema. | ||
// ref: https://openapi-ts.dev/advanced#use-oneof-by-itself | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const stripDiscriminator = (schema: any) => { | ||
Object.entries(schema).forEach(([key, value]) => { | ||
if (!(typeof value === 'object')) return | ||
if (key === 'discriminator') { | ||
delete schema[key] | ||
} else { | ||
stripDiscriminator(value) | ||
} | ||
}) | ||
} | ||
|
||
const file = await Bun.file('../openapi/openapi.yml').text() | ||
const parsed = yaml.parse(file) | ||
stripDiscriminator(parsed) | ||
const temp = Bun.env['FILE'] ?? '/tmp/openapi.yml' | ||
await Bun.write(temp, yaml.stringify(parsed)) | ||
|
||
const ast = await openapiTS(new URL(temp, import.meta.url).toString()) | ||
const contents = astToString(ast) | ||
|
||
const contentsWithHeader = | ||
`/** | ||
* This file was auto-generated by openapi-typescript. | ||
* Do not make direct changes to the file. | ||
*/ | ||
` + contents | ||
|
||
await Bun.write('./src/api/openapi.ts', contentsWithHeader) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
{ | ||
"files": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.node.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.app.json" | ||
} | ||
{ "path": "./tsconfig.node.json" }, | ||
{ "path": "./tsconfig.app.json" }, | ||
{ "path": "./tsconfig.script.json" } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"include": ["scripts/**/*"], | ||
"compilerOptions": { | ||
// Enable latest features | ||
"lib": ["ESNext"], | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleDetection": "force", | ||
"jsx": "react-jsx", | ||
"allowJs": true, | ||
|
||
// Bundler mode | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"verbatimModuleSyntax": true, | ||
"noEmit": true, | ||
|
||
// Best practices | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"noFallthroughCasesInSwitch": true, | ||
|
||
// Some stricter flags | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noPropertyAccessFromIndexSignature": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.