File tree Expand file tree Collapse file tree 11 files changed +96
-335
lines changed 
packages/openapi-fetch/examples/sveltekit Expand file tree Collapse file tree 11 files changed +96
-335
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ See [swr-openapi](/swr-openapi/)
2222
2323## Svelte / SvelteKit  
2424
25- [ SvelteKit] ( https://kit. svelte.dev )  の自動型推論機能は、クライアントサイドでのデータ取得や[ ページデータ] ( https://kit. svelte.dev/docs/load#page -data ) の取得において、openapi-fetchの型を簡単に活用できます。また、追加のライブラリを必要とせずに動作します。SvelteKitは、ロード関数内で[ カスタムフェッチ] ( https://kit. svelte.dev/docs/load#making -fetch-requests ) を使用することを推奨しており、これは[ フェッチオプション] ( /ja/openapi-fetch/api#fetch-オプション ) で実現できます。
25+ [ SvelteKit] ( https://svelte.dev/docs/kit  )  の自動型推論機能は、クライアントサイドでのデータ取得や[ ページデータ] ( https://svelte.dev/docs/kit/ load#Page -data ) の取得において、openapi-fetchの型を簡単に活用できます。また、追加のライブラリを必要とせずに動作します。SvelteKitは、ロード関数内で[ カスタムフェッチ] ( https://svelte.dev/docs/kit/ load#Making -fetch-requests ) を使用することを推奨しており、これは[ フェッチオプション] ( /ja/openapi-fetch/api#fetch-オプション ) で実現できます。
2626
2727_ 注: SvelteKitを使用しない場合でも、` src/routes/+page.svelte `  内のルート例は、SvelteKitの機能を使用しておらず、どのようなセットアップにも適用可能です。_ 
2828
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ See [swr-openapi](/swr-openapi/)
2222
2323## Svelte / SvelteKit  
2424
25- [ SvelteKit] ( https://kit. svelte.dev ) ’s automatic type inference can easily pick up openapi-fetch’s types in both clientside fetching and [ Page Data] ( https://kit. svelte.dev/docs/load#page -data )  fetching. And it doesn’t need any additional libraries to work. SvelteKit also advises to use their [ custom fetch] ( https://kit. svelte.dev/docs/load#making -fetch-requests )  in load functions. This can be achieved with [ fetch options] ( /openapi-fetch/api#fetch-options ) .
25+ [ SvelteKit] ( https://svelte.dev/docs/kit  ) ’s automatic type inference can easily pick up openapi-fetch’s types in both clientside fetching and [ Page Data] ( https://svelte.dev/docs/kit/ load#Page -data )  fetching. And it doesn’t need any additional libraries to work. SvelteKit also advises to use their [ custom fetch] ( https://svelte.dev/docs/kit/ load#Making -fetch-requests )  in load functions. This can be achieved with [ fetch options] ( /openapi-fetch/api#fetch-options ) .
2626
2727_ Note: if you’re using Svelte without SvelteKit, the root example in ` src/routes/+page.svelte `  doesn’t use any SvelteKit features and is generally-applicable to any setup._ 
2828
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ See [swr-openapi](/swr-openapi/)
2222
2323## Svelte / SvelteKit  
2424
25- [ SvelteKit] ( https://kit. svelte.dev )  的自动类型推断可以轻松地在客户端获取和 [ Page Data] ( https://kit. svelte.dev/docs/load#page -data )  获取中捕获 openapi-fetch 的类型。而且它不需要任何额外的库。SvelteKit 还建议使用它们的[ 自定义 fetch] ( https://kit. svelte.dev/docs/load#making -fetch-requests ) 在 load 函数中工作。这可以通过 [ fetch options] ( /openapi-fetch/api#fetch-options )  实现。
25+ [ SvelteKit] ( https://svelte.dev/docs/kit  )  的自动类型推断可以轻松地在客户端获取和 [ Page Data] ( https://svelte.dev/docs/kit/ load#Page -data )  获取中捕获 openapi-fetch 的类型。而且它不需要任何额外的库。SvelteKit 还建议使用它们的[ 自定义 fetch] ( https://svelte.dev/docs/kit/ load#Making -fetch-requests ) 在 load 函数中工作。这可以通过 [ fetch options] ( /openapi-fetch/api#fetch-options )  实现。
2626
2727_ 注意:如果你在没有 SvelteKit 的情况下使用 Svelte,` src/routes/+page.svelte `  中的根示例不使用任何 SvelteKit 特性,通常适用于任何设置。_ 
2828
Original file line number Diff line number Diff line change 77    "check" : " svelte-kit sync && svelte-check --tsconfig ./tsconfig.json"  ,
88    "check:watch" : " svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch" 
99  },
10-   "dependencies" : {
11-     "@sveltejs/vite-plugin-svelte-inspector" : " ^4.0.1"  ,
12-     "openapi-fetch" : " workspace:^" 
13-   },
1410  "devDependencies" : {
15-     "@sveltejs/adapter-auto" : " ^3.3.1"  ,
16-     "@sveltejs/kit" : " ^2.20.8"  ,
17-     "@sveltejs/vite-plugin-svelte" : " ^5.0.3"  ,
11+     "@sveltejs/adapter-auto" : " ^6.0.1"  ,
12+     "@sveltejs/kit" : " ^2.22.2"  ,
13+     "@sveltejs/vite-plugin-svelte" : " ^5.1.0"  ,
14+     "openapi-fetch" : " workspace:^"  ,
1815    "openapi-typescript" : " workspace:^"  ,
19-     "svelte" : " ^5.28.2"  ,
20-     "svelte-check" : " ^3.8.6"  ,
21-     "tslib" : " ^2.8.1"  ,
16+     "svelte" : " ^5.34.9"  ,
17+     "svelte-check" : " ^4.2.2"  ,
2218    "typescript" : " ^5.8.3"  ,
23-     "vite" : " ^6.3.4" 
19+     "vite" : " ^6.3.5" 
20+   },
21+   "pnpm" : {
22+     "onlyBuiltDependencies" : [
23+       " esbuild" 
24+     ]
2425  }
2526}
Original file line number Diff line number Diff line change 1- // See https://kit. svelte.dev/docs/types#app 
1+ // See https://svelte.dev/docs/kit/ types#app.d.ts  
22// for information about these interfaces 
33declare  global { 
44	namespace  App  { 
55		// interface Error {} 
66		// interface Locals {} 
77		// interface PageData {} 
8+ 		// interface PageState {} 
89		// interface Platform {} 
910	} 
1011} 
Original file line number Diff line number Diff line change 11<script  lang =" ts"  >
22  import  { onMount  } from  " svelte"  ; 
3+ 
34  import  client  from  " $lib/api/index.js"  ; 
45
5-   let  fact:  Awaited <ReturnType <typeof  getFact >> |  undefined ; 
6+   let  fact:  Awaited <ReturnType <typeof  getFact >> |  undefined   =   $state ( undefined ) ; 
67
78  async  function  getFact() { 
89    return  client .GET (" /fact"  , { 
1213    }); 
1314  } 
1415
15-   onMount (() =>  { 
16-     getFact (). then (( res )  =>  ( fact  =  res ) ); 
16+   onMount (async   () =>  { 
17+     fact  =  await   getFact ( ); 
1718  }); 
1819 </script >
1920
2627      <pre ><code >{JSON .stringify (fact .data , undefined , 2 )}</code ></pre >
2728    {/if }
2829  {/if }
29-   <button  type ="button"  on:click ={() =>  getFact ().then ((res ) =>  (fact  =  res ))}>Another fact!</button >
30+   <button  type ="button"  onclick ={async  () =>  (fact  =  await  getFact ())}>
31+     Another fact!
32+   </button >
3033</div >
Original file line number Diff line number Diff line change 11<script  lang =" ts"  >
2-   import  type  { PageData  } from  " ./$types"  ; 
2+   import  type  { PageProps  } from  " ./$types"  ; 
33
4-   export   let  data:   PageData ; 
4+   let  {  data } :   PageProps   =   $props () ; 
55 </script >
66
77<div >
1313  {:else }
1414    <div >Loading...</div >
1515  {/if }
16-   <button  type ="button"  on:click ={() =>  location .reload ()}>Another fact!</button >
16+   <button  type ="button"  onclick ={() =>  location .reload ()}>Another fact!</button >
1717</div >
Original file line number Diff line number Diff line change 1+ import  type  {  PageLoad  }  from  "./$types" ; 
2+ 
13import  client  from  "$lib/api/index.js" ; 
24
35// Note: this uses Svelte’s custom fetcher as an example, but Node’s 
46// native fetch works, too. See Svelte’s docs to learn the difference: 
5- // @see  https://kit. svelte.dev/docs/load#making -fetch-requests 
6- export  async   function   load ( {  fetch } )  { 
7+ // @see  https://svelte.dev/docs/kit/ load#Making -fetch-requests 
8+ export  const   load :  PageLoad   =   async   ( {  fetch } )   =>  { 
79  const  fact  =  await  client . GET ( "/fact" ,  { 
810    params : {  query : {  max_length : 500  }  } , 
911    fetch, 
@@ -15,4 +17,4 @@ export async function load({ fetch }) {
1517      error : fact . error , 
1618    } , 
1719  } ; 
18- } 
20+ } ; 
Original file line number Diff line number Diff line change @@ -3,14 +3,14 @@ import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
33
44/** @type  {import('@sveltejs/kit').Config } */ 
55const  config  =  { 
6-   // Consult https://kit. svelte.dev/docs/integrations#preprocessors  
6+   // Consult https://svelte.dev/docs/kit/ integrations 
77  // for more information about preprocessors 
88  preprocess : vitePreprocess ( ) , 
99
1010  kit : { 
11-     // adapter-auto only supports some environments, see https://kit. svelte.dev/docs/adapter-auto for a list. 
12-     // If your environment is not supported or you settled on a specific environment, switch out the adapter. 
13-     // See https://kit. svelte.dev/docs/adapters for more information about adapters. 
11+     // adapter-auto only supports some environments, see https://svelte.dev/docs/kit /adapter-auto for a list. 
12+     // If your environment is not supported,  or you settled on a specific environment, switch out the adapter. 
13+     // See https://svelte.dev/docs/kit /adapters for more information about adapters. 
1414    adapter : adapter ( ) , 
1515  } , 
1616} ; 
Original file line number Diff line number Diff line change 33  "compilerOptions" : {
44    "allowJs" : true ,
55    "checkJs" : true ,
6-     "lib" : [" DOM"  ],
76    "esModuleInterop" : true ,
87    "forceConsistentCasingInFileNames" : true ,
98    "resolveJsonModule" : true ,
109    "skipLibCheck" : true ,
1110    "sourceMap" : true ,
12-     "strict" : true 
11+     "strict" : true ,
12+     "moduleResolution" : " bundler" 
1313  }
14-   //  Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
14+   //  Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
15+   //  except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
1516  // 
1617  //  If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
1718  //  from the referenced tsconfig.json - TypeScript does not merge them in
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments