Skip to content

Commit

Permalink
add script to build fetch methods from backend's openapi json
Browse files Browse the repository at this point in the history
  • Loading branch information
cocowmn committed Jan 13, 2024
1 parent 78baab8 commit 32a561f
Show file tree
Hide file tree
Showing 5 changed files with 2,152 additions and 0 deletions.
Binary file added scripts/openapi-codegen/bun.lockb
Binary file not shown.
16 changes: 16 additions & 0 deletions scripts/openapi-codegen/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "openapi-codegen",
"module": "src/app.ts",
"type": "module",
"scripts": {
"start": "openapi-typescript src/openapi/openapi.json --output src/openapi/openapi.ts && bun src/app.ts"
},
"devDependencies": {
"bun-types": "latest",
"openapi-typescript": "^6.7.3",
"typescript": "^5.3.3"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}
4 changes: 4 additions & 0 deletions scripts/openapi-codegen/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ function bufferModels() {
}

function bufferEndpoints() {
<<<<<<< HEAD
outputBuffer = `import type {\n`
=======
outputBuffer = `import {\n`
>>>>>>> e75fc75 (add script to build fetch methods from backend's openapi json)
interfaceNames.forEach((name) => (outputBuffer += ` ${name},\n`))
outputBuffer += `} from './models'\n\n`
outputBuffer += `type Fetch = (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>\n\n`
Expand Down
Loading

0 comments on commit 32a561f

Please sign in to comment.