Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: type error manually #1

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
# WIP
# What is this

# cloudflare-ts-client
CloudFlare Typescript client generated by https://github.com/Himenon/openapi-typescript-code-generator.

To install dependencies:
## Caveat

```bash
bun install
```
- This library support typescript and esm for tree shaking. (Not support commonjs)
- CloudFlare OAS looks less maintenance, which means you can't take benefits and fully types and you man need to extend types manually.
- Therefore, we won't publish it to npm unless official support OAS gets correct. If you want to use this api client, I recommend to fork this and edit openapi.yaml apis sections you'll use, and run gen.ts yourself, but welcome to PR to fix openapi.yaml to be correct.

To run:

```bash
bun run index.ts
```

This project was created using `bun init` in bun v1.0.3. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
Binary file modified bun.lockb
Binary file not shown.
8 changes: 5 additions & 3 deletions gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import type * as Types from "@himenon/openapi-typescript-code-generator/dist/typ
import * as yaml from "js-yaml";

const main = async () => {
const oasDoc: Types.OpenApi.Document = await fetch("https://raw.githubusercontent.com/cloudflare/api-schemas/main/openapi.yaml").then(async v => {
return yaml.load(await v.text()) as Types.OpenApi.Document
})
// const oasDoc: Types.OpenApi.Document = await fetch("https://raw.githubusercontent.com/cloudflare/api-schemas/main/openapi.yaml").then(async v => {
// return yaml.load(await v.text()) as Types.OpenApi.Document
// })

const oasDoc = './openapi.yaml'
const codeGenerator = new CodeGenerator(oasDoc);

const apiClientGeneratorTemplate: Types.CodeGenerator.CustomGenerator<Templates.FunctionalApiClient.Option> = {
Expand Down
Loading