Skip to content

feat: support ES Modules #119

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

Merged
merged 47 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
aa6c312
chore: update pnpm version
Himenon Feb 1, 2024
1993e20
chore: update pnpm version
Himenon Feb 1, 2024
3888a77
ci: update node version
Himenon Feb 1, 2024
bcba1d7
chore: update pnpm version
Himenon Feb 1, 2024
8534ef5
chore(deps): update all dependencies version
Himenon Feb 1, 2024
057b648
chore: update
Himenon Feb 1, 2024
0fc2818
chore: update
Himenon Feb 1, 2024
bff8fdb
chore: update
Himenon Feb 1, 2024
c22b9dc
chore: update
Himenon Feb 1, 2024
8d70839
chore: update
Himenon Feb 1, 2024
9c7707a
chore: update
Himenon Feb 1, 2024
e3cae82
chore: update
Himenon Feb 1, 2024
9578561
chore: update
Himenon Feb 1, 2024
f42f121
chore: update
Himenon Feb 1, 2024
32fa955
chore: update
Himenon Feb 1, 2024
e3f0251
chore: update
Himenon Feb 1, 2024
1b6cf86
chore: update
Himenon Feb 1, 2024
dcd3763
chore: update
Himenon Feb 1, 2024
61a0de5
chore: update
Himenon Feb 1, 2024
d2e0aa0
chore: update
Himenon Feb 1, 2024
a7305fd
chore: update
Himenon Feb 1, 2024
ac29900
chore: update
Himenon Feb 2, 2024
785dcb3
chore: update
Himenon Feb 2, 2024
ccfa9a3
chore: update
Himenon Feb 2, 2024
f49e14d
chore: update
Himenon Feb 2, 2024
f1cfa70
chore: update
Himenon Feb 2, 2024
d421b83
fix: equality
Himenon Feb 2, 2024
1c39d08
chore: update
Himenon Feb 2, 2024
d216ac6
chore: update
Himenon Feb 2, 2024
7f13b9b
chore: update
Himenon Feb 2, 2024
0d77314
chore: update
Himenon Feb 2, 2024
78dc213
docs: update readme
Himenon Feb 2, 2024
6747d51
chore: update
Himenon Feb 2, 2024
02847a5
chore: update api
Himenon Feb 2, 2024
bd5d9df
chore: update
Himenon Feb 2, 2024
689c2cc
refactor: example
Himenon Feb 3, 2024
f5ca027
chore: update
Himenon Feb 3, 2024
db40f9a
chore: tsup
Himenon Feb 3, 2024
6b92e8b
chore: tsup
Himenon Feb 3, 2024
d92347d
refactor: example
Himenon Feb 3, 2024
6b85884
chore: update
Himenon Feb 3, 2024
b976a5f
chore: update
Himenon Feb 3, 2024
731bc79
chore: update
Himenon Feb 3, 2024
22be7e0
chore: update
Himenon Feb 3, 2024
ba1de3e
chore: update
Himenon Feb 3, 2024
0c7e6a1
chore: update
Himenon Feb 3, 2024
e06fc85
chore: update
Himenon Feb 3, 2024
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
File renamed without changes.
2 changes: 1 addition & 1 deletion .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = {
},
overrides: [
{
files: ["example/**"],
files: ["examples/**"],
rules: {
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-empty-interface": "off",
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [16]
node-version: [20.x]
os: [windows-latest, ubuntu-latest]

steps:
Expand All @@ -22,10 +22,10 @@ jobs:
- uses: actions/checkout@v3
- uses: pnpm/[email protected]
with:
version: 7.0.0
version: 8.15.1
- uses: actions/setup-node@v2
with:
node-version: "16"
node-version: "20.x"
cache: "pnpm"
- run: pnpm i --frozen-lockfile
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
ref: main
- uses: pnpm/[email protected]
with:
version: 7.0.0
version: 8.15.1
- uses: actions/setup-node@v2
with:
node-version: "16"
node-version: "20.x"
registry-url: https://npm.pkg.github.com
scope: "@Himenon"
cache: "pnpm"
Expand All @@ -46,10 +46,10 @@ jobs:
ref: main
- uses: pnpm/[email protected]
with:
version: 7.0.0
version: 8.15.1
- uses: actions/setup-node@v2
with:
node-version: "16"
node-version: "20.x"
registry-url: https://npm.pkg.github.com
scope: "@Himenon"
cache: "pnpm"
Expand All @@ -69,10 +69,10 @@ jobs:
ref: main
- uses: pnpm/[email protected]
with:
version: 7.0.0
version: 8.15.1
- uses: actions/setup-node@v2
with:
node-version: "16.x"
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
cache: "pnpm"
- run: pnpm install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/versionUp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
ref: main
- uses: pnpm/[email protected]
with:
version: 7.0.0
version: 8.15.1
- uses: actions/setup-node@v2
with:
node-version: "16.x"
node-version: "20.x"
cache: "pnpm"
- run: pnpm i --frozen-lockfile
- name: Auto version update
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ debug
test/kubernetes
test/argo-rollout
CHANGELOG.md
esm/
dist/
output/
1 change: 0 additions & 1 deletion .yarnrc

This file was deleted.

23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ main();
import * as fs from "fs";

import { CodeGenerator } from "@himenon/openapi-typescript-code-generator";
import * as Templates from "@himenon/openapi-typescript-code-generator/templates";
import type * as Types from "@himenon/openapi-typescript-code-generator/types";
import * as Templates from "@himenon/openapi-typescript-code-generator/dist/templates";
import type * as Types from "@himenon/openapi-typescript-code-generator/dist/types";

const main = () => {
const codeGenerator = new CodeGenerator("your/openapi/spec.yml");
Expand All @@ -79,7 +79,7 @@ main();
This library provides three types of templates

```ts
import * as Templates from "@himenon/openapi-typescript-code-generator/templates";
import * as Templates from "@himenon/openapi-typescript-code-generator/dist/templates";

Templates.ClassApiClient.generator;
Templates.FunctionalApiClient.generator;
Expand All @@ -106,7 +106,10 @@ export interface ApiClient<RequestOption> {

export class Client<RequestOption> {
private baseUrl: string;
constructor(private apiClient: ApiClient<RequestOption>, baseUrl: string) {
constructor(
private apiClient: ApiClient<RequestOption>,
baseUrl: string,
) {
this.baseUrl = baseUrl.replace(/\/$/, "");
}

Expand Down Expand Up @@ -270,8 +273,8 @@ export const createPublisherV2 =
import * as fs from "fs";

import { CodeGenerator } from "@himenon/openapi-typescript-code-generator";
import * as Templates from "@himenon/openapi-typescript-code-generator/templates";
import type * as Types from "@himenon/openapi-typescript-code-generator/types";
import * as Templates from "@himenon/openapi-typescript-code-generator/dist/templates";
import type * as Types from "@himenon/openapi-typescript-code-generator/dist/types";

const main = () => {
const codeGenerator = new CodeGenerator("your/openapi/spec.yml");
Expand Down Expand Up @@ -307,7 +310,7 @@ The examples in this section can be used in the following ways
import * as fs from "fs";

import { CodeGenerator } from "@himenon/openapi-typescript-code-generator";
import type * as Types from "@himenon/openapi-typescript-code-generator/types";
import type * as Types from "@himenon/openapi-typescript-code-generator/dist/types";

/** Write the definition of the Code Template here. */
const customGenerator: Types.CodeGenerator.CustomGenerator<{}> = {
Expand Down Expand Up @@ -440,7 +443,7 @@ You can directly use the API of TypeScript AST or use the wrapper API of TypeScr

```ts
import * as Types from "@himenon/openapi-typescript-code-generator/types";
import { TsGenerator } from "@himenon/openapi-typescript-code-generator/api";
import { TsGenerator } from "@himenon/openapi-typescript-code-generator/dist/api";

interface Option {}

Expand Down Expand Up @@ -501,7 +504,7 @@ This is a type definition file for `Templates.FunctionalApiClient`. The reason i
### TsGenerator

```ts
import { TsGenerator } from "@himenon/openapi-typescript-code-generator/api";
import { TsGenerator } from "@himenon/openapi-typescript-code-generator/dist/api";
```

This is a wrapper API for the TypeScript AST used internally.
Expand All @@ -510,7 +513,7 @@ It is subject to change without notice.
### OpenApiTools

```ts
import { OpenApiTools } from "@himenon/openapi-typescript-code-generator/api";
import { OpenApiTools } from "@himenon/openapi-typescript-code-generator/dist/api";
```

#### Parser
Expand Down
23 changes: 13 additions & 10 deletions docs/ja/README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ main();
import * as fs from "fs";

import { CodeGenerator } from "@himenon/openapi-typescript-code-generator";
import * as Templates from "@himenon/openapi-typescript-code-generator/templates";
import type * as Types from "@himenon/openapi-typescript-code-generator/types";
import * as Templates from "@himenon/openapi-typescript-code-generator/dist/templates";
import type * as Types from "@himenon/openapi-typescript-code-generator/dist/types";

const main = () => {
const codeGenerator = new CodeGenerator("your/openapi/spec.yml");
Expand All @@ -73,7 +73,7 @@ main();
本ライブラリからは 3 種類提供しています。

```ts
import * as Templates from "@himenon/openapi-typescript-code-generator/templates";
import * as Templates from "@himenon/openapi-typescript-code-generator/dist/templates";

Templates.ClassApiClient.generator;
Templates.FunctionalApiClient.generator;
Expand All @@ -100,7 +100,10 @@ export interface ApiClient<RequestOption> {

export class Client<RequestOption> {
private baseUrl: string;
constructor(private apiClient: ApiClient<RequestOption>, baseUrl: string) {
constructor(
private apiClient: ApiClient<RequestOption>,
baseUrl: string,
) {
this.baseUrl = baseUrl.replace(/\/$/, "");
}

Expand Down Expand Up @@ -266,8 +269,8 @@ export const createPublisherV2 =
import * as fs from "fs";

import { CodeGenerator } from "@himenon/openapi-typescript-code-generator";
import * as Templates from "@himenon/openapi-typescript-code-generator/templates";
import type * as Types from "@himenon/openapi-typescript-code-generator/types";
import * as Templates from "@himenon/openapi-typescript-code-generator/dist/templates";
import type * as Types from "@himenon/openapi-typescript-code-generator/dist/types";

const main = () => {
const codeGenerator = new CodeGenerator("your/openapi/spec.yml");
Expand Down Expand Up @@ -303,7 +306,7 @@ main();
import * as fs from "fs";

import { CodeGenerator } from "@himenon/openapi-typescript-code-generator";
import type * as Types from "@himenon/openapi-typescript-code-generator/types";
import type * as Types from "@himenon/openapi-typescript-code-generator/dist/types";

/** ここにCode Templateの定義を記述してください */
const customGenerator: Types.CodeGenerator.CustomGenerator<{}> = {
Expand Down Expand Up @@ -436,7 +439,7 @@ TypeScript AST の API を利用したコードの拡張が可能です。

```ts
import * as Types from "@himenon/openapi-typescript-code-generator/types";
import { TsGenerator } from "@himenon/openapi-typescript-code-generator/api";
import { TsGenerator } from "@himenon/openapi-typescript-code-generator/dist/api";

interface Option {}

Expand Down Expand Up @@ -497,7 +500,7 @@ OpenAPI Schema から抽出したパラメーターを取得できます。
### TsGenerator

```ts
import { TsGenerator } from "@himenon/openapi-typescript-code-generator/api";
import { TsGenerator } from "@himenon/openapi-typescript-code-generator/dist/api";
```

内部で利用している TypeScript AST のラッパー API です。
Expand All @@ -506,7 +509,7 @@ import { TsGenerator } from "@himenon/openapi-typescript-code-generator/api";
### OpenApiTools

```ts
import { OpenApiTools } from "@himenon/openapi-typescript-code-generator/api";
import { OpenApiTools } from "@himenon/openapi-typescript-code-generator/dist/api";
```

#### Parser
Expand Down
File renamed without changes.
5 changes: 4 additions & 1 deletion example/client.ts → examples/apis/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ export interface ApiClient<RequestOption> {
) => Promise<T>;
}
export class Client<RequestOption> {
constructor(private apiClient: ApiClient<RequestOption>, private baseUrl: string) {}
constructor(
private apiClient: ApiClient<RequestOption>,
private baseUrl: string,
) {}
public async getBooks(option?: RequestOption): Promise<Response$getBooks$Status$200["application/json"]> {
const url = this.baseUrl + `/get/books`;
const headers = {
Expand Down
File renamed without changes.
File renamed without changes.
Loading