From dc8499f13c11dd554f74fe8ec787fe76120ee1cb Mon Sep 17 00:00:00 2001 From: Wouter Boereboom <62436079+wboereboom@users.noreply.github.com> Date: Mon, 20 Jun 2022 11:31:07 +0200 Subject: [PATCH] add openapi templates to repo (#890) * add openapi templates to repo * remove ASCII header from template --- templates/typescript/licenseInfo.mustache | 8 ++++ templates/typescript/model.mustache | 56 +++++++++++++++++++++++ templates/typescript/models.mustache | 6 +++ 3 files changed, 70 insertions(+) create mode 100644 templates/typescript/licenseInfo.mustache create mode 100644 templates/typescript/model.mustache create mode 100644 templates/typescript/models.mustache diff --git a/templates/typescript/licenseInfo.mustache b/templates/typescript/licenseInfo.mustache new file mode 100644 index 0000000..c3a1bc0 --- /dev/null +++ b/templates/typescript/licenseInfo.mustache @@ -0,0 +1,8 @@ +/* + * {{#version}}The version of the OpenAPI document: v{{{.}}}{{/version}} + * {{#infoEmail}}Contact: {{{.}}}{{/infoEmail}} + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ diff --git a/templates/typescript/model.mustache b/templates/typescript/model.mustache new file mode 100644 index 0000000..aabb0de --- /dev/null +++ b/templates/typescript/model.mustache @@ -0,0 +1,56 @@ +{{>licenseInfo}} +{{#models}} +{{#model}} +{{#tsImports}} +import { {{classname}} } from '{{filename}}'; +{{/tsImports}} + +{{#description}} +/** +* {{{description}}} +*/ +{{/description}} +{{^isEnum}} +export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ +{{#vars}} + + /** +{{#description}} + * {{{description}}} +{{/description}} +{{#deprecated}} + * + * @deprecated +{{/deprecated}} + */ + '{{name}}'{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}; +{{/vars}} +} + +{{#hasEnums}} +export namespace {{classname}} { +{{#vars}} +{{#isEnum}} + export enum {{enumName}} { + {{#allowableValues}} + {{#enumVars}} + {{name}} = {{{value}}}{{^-last}},{{/-last}} + {{/enumVars}} + {{/allowableValues}} + } +{{/isEnum}} +{{/vars}} +} +{{/hasEnums}} +{{/isEnum}} +{{#isEnum}} +export enum {{classname}} { + {{#allowableValues}} + {{#enumVars}} + {{name}} = {{{value}}}{{^-last}},{{/-last}} + {{/enumVars}} + {{/allowableValues}} +} +{{/isEnum}} +{{/model}} +{{/models}} \ No newline at end of file diff --git a/templates/typescript/models.mustache b/templates/typescript/models.mustache new file mode 100644 index 0000000..17f9bc1 --- /dev/null +++ b/templates/typescript/models.mustache @@ -0,0 +1,6 @@ +{{>licenseInfo}} +{{#models}} +{{#model}} +export * from '{{{ classFilename }}}'; +{{/model}} +{{/models}}