typescript-fetch-api.api.handlebars Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openapi-generator-typescript-fetch-api Show documentation
Show all versions of openapi-generator-typescript-fetch-api Show documentation
OpenAPI-generator for TypeScript interfaces using the browser native fetch API.
Generates direct mapping of APIs as interfaces and test-data generators for DTOs
/* eslint @typescript-eslint/no-unused-vars: off */
{{>licenseInfo}}
import {
{{~#models}}
{{~#model}}
{{classname}},{{#if vendorExtensions.ts-fetch-api-omitted-in-response}}
{{classname}}Response,{{/if}}{{~#if vendorExtensions.ts-fetch-api-omitted-in-request}}
{{classname}}Request,{{/if}}{{~/model}}
{{~/models}}
} from "./model";
import { BaseAPI, RequestCallOptions, SecurityScheme } from "./base";
{{#withInterfaces~}}
export interface ApplicationApis {
{{~#apiInfo}}{{#apis}}
{{classVarName}}Api: {{classname}}Interface;
{{~/apis}}{{/apiInfo}}
}
{{~/withInterfaces}}
{{#apiInfo}}{{#apis}}{{>apiInner}}{{/apis}}{{/apiInfo}}
type ServerNames =
{{~#servers}}
| "{{#if description}}{{description}}{{else}}default{{/if}}"
{{~/servers}};
export const servers: Record = {
{{~#servers}}
{{#if description}}"{{description}}"{{else}}default{{/if}}: {
{{~#apiInfo}}{{#apis}}
{{classVarName}}Api: new {{classname}}("{{url}}"),
{{~/apis}}{{/apiInfo}}
},
{{~/servers}}
};
{{#if authMethods}}{{#authMethods}}
{{~#unless (eq scheme 'none')}}
export class {{name}} implements SecurityScheme {
{{~#if isBasicBasic}}
constructor(private basicAuthorization: string) {}
headers(): Record {
return {
"Authorization": `Basic ${this.basicAuthorization}`,
}
}
{{~else}}
constructor(private bearerToken: string) {}
headers(): Record {
return {
"Authorization": `Bearer ${this.bearerToken}`,
}
}
{{~/if}}
}
{{/unless~}}
{{/authMethods~}}{{/if~}}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy