The TypeScriptClients directive allows you to generate one or more TypeScript Client Libraries.
LazyStack uses the NSwag library to generate these libraries and you are able to use most of the NSwag TypeScriptClientGeneratorSettings class properties to tailor how these libs are generated. NSwag provides many options so we suggest you visit the NSwag Wiki for information on the available settings.
One deviation from the documented NSwag settings is the TypeScriptGeneratorSettings.ExtensionCode property. Instead of specifying code directly, LazyStack requires you provide the name of a template file stored in the solution's TypeScriptClientLibs folder. NSwag inserts this code into the generated TypeScript client library. LazyStack provides a LzClientBaseAxios.ts_tpl file. Use this code as a starting point if you need to create your own.
To support making calls against LazyStack generated AWS serverless stacks, LazyStack requires the following NSwag configuration settings:
ProjectOptions: TypeScriptClients: Axios: Template: Axios UseTransformOptionsMethod: true ClassName: PetStore ClientBaseClass: LzClientBaseAxios ConfigurationClass: any TypeScriptGeneratorSettings: ExtensionCode: LzClientBaseAxios.ts_tpl
ProjectOptions.TypeScriptClients.Axios specifies the name of the client lib. You can use any name you want here but usually it is best to name the lib after the template as it is unlikely you will need multiple client libs using the same template.
Template: The templates supported by NSwag include:
After NSwag generates the library, LazyStack makes a final pass to instrument the library for making secure calls against API Gateways. Like the LzHttpClass, calls are directed to the appropriate API Gateway using the LazyStack generated MethodMap and LazyStack generated AwsSettings.