1- import type { Plugin } from "@hey-api/openapi-ts" ;
21import { defineConfig } from "@hey-api/openapi-ts" ;
3- import ts from "typescript" ;
42
5- const customPlugin : Plugin . Config < { name : "vrchat/custom-plugin" } > = {
6- name : "vrchat/custom-plugin" ,
7- _handler : ( { context } ) => {
8- const typesFile = context . file ( { id : "types" } ) ! ;
9-
10- context . subscribe ( "after" , ( ) => {
11- const items = ( typesFile as any ) . _items as Array < ts . Node > ;
12-
13- // type _Error = { ... }
14- // ->
15- // import { VRChatError } from "../error";
16- // type _Error = VRChatError;
17-
18- const errorTypeName = "_Error" ;
19- const errorTypeIndex = items . findIndex ( ( item : ts . Node ) => ts . isTypeAliasDeclaration ( item ) && item . name . text === errorTypeName ) ;
20- if ( errorTypeIndex === - 1 ) throw new Error ( "Could not find error type definition" ) ;
21-
22- const { name : errorImport } = typesFile . import ( { module : "../error" , name : "VRChatError" , asType : true } ) ;
23- const errorImportIdentifier = ts . factory . createIdentifier ( errorImport ) ;
24-
25- items [ errorTypeIndex ] = ts . factory . createTypeAliasDeclaration (
26- undefined ,
27- ts . factory . createIdentifier ( errorTypeName ) ,
28- undefined ,
29- ts . factory . createTypeReferenceNode (
30- errorImportIdentifier ,
31- undefined
32- )
33- ) ;
34- } ) ;
35- } ,
36- _handlerLegacy : ( ) => { } ,
37- } ;
3+ import { errorPlugin } from "./plugins/error" ;
384
395export default defineConfig ( {
406 input : "./openapi.yaml" ,
@@ -43,14 +9,18 @@ export default defineConfig({
439 {
4410 name : "@hey-api/typescript" ,
4511 exportFromIndex : false ,
12+ requests : "{{name}}" ,
13+ enums : {
14+ case : "camelCase"
15+ }
4616 } ,
4717 {
4818 name : "@hey-api/client-fetch" ,
49- exportFromIndex : false ,
19+ exportFromIndex : false
5020 } ,
5121 {
5222 name : "@hey-api/transformers" ,
53- exportFromIndex : false ,
23+ exportFromIndex : false
5424 } ,
5525 {
5626 name : "@hey-api/sdk" ,
@@ -61,6 +31,6 @@ export default defineConfig({
6131 transformer : true ,
6232 classNameBuilder : ( ) => "VRChatInternal" ,
6333 } ,
64- customPlugin as any
34+ errorPlugin ( )
6535 ] ,
6636} ) ;
0 commit comments