diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2fc00b1db..ba3fbcce2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Contributing to OpenAPI TypeScript Codegen +# Contributing to OpenAPI TypeScript 👋 Thanks for your interest in contributing to this project. diff --git a/README.md b/README.md index 762eb89f7..5729a3039 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# OpenAPI TypeScript Codegen +# OpenAPI TypeScript 👋 > ✨ Turn your OpenAPI specification into a beautiful TypeScript client @@ -17,7 +17,7 @@ ## About -This is an opinionated fork of the [openapi-typescript-codegen](https://github.com/ferdikoomen/openapi-typescript-codegen) package. We created it after the original project became [unmaintained](https://github.com/ferdikoomen/openapi-typescript-codegen/issues/1276#issuecomment-1302392146) because we wanted to support OpenAPI v3.1 introduced in the FastAPI [v0.99.0](https://fastapi.tiangolo.com/release-notes/#0990) release. We plan to resolve the most pressing issues in the original project – open an issue if you'd like to prioritise your use case! +`openapi-ts` started as a fork of [openapi-typescript-codegen](https://github.com/ferdikoomen/openapi-typescript-codegen). We created it after the original project became [unmaintained](https://github.com/ferdikoomen/openapi-typescript-codegen/issues/1276#issuecomment-1302392146) to add support for OpenAPI v3.1. We plan to resolve the most pressing issues in the original project – open an issue if you'd like to prioritise your use case! ## Features @@ -33,7 +33,7 @@ This is an opinionated fork of the [openapi-typescript-codegen](https://github.c The fastest way to use `openapi-ts` is via npx ```sh -npx @nicolas-chaulet/openapi-typescript-codegen -i path/to/openapi.json -o src/client +npx @hey-api/openapi-ts -i path/to/openapi.json -o src/client ``` Congratulations on creating your first client! 🎉 @@ -41,13 +41,13 @@ Congratulations on creating your first client! 🎉 ## Installation ```sh -npm install @nicolas-chaulet/openapi-typescript-codegen --save-dev +npm install @hey-api/openapi-ts --save-dev ``` or ```sh -yarn add @nicolas-chaulet/openapi-typescript-codegen -D +yarn add @hey-api/openapi-ts -D ``` If you want to use `openapi-ts` with CLI, add a script to your `package.json` file @@ -61,7 +61,7 @@ If you want to use `openapi-ts` with CLI, add a script to your `package.json` fi You can also generate your client programmatically by importing `openapi-ts` in a `.ts` file. ```ts -import { createClient } from '@nicolas-chaulet/openapi-typescript-codegen' +import { createClient } from '@hey-api/openapi-ts' createClient({ input: 'path/to/openapi.json', @@ -75,8 +75,8 @@ createClient({ `openapi-ts` supports loading configuration from a file inside your project root directory. You can either create a `openapi-ts.config.cjs` file -```js -/** @type {import('@nicolas-chaulet/openapi-typescript-codegen').UserConfig} */ +```cjs +/** @type {import('@hey-api/openapi-ts').UserConfig} */ module.exports = { input: 'path/to/openapi.json', output: 'src/client', @@ -85,8 +85,8 @@ module.exports = { or `openapi-ts.config.mjs` -```js -/** @type {import('@nicolas-chaulet/openapi-typescript-codegen').UserConfig} */ +```mjs +/** @type {import('@hey-api/openapi-ts').UserConfig} */ export default { input: 'path/to/openapi.json', output: 'src/client', @@ -99,8 +99,8 @@ Alternatively, you can use `openapi-ts.config.js` and configure the export state By default, `openapi-ts` will automatically format your client according to your project configuration. To disable automatic formatting, set `format` to false -```js -/** @type {import('@nicolas-chaulet/openapi-typescript-codegen').UserConfig} */ +```mjs +/** @type {import('@hey-api/openapi-ts').UserConfig} */ export default { format: false, input: 'path/to/openapi.json', @@ -114,8 +114,8 @@ You can also prevent your client from being processed by formatters by adding yo For performance reasons, `openapi-ts` does not automatically lint your client. To enable this feature, set `lint` to true -```js -/** @type {import('@nicolas-chaulet/openapi-typescript-codegen').UserConfig} */ +```mjs +/** @type {import('@hey-api/openapi-ts').UserConfig} */ export default { input: 'path/to/openapi.json', lint: true, @@ -129,8 +129,8 @@ You can also prevent your client from being processed by linters by adding your We do not generate TypeScript [enums](https://www.typescriptlang.org/docs/handbook/enums.html) because they are not standard JavaScript and pose [typing challenges](https://dev.to/ivanzm123/dont-use-enums-in-typescript-they-are-very-dangerous-57bh). If you want to iterate through possible field values without manually typing arrays, you can export enums by running -```js -/** @type {import('@nicolas-chaulet/openapi-typescript-codegen').UserConfig} */ +```mjs +/** @type {import('@hey-api/openapi-ts').UserConfig} */ export default { enums: true, input: 'path/to/openapi.json', diff --git a/package-lock.json b/package-lock.json index 862f3d065..28f08c80a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@nicolas-chaulet/openapi-typescript-codegen", + "name": "@hey-api/openapi-ts", "version": "0.27.36", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@nicolas-chaulet/openapi-typescript-codegen", + "name": "@hey-api/openapi-ts", "version": "0.27.36", "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 14daf80f5..0bd3c06b9 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,15 @@ { - "name": "@nicolas-chaulet/openapi-typescript-codegen", + "name": "@hey-api/openapi-ts", "version": "0.27.36", "type": "module", - "description": "Library that generates Typescript clients based on the OpenAPI specification.", - "author": "Ferdi Koomen", - "homepage": "https://github.com/nicolas-chaulet/openapi-typescript-codegen/", + "description": "Turn your OpenAPI specification into a beautiful TypeScript client", + "homepage": "https://github.com/hey-api/openapi-ts/", "repository": { "type": "git", - "url": "git+https://github.com/nicolas-chaulet/openapi-typescript-codegen.git" + "url": "git+https://github.com/hey-api/openapi-ts.git" }, "bugs": { - "url": "https://github.com/nicolas-chaulet/openapi-typescript-codegen/issues" + "url": "https://github.com/hey-api/openapi-ts/issues" }, "license": "MIT", "keywords": [ @@ -18,6 +17,8 @@ "swagger", "generator", "typescript", + "javascript", + "codegen", "yaml", "json", "fetch", @@ -26,12 +27,6 @@ "angular", "node" ], - "maintainers": [ - { - "name": "Ferdi Koomen", - "email": "info@madebyferdi.com" - } - ], "main": "./dist/node/index.js", "types": "./dist/node/index.d.ts", "bin": { @@ -42,23 +37,23 @@ "dist" ], "scripts": { - "dev": "rimraf dist && npm run build-bundle -- --watch", - "build": "run-s clean build-bundle build-types", "build-bundle": "rollup --config rollup.config.ts --configPlugin typescript", - "build-types": "run-s build-types-temp build-types-roll build-types-check", "build-types-check": "tsc --project tsconfig.check.json", "build-types-roll": "rollup --config rollup.dts.config.ts --configPlugin typescript && rimraf temp", "build-types-temp": "tsc --emitDeclarationOnly --outDir temp -p src/node", + "build-types": "run-s build-types-temp build-types-roll build-types-check", + "build": "run-s clean build-bundle build-types", "clean": "rimraf dist test/generated test/e2e/generated coverage node_modules/.cache", + "dev": "rimraf dist && npm run build-bundle -- --watch", "lint:fix": "eslint . --fix", "lint": "eslint .", "prepublishOnly": "npm run build", - "test": "vitest run --config vitest.config.unit.ts", "test:coverage": "vitest run --config vitest.config.unit.ts --coverage", "test:e2e": "vitest run --config vitest.config.e2e.ts", "test:sample": "node test/sample.cjs", "test:update": "vitest run --config vitest.config.unit.ts --update", "test:watch": "vitest --config vitest.config.unit.ts --watch", + "test": "vitest run --config vitest.config.unit.ts", "typecheck": "tsc --noEmit" }, "engines": { diff --git a/src/index.spec.ts b/src/index.spec.ts index c943fdc42..c5fce0b53 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -21,7 +21,7 @@ describe('index', () => { it('downloads and parses v2 without issues', async () => { await createClient({ - input: 'https://raw.githubusercontent.com/ferdikoomen/openapi-typescript-codegen/master/test/spec/v2.json', + input: 'https://raw.githubusercontent.com/hey-api/openapi-ts/main/test/spec/v2.json', output: './generated/v2-downloaded/', write: false, }); @@ -29,7 +29,7 @@ describe('index', () => { it('downloads and parses v3 without issues', async () => { await createClient({ - input: 'https://raw.githubusercontent.com/ferdikoomen/openapi-typescript-codegen/master/test/spec/v3.json', + input: 'https://raw.githubusercontent.com/hey-api/openapi-ts/main/test/spec/v3.json', output: './generated/v3-downloaded/', write: false, });