@openapi-generator-plus/typescript-fetch-rn-client-generator
Version:
An OpenAPI Generator Plus template for a TypeScript API client using Fetch in React Native
31 lines (27 loc) • 1.13 kB
text/typescript
import { CodegenGeneratorConstructor, CodegenGeneratorType } from '@openapi-generator-plus/types'
import path from 'path'
import { loadTemplates } from '@openapi-generator-plus/handlebars-templates'
import typescriptGenerator from '@openapi-generator-plus/typescript-fetch-client-generator'
import { TypeScriptGeneratorContext, chainTypeScriptGeneratorContext } from '@openapi-generator-plus/typescript-generator-common'
const createGenerator: CodegenGeneratorConstructor = (config, context) => {
const myContext: TypeScriptGeneratorContext = chainTypeScriptGeneratorContext(context, {
loadAdditionalTemplates: async(hbs) => {
await loadTemplates(path.resolve(__dirname, '../templates'), hbs)
},
additionalWatchPaths: () => {
return [path.resolve(__dirname, '../templates')]
},
})
const base = typescriptGenerator(config, myContext)
return {
...base,
templateRootContext: () => {
return {
...base.templateRootContext(),
generatorClass: '@openapi-generator-plus/typescript-fetch-rn-client-generator',
}
},
generatorType: () => CodegenGeneratorType.CLIENT,
}
}
export default createGenerator