-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not use a body serializer on text/plain sdks
- Loading branch information
Showing
37 changed files
with
486 additions
and
29 deletions.
There are no files selected for viewing
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,5 @@ | ||
--- | ||
'@hey-api/openapi-ts': patch | ||
--- | ||
|
||
fix: do not use a body serializer on text/plain sdks |
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,8 @@ | ||
--- | ||
'@hey-api/client-axios': patch | ||
'@hey-api/client-fetch': patch | ||
'@hey-api/client-nuxt': patch | ||
'@hey-api/openapi-ts': patch | ||
--- | ||
|
||
fix: add null to valid bodySerializer types |
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,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
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,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<!-- <link rel="icon" type="image/svg+xml" href="/vite.svg" /> --> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Hey API + Fetch API Demo</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
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,20 @@ | ||
import { defineConfig } from '@hey-api/openapi-ts'; | ||
|
||
export default defineConfig({ | ||
client: '@hey-api/client-fetch', | ||
input: | ||
'../../packages/openapi-ts/test/spec/2.0.x/body-response-text-plain.yaml', | ||
output: { | ||
format: 'prettier', | ||
lint: 'eslint', | ||
path: './src/client', | ||
}, | ||
plugins: [ | ||
'@hey-api/schemas', | ||
'@hey-api/sdk', | ||
{ | ||
enums: 'javascript', | ||
name: '@hey-api/typescript', | ||
}, | ||
], | ||
}); |
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 @@ | ||
{ | ||
"name": "@example/openapi-ts-sample", | ||
"private": true, | ||
"version": "0.0.1", | ||
"type": "module", | ||
"scripts": { | ||
"build": "tsc && vite build", | ||
"dev": "vite", | ||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", | ||
"openapi-ts": "openapi-ts", | ||
"preview": "vite preview", | ||
"typecheck": "tsc --noEmit" | ||
}, | ||
"dependencies": { | ||
"@hey-api/client-fetch": "workspace:*", | ||
"@radix-ui/react-form": "0.1.1", | ||
"@radix-ui/react-icons": "1.3.2", | ||
"@radix-ui/themes": "3.1.6", | ||
"react": "19.0.0", | ||
"react-dom": "19.0.0" | ||
}, | ||
"devDependencies": { | ||
"@hey-api/openapi-ts": "workspace:*", | ||
"@types/react": "19.0.1", | ||
"@types/react-dom": "19.0.1", | ||
"@typescript-eslint/eslint-plugin": "7.18.0", | ||
"@typescript-eslint/parser": "7.15.0", | ||
"@vitejs/plugin-react": "4.3.1", | ||
"autoprefixer": "10.4.19", | ||
"eslint": "9.17.0", | ||
"eslint-plugin-react-hooks": "4.6.2", | ||
"eslint-plugin-react-refresh": "0.4.7", | ||
"postcss": "8.4.39", | ||
"prettier": "3.4.2", | ||
"tailwindcss": "3.4.4", | ||
"typescript": "5.5.3", | ||
"vite": "6.0.7" | ||
} | ||
} |
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,6 @@ | ||
export default { | ||
plugins: { | ||
autoprefixer: {}, | ||
tailwindcss: {}, | ||
}, | ||
}; |
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,3 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
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,40 @@ | ||
import './App.css'; | ||
|
||
import { | ||
Box, | ||
Button, | ||
Container, | ||
Flex, | ||
Heading, | ||
Section, | ||
} from '@radix-ui/themes'; | ||
|
||
import { postFoo } from './client/sdk.gen'; | ||
|
||
function App() { | ||
const onClick = async () => { | ||
postFoo({ | ||
body: 'foo', | ||
}); | ||
}; | ||
|
||
return ( | ||
<Box | ||
style={{ background: 'var(--gray-a2)', borderRadius: 'var(--radius-3)' }} | ||
> | ||
<Container size="1"> | ||
<Section size="1" /> | ||
<Flex align="center"> | ||
<Heading>sample for internal testing</Heading> | ||
</Flex> | ||
<Section size="1" /> | ||
<Flex direction="column" gapY="2"> | ||
<Button onClick={onClick}>Click me</Button> | ||
</Flex> | ||
<Section size="1" /> | ||
</Container> | ||
</Box> | ||
); | ||
} | ||
|
||
export default App; |
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,3 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
export * from './sdk.gen'; | ||
export * from './types.gen'; |
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,24 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
|
||
import { | ||
createClient, | ||
createConfig, | ||
type Options, | ||
} from '@hey-api/client-fetch'; | ||
|
||
import type { PostFooData, PostFooResponse } from './types.gen'; | ||
|
||
export const client = createClient(createConfig()); | ||
|
||
export const postFoo = <ThrowOnError extends boolean = false>( | ||
options: Options<PostFooData, ThrowOnError>, | ||
) => | ||
(options?.client ?? client).post<PostFooResponse, unknown, ThrowOnError>({ | ||
bodySerializer: null, | ||
url: '/foo', | ||
...options, | ||
headers: { | ||
'Content-Type': 'text/plain', | ||
...options?.headers, | ||
}, | ||
}); |
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,17 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
|
||
export type PostFooData = { | ||
body: string; | ||
path?: never; | ||
query?: never; | ||
url: '/foo'; | ||
}; | ||
|
||
export type PostFooResponses = { | ||
/** | ||
* OK | ||
*/ | ||
200: string; | ||
}; | ||
|
||
export type PostFooResponse = PostFooResponses[keyof PostFooResponses]; |
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,26 @@ | ||
import '@radix-ui/themes/styles.css'; | ||
|
||
import { Theme } from '@radix-ui/themes'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
|
||
import App from './App.tsx'; | ||
import { client } from './client/sdk.gen'; | ||
|
||
// configure internal service client | ||
client.setConfig({ | ||
// set default base url for requests | ||
baseUrl: 'https://petstore3.swagger.io/api/v3', | ||
// set default headers for requests | ||
headers: { | ||
Authorization: 'Bearer <token_from_service_client>', | ||
}, | ||
}); | ||
|
||
ReactDOM.createRoot(document.getElementById('root')!).render( | ||
<React.StrictMode> | ||
<Theme appearance="dark"> | ||
<App /> | ||
</Theme> | ||
</React.StrictMode>, | ||
); |
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 @@ | ||
/// <reference types="vite/client" /> |
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,8 @@ | ||
/** @type {import('tailwindcss').Config} */ | ||
export default { | ||
content: ['./index.html', './src/**/*.{html,js,ts,jsx,tsx}'], | ||
plugins: [], | ||
theme: { | ||
extend: {}, | ||
}, | ||
}; |
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,25 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2020", | ||
"useDefineForClassFields": true, | ||
"lib": ["ES2020", "DOM", "DOM.Iterable"], | ||
"module": "ESNext", | ||
"skipLibCheck": true, | ||
|
||
/* Bundler mode */ | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
"jsx": "react-jsx", | ||
|
||
/* Linting */ | ||
"strict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noFallthroughCasesInSwitch": true | ||
}, | ||
"include": ["src"], | ||
"references": [{ "path": "./tsconfig.node.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,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"composite": true, | ||
"skipLibCheck": true, | ||
"module": "ESNext", | ||
"moduleResolution": "bundler", | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true | ||
}, | ||
"include": ["vite.config.ts"] | ||
} |
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,7 @@ | ||
import react from '@vitejs/plugin-react'; | ||
import { defineConfig } from 'vite'; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [react()], | ||
}); |
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
Oops, something went wrong.