[typescript-axios] Add stringEnums option (#11368)

* add stringEnums option

* update templates

* add export

* update samples

* update document

* improve readability

* remove unnecessary code

* add config file for sample

* add sample

* update sample

* remove enum variable form modelObjetEnum template because this variable is not used in modelStringEnum template.

* change the indentation to be the same as modelGeneric template
This commit is contained in:
y-tomida 2022-01-29 16:07:30 +09:00 committed by GitHub
parent b901f11e85
commit 088c65c9c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 2664 additions and 426 deletions

View File

@ -0,0 +1,6 @@
generatorName: typescript-axios
outputDir: samples/client/petstore/typescript-axios/builds/with-string-enums
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/typescript-axios
additionalProperties:
stringEnums: true

View File

@ -34,6 +34,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|stringEnums|Generate string enums instead of objects for enum values.| |false|
|supportsES6|Generate code that conforms to ES6.| |false| |supportsES6|Generate code that conforms to ES6.| |false|
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |false| |useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |false|
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false| |withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|

View File

@ -34,8 +34,11 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
public static final String WITHOUT_PREFIX_ENUMS = "withoutPrefixEnums"; public static final String WITHOUT_PREFIX_ENUMS = "withoutPrefixEnums";
public static final String USE_SINGLE_REQUEST_PARAMETER = "useSingleRequestParameter"; public static final String USE_SINGLE_REQUEST_PARAMETER = "useSingleRequestParameter";
public static final String WITH_NODE_IMPORTS = "withNodeImports"; public static final String WITH_NODE_IMPORTS = "withNodeImports";
public static final String STRING_ENUMS = "stringEnums";
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";
protected String npmRepository = null; protected String npmRepository = null;
protected Boolean stringEnums = false;
private String tsModelPackage = ""; private String tsModelPackage = "";
@ -57,6 +60,7 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
this.cliOptions.add(new CliOption(WITHOUT_PREFIX_ENUMS, "Don't prefix enum names with class names", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(WITHOUT_PREFIX_ENUMS, "Don't prefix enum names with class names", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
this.cliOptions.add(new CliOption(USE_SINGLE_REQUEST_PARAMETER, "Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(USE_SINGLE_REQUEST_PARAMETER, "Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
this.cliOptions.add(new CliOption(WITH_NODE_IMPORTS, "Setting this property to true adds imports for NodeJS", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(WITH_NODE_IMPORTS, "Setting this property to true adds imports for NodeJS", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
this.cliOptions.add(new CliOption(STRING_ENUMS, STRING_ENUMS_DESC).defaultValue(String.valueOf(this.stringEnums)));
// Templates have no mapping between formatted property names and original base names so use only "original" and remove this option // Templates have no mapping between formatted property names and original base names so use only "original" and remove this option
removeOption(CodegenConstants.MODEL_PROPERTY_NAMING); removeOption(CodegenConstants.MODEL_PROPERTY_NAMING);
} }
@ -127,6 +131,11 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
} }
} }
if (additionalProperties.containsKey(STRING_ENUMS)) {
this.stringEnums = Boolean.parseBoolean(additionalProperties.get(STRING_ENUMS).toString());
additionalProperties.put("stringEnums", this.stringEnums);
}
if (additionalProperties.containsKey(NPM_NAME)) { if (additionalProperties.containsKey(NPM_NAME)) {
addNpmPackageGeneration(); addNpmPackageGeneration();
} }

View File

@ -8,16 +8,10 @@ export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last
{{/isBoolean}} {{/isBoolean}}
{{^isBoolean}} {{^isBoolean}}
export enum {{classname}} { {{^stringEnums}}
{{#allowableValues}} {{>modelObjectEnum}}
{{#enumVars}} {{/stringEnums}}
{{#enumDescription}} {{#stringEnums}}
/** {{>modelStringEnum}}
* {{.}} {{/stringEnums}}
*/
{{/enumDescription}}
{{{name}}} = {{{value}}}{{^-last}},{{/-last}}
{{/enumVars}}
{{/allowableValues}}
}
{{/isBoolean}} {{/isBoolean}}

View File

@ -23,6 +23,7 @@ export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
{{#vars}} {{#vars}}
{{#isEnum}} {{#isEnum}}
{{#stringEnums}}
/** /**
* @export * @export
* @enum {string} * @enum {string}
@ -39,6 +40,23 @@ export enum {{enumName}} {
{{/enumVars}} {{/enumVars}}
{{/allowableValues}} {{/allowableValues}}
} }
{{/stringEnums}}
{{^stringEnums}}
export const {{enumName}} = {
{{#allowableValues}}
{{#enumVars}}
{{#enumDescription}}
/**
* {{.}}
*/
{{/enumDescription}}
{{{name}}}: {{{value}}}{{^-last}},{{/-last}}
{{/enumVars}}
{{/allowableValues}}
} as const;
export type {{enumName}} = typeof {{enumName}}[keyof typeof {{enumName}}];
{{/stringEnums}}
{{/isEnum}} {{/isEnum}}
{{/vars}} {{/vars}}
{{/hasEnums}} {{/hasEnums}}

View File

@ -0,0 +1,14 @@
export const {{classname}} = {
{{#allowableValues}}
{{#enumVars}}
{{#enumDescription}}
/**
* {{.}}
*/
{{/enumDescription}}
{{{name}}}: {{{value}}}{{^-last}},{{/-last}}
{{/enumVars}}
{{/allowableValues}}
} as const;
export type {{classname}} = typeof {{classname}}[keyof typeof {{classname}}];

View File

@ -0,0 +1,12 @@
export enum {{classname}} {
{{#allowableValues}}
{{#enumVars}}
{{#enumDescription}}
/**
* {{.}}
*/
{{/enumDescription}}
{{{name}}} = {{{value}}}{{^-last}},{{/-last}}
{{/enumVars}}
{{/allowableValues}}
}

View File

@ -79,16 +79,14 @@ export interface Dog {
'breed'?: DogBreedEnum; 'breed'?: DogBreedEnum;
} }
/** export const DogBreedEnum = {
* @export Dingo: 'Dingo',
* @enum {string} Husky: 'Husky',
*/ Retriever: 'Retriever',
export enum DogBreedEnum { Shepherd: 'Shepherd'
Dingo = 'Dingo', } as const;
Husky = 'Husky',
Retriever = 'Retriever', export type DogBreedEnum = typeof DogBreedEnum[keyof typeof DogBreedEnum];
Shepherd = 'Shepherd'
}
/** /**
* *
@ -110,16 +108,14 @@ export interface DogAllOf {
'breed'?: DogAllOfBreedEnum; 'breed'?: DogAllOfBreedEnum;
} }
/** export const DogAllOfBreedEnum = {
* @export Dingo: 'Dingo',
* @enum {string} Husky: 'Husky',
*/ Retriever: 'Retriever',
export enum DogAllOfBreedEnum { Shepherd: 'Shepherd'
Dingo = 'Dingo', } as const;
Husky = 'Husky',
Retriever = 'Retriever', export type DogAllOfBreedEnum = typeof DogAllOfBreedEnum[keyof typeof DogAllOfBreedEnum];
Shepherd = 'Shepherd'
}
/** /**
* *
@ -173,14 +169,12 @@ export interface PetByType {
'hunts'?: boolean; 'hunts'?: boolean;
} }
/** export const PetByTypePetTypeEnum = {
* @export Cat: 'Cat',
* @enum {string} Dog: 'Dog'
*/ } as const;
export enum PetByTypePetTypeEnum {
Cat = 'Cat', export type PetByTypePetTypeEnum = typeof PetByTypePetTypeEnum[keyof typeof PetByTypePetTypeEnum];
Dog = 'Dog'
}
/** /**

View File

@ -109,15 +109,13 @@ export interface Order {
'complete'?: boolean; 'complete'?: boolean;
} }
/** export const OrderStatusEnum = {
* @export Placed: 'placed',
* @enum {string} Approved: 'approved',
*/ Delivered: 'delivered'
export enum OrderStatusEnum { } as const;
Placed = 'placed',
Approved = 'approved', export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnum];
Delivered = 'delivered'
}
/** /**
* A pet for sale in the pet store * A pet for sale in the pet store
@ -163,15 +161,13 @@ export interface Pet {
'status'?: PetStatusEnum; 'status'?: PetStatusEnum;
} }
/** export const PetStatusEnum = {
* @export Available: 'available',
* @enum {string} Pending: 'pending',
*/ Sold: 'sold'
export enum PetStatusEnum { } as const;
Available = 'available',
Pending = 'pending', export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum];
Sold = 'sold'
}
/** /**
* A tag for a pet * A tag for a pet

View File

@ -109,15 +109,13 @@ export interface Order {
'complete'?: boolean; 'complete'?: boolean;
} }
/** export const OrderStatusEnum = {
* @export Placed: 'placed',
* @enum {string} Approved: 'approved',
*/ Delivered: 'delivered'
export enum OrderStatusEnum { } as const;
Placed = 'placed',
Approved = 'approved', export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnum];
Delivered = 'delivered'
}
/** /**
* A pet for sale in the pet store * A pet for sale in the pet store
@ -163,15 +161,13 @@ export interface Pet {
'status'?: PetStatusEnum; 'status'?: PetStatusEnum;
} }
/** export const PetStatusEnum = {
* @export Available: 'available',
* @enum {string} Pending: 'pending',
*/ Sold: 'sold'
export enum PetStatusEnum { } as const;
Available = 'available',
Pending = 'pending', export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum];
Sold = 'sold'
}
/** /**
* A tag for a pet * A tag for a pet

View File

@ -362,13 +362,11 @@ export interface ChildCat extends ParentPet {
'pet_type': ChildCatPetTypeEnum; 'pet_type': ChildCatPetTypeEnum;
} }
/** export const ChildCatPetTypeEnum = {
* @export ChildCat: 'ChildCat'
* @enum {string} } as const;
*/
export enum ChildCatPetTypeEnum { export type ChildCatPetTypeEnum = typeof ChildCatPetTypeEnum[keyof typeof ChildCatPetTypeEnum];
ChildCat = 'ChildCat'
}
/** /**
* *
@ -390,13 +388,11 @@ export interface ChildCatAllOf {
'pet_type'?: ChildCatAllOfPetTypeEnum; 'pet_type'?: ChildCatAllOfPetTypeEnum;
} }
/** export const ChildCatAllOfPetTypeEnum = {
* @export ChildCat: 'ChildCat'
* @enum {string} } as const;
*/
export enum ChildCatAllOfPetTypeEnum { export type ChildCatAllOfPetTypeEnum = typeof ChildCatAllOfPetTypeEnum[keyof typeof ChildCatAllOfPetTypeEnum];
ChildCat = 'ChildCat'
}
/** /**
* Model for testing model with \"_class\" property * Model for testing model with \"_class\" property
@ -548,22 +544,18 @@ export interface EnumArrays {
'array_enum'?: Array<EnumArraysArrayEnumEnum>; 'array_enum'?: Array<EnumArraysArrayEnumEnum>;
} }
/** export const EnumArraysJustSymbolEnum = {
* @export GreaterThanOrEqualTo: '>=',
* @enum {string} Dollar: '$'
*/ } as const;
export enum EnumArraysJustSymbolEnum {
GreaterThanOrEqualTo = '>=', export type EnumArraysJustSymbolEnum = typeof EnumArraysJustSymbolEnum[keyof typeof EnumArraysJustSymbolEnum];
Dollar = '$' export const EnumArraysArrayEnumEnum = {
} Fish: 'fish',
/** Crab: 'crab'
* @export } as const;
* @enum {string}
*/ export type EnumArraysArrayEnumEnum = typeof EnumArraysArrayEnumEnum[keyof typeof EnumArraysArrayEnumEnum];
export enum EnumArraysArrayEnumEnum {
Fish = 'fish',
Crab = 'crab'
}
/** /**
* *
@ -571,11 +563,14 @@ export enum EnumArraysArrayEnumEnum {
* @enum {string} * @enum {string}
*/ */
export enum EnumClass { export const EnumClass = {
Abc = '_abc', Abc: '_abc',
Efg = '-efg', Efg: '-efg',
Xyz = '(xyz)' Xyz: '(xyz)'
} } as const;
export type EnumClass = typeof EnumClass[keyof typeof EnumClass];
/** /**
* *
@ -639,48 +634,38 @@ export interface EnumTest {
'outerEnumIntegerDefaultValue'?: OuterEnumIntegerDefaultValue; 'outerEnumIntegerDefaultValue'?: OuterEnumIntegerDefaultValue;
} }
/** export const EnumTestEnumStringEnum = {
* @export Upper: 'UPPER',
* @enum {string} Lower: 'lower',
*/ Empty: ''
export enum EnumTestEnumStringEnum { } as const;
Upper = 'UPPER',
Lower = 'lower', export type EnumTestEnumStringEnum = typeof EnumTestEnumStringEnum[keyof typeof EnumTestEnumStringEnum];
Empty = '' export const EnumTestEnumStringRequiredEnum = {
} Upper: 'UPPER',
/** Lower: 'lower',
* @export Empty: ''
* @enum {string} } as const;
*/
export enum EnumTestEnumStringRequiredEnum { export type EnumTestEnumStringRequiredEnum = typeof EnumTestEnumStringRequiredEnum[keyof typeof EnumTestEnumStringRequiredEnum];
Upper = 'UPPER', export const EnumTestEnumIntegerEnum = {
Lower = 'lower', NUMBER_1: 1,
Empty = '' NUMBER_MINUS_1: -1
} } as const;
/**
* @export export type EnumTestEnumIntegerEnum = typeof EnumTestEnumIntegerEnum[keyof typeof EnumTestEnumIntegerEnum];
* @enum {string} export const EnumTestEnumIntegerOnlyEnum = {
*/ NUMBER_2: 2,
export enum EnumTestEnumIntegerEnum { NUMBER_MINUS_2: -2
NUMBER_1 = 1, } as const;
NUMBER_MINUS_1 = -1
} export type EnumTestEnumIntegerOnlyEnum = typeof EnumTestEnumIntegerOnlyEnum[keyof typeof EnumTestEnumIntegerOnlyEnum];
/** export const EnumTestEnumNumberEnum = {
* @export NUMBER_1_DOT_1: 1.1,
* @enum {string} NUMBER_MINUS_1_DOT_2: -1.2
*/ } as const;
export enum EnumTestEnumIntegerOnlyEnum {
NUMBER_2 = 2, export type EnumTestEnumNumberEnum = typeof EnumTestEnumNumberEnum[keyof typeof EnumTestEnumNumberEnum];
NUMBER_MINUS_2 = -2
}
/**
* @export
* @enum {string}
*/
export enum EnumTestEnumNumberEnum {
NUMBER_1_DOT_1 = 1.1,
NUMBER_MINUS_1_DOT_2 = -1.2
}
/** /**
* *
@ -1007,14 +992,12 @@ export interface MapTest {
'indirect_map'?: { [key: string]: boolean; }; 'indirect_map'?: { [key: string]: boolean; };
} }
/** export const MapTestMapOfEnumStringEnum = {
* @export Upper: 'UPPER',
* @enum {string} Lower: 'lower'
*/ } as const;
export enum MapTestMapOfEnumStringEnum {
Upper = 'UPPER', export type MapTestMapOfEnumStringEnum = typeof MapTestMapOfEnumStringEnum[keyof typeof MapTestMapOfEnumStringEnum];
Lower = 'lower'
}
/** /**
* *
@ -1283,15 +1266,13 @@ export interface Order {
'complete'?: boolean; 'complete'?: boolean;
} }
/** export const OrderStatusEnum = {
* @export Placed: 'placed',
* @enum {string} Approved: 'approved',
*/ Delivered: 'delivered'
export enum OrderStatusEnum { } as const;
Placed = 'placed',
Approved = 'approved', export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnum];
Delivered = 'delivered'
}
/** /**
* *
@ -1324,11 +1305,14 @@ export interface OuterComposite {
* @enum {string} * @enum {string}
*/ */
export enum OuterEnum { export const OuterEnum = {
Placed = 'placed', Placed: 'placed',
Approved = 'approved', Approved: 'approved',
Delivered = 'delivered' Delivered: 'delivered'
} } as const;
export type OuterEnum = typeof OuterEnum[keyof typeof OuterEnum];
/** /**
* *
@ -1336,11 +1320,14 @@ export enum OuterEnum {
* @enum {string} * @enum {string}
*/ */
export enum OuterEnumDefaultValue { export const OuterEnumDefaultValue = {
Placed = 'placed', Placed: 'placed',
Approved = 'approved', Approved: 'approved',
Delivered = 'delivered' Delivered: 'delivered'
} } as const;
export type OuterEnumDefaultValue = typeof OuterEnumDefaultValue[keyof typeof OuterEnumDefaultValue];
/** /**
* *
@ -1348,11 +1335,14 @@ export enum OuterEnumDefaultValue {
* @enum {string} * @enum {string}
*/ */
export enum OuterEnumInteger { export const OuterEnumInteger = {
NUMBER_0 = 0, NUMBER_0: 0,
NUMBER_1 = 1, NUMBER_1: 1,
NUMBER_2 = 2 NUMBER_2: 2
} } as const;
export type OuterEnumInteger = typeof OuterEnumInteger[keyof typeof OuterEnumInteger];
/** /**
* *
@ -1360,11 +1350,14 @@ export enum OuterEnumInteger {
* @enum {string} * @enum {string}
*/ */
export enum OuterEnumIntegerDefaultValue { export const OuterEnumIntegerDefaultValue = {
NUMBER_0 = 0, NUMBER_0: 0,
NUMBER_1 = 1, NUMBER_1: 1,
NUMBER_2 = 2 NUMBER_2: 2
} } as const;
export type OuterEnumIntegerDefaultValue = typeof OuterEnumIntegerDefaultValue[keyof typeof OuterEnumIntegerDefaultValue];
/** /**
* *
@ -1417,15 +1410,13 @@ export interface Pet {
'status'?: PetStatusEnum; 'status'?: PetStatusEnum;
} }
/** export const PetStatusEnum = {
* @export Available: 'available',
* @enum {string} Pending: 'pending',
*/ Sold: 'sold'
export enum PetStatusEnum { } as const;
Available = 'available',
Pending = 'pending', export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum];
Sold = 'sold'
}
/** /**
* @type Pig * @type Pig
@ -1731,15 +1722,13 @@ export interface Zebra {
'className': string; 'className': string;
} }
/** export const ZebraTypeEnum = {
* @export Plains: 'plains',
* @enum {string} Mountain: 'mountain',
*/ Grevys: 'grevys'
export enum ZebraTypeEnum { } as const;
Plains = 'plains',
Mountain = 'mountain', export type ZebraTypeEnum = typeof ZebraTypeEnum[keyof typeof ZebraTypeEnum];
Grevys = 'grevys'
}
/** /**

View File

@ -109,15 +109,13 @@ export interface Order {
'complete'?: boolean; 'complete'?: boolean;
} }
/** export const OrderStatusEnum = {
* @export Placed: 'placed',
* @enum {string} Approved: 'approved',
*/ Delivered: 'delivered'
export enum OrderStatusEnum { } as const;
Placed = 'placed',
Approved = 'approved', export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnum];
Delivered = 'delivered'
}
/** /**
* A pet for sale in the pet store * A pet for sale in the pet store
@ -163,15 +161,13 @@ export interface Pet {
'status'?: PetStatusEnum; 'status'?: PetStatusEnum;
} }
/** export const PetStatusEnum = {
* @export Available: 'available',
* @enum {string} Pending: 'pending',
*/ Sold: 'sold'
export enum PetStatusEnum { } as const;
Available = 'available',
Pending = 'pending', export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum];
Sold = 'sold'
}
/** /**
* A tag for a pet * A tag for a pet

View File

@ -361,22 +361,18 @@ export interface EnumArrays {
'array_enum'?: Array<EnumArraysArrayEnumEnum>; 'array_enum'?: Array<EnumArraysArrayEnumEnum>;
} }
/** export const EnumArraysJustSymbolEnum = {
* @export GreaterThanOrEqualTo: '>=',
* @enum {string} Dollar: '$'
*/ } as const;
export enum EnumArraysJustSymbolEnum {
GreaterThanOrEqualTo = '>=', export type EnumArraysJustSymbolEnum = typeof EnumArraysJustSymbolEnum[keyof typeof EnumArraysJustSymbolEnum];
Dollar = '$' export const EnumArraysArrayEnumEnum = {
} Fish: 'fish',
/** Crab: 'crab'
* @export } as const;
* @enum {string}
*/ export type EnumArraysArrayEnumEnum = typeof EnumArraysArrayEnumEnum[keyof typeof EnumArraysArrayEnumEnum];
export enum EnumArraysArrayEnumEnum {
Fish = 'fish',
Crab = 'crab'
}
/** /**
* *
@ -384,11 +380,14 @@ export enum EnumArraysArrayEnumEnum {
* @enum {string} * @enum {string}
*/ */
export enum EnumClass { export const EnumClass = {
Abc = '_abc', Abc: '_abc',
Efg = '-efg', Efg: '-efg',
Xyz = '(xyz)' Xyz: '(xyz)'
} } as const;
export type EnumClass = typeof EnumClass[keyof typeof EnumClass];
/** /**
* *
@ -446,40 +445,32 @@ export interface EnumTest {
'outerEnumIntegerDefaultValue'?: OuterEnumIntegerDefaultValue; 'outerEnumIntegerDefaultValue'?: OuterEnumIntegerDefaultValue;
} }
/** export const EnumTestEnumStringEnum = {
* @export Upper: 'UPPER',
* @enum {string} Lower: 'lower',
*/ Empty: ''
export enum EnumTestEnumStringEnum { } as const;
Upper = 'UPPER',
Lower = 'lower', export type EnumTestEnumStringEnum = typeof EnumTestEnumStringEnum[keyof typeof EnumTestEnumStringEnum];
Empty = '' export const EnumTestEnumStringRequiredEnum = {
} Upper: 'UPPER',
/** Lower: 'lower',
* @export Empty: ''
* @enum {string} } as const;
*/
export enum EnumTestEnumStringRequiredEnum { export type EnumTestEnumStringRequiredEnum = typeof EnumTestEnumStringRequiredEnum[keyof typeof EnumTestEnumStringRequiredEnum];
Upper = 'UPPER', export const EnumTestEnumIntegerEnum = {
Lower = 'lower', NUMBER_1: 1,
Empty = '' NUMBER_MINUS_1: -1
} } as const;
/**
* @export export type EnumTestEnumIntegerEnum = typeof EnumTestEnumIntegerEnum[keyof typeof EnumTestEnumIntegerEnum];
* @enum {string} export const EnumTestEnumNumberEnum = {
*/ NUMBER_1_DOT_1: 1.1,
export enum EnumTestEnumIntegerEnum { NUMBER_MINUS_1_DOT_2: -1.2
NUMBER_1 = 1, } as const;
NUMBER_MINUS_1 = -1
} export type EnumTestEnumNumberEnum = typeof EnumTestEnumNumberEnum[keyof typeof EnumTestEnumNumberEnum];
/**
* @export
* @enum {string}
*/
export enum EnumTestEnumNumberEnum {
NUMBER_1_DOT_1 = 1.1,
NUMBER_MINUS_1_DOT_2 = -1.2
}
/** /**
* *
@ -743,14 +734,12 @@ export interface MapTest {
'indirect_map'?: { [key: string]: boolean; }; 'indirect_map'?: { [key: string]: boolean; };
} }
/** export const MapTestMapOfEnumStringEnum = {
* @export Upper: 'UPPER',
* @enum {string} Lower: 'lower'
*/ } as const;
export enum MapTestMapOfEnumStringEnum {
Upper = 'UPPER', export type MapTestMapOfEnumStringEnum = typeof MapTestMapOfEnumStringEnum[keyof typeof MapTestMapOfEnumStringEnum];
Lower = 'lower'
}
/** /**
* *
@ -978,15 +967,13 @@ export interface Order {
'complete'?: boolean; 'complete'?: boolean;
} }
/** export const OrderStatusEnum = {
* @export Placed: 'placed',
* @enum {string} Approved: 'approved',
*/ Delivered: 'delivered'
export enum OrderStatusEnum { } as const;
Placed = 'placed',
Approved = 'approved', export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnum];
Delivered = 'delivered'
}
/** /**
* *
@ -1019,11 +1006,14 @@ export interface OuterComposite {
* @enum {string} * @enum {string}
*/ */
export enum OuterEnum { export const OuterEnum = {
Placed = 'placed', Placed: 'placed',
Approved = 'approved', Approved: 'approved',
Delivered = 'delivered' Delivered: 'delivered'
} } as const;
export type OuterEnum = typeof OuterEnum[keyof typeof OuterEnum];
/** /**
* *
@ -1031,11 +1021,14 @@ export enum OuterEnum {
* @enum {string} * @enum {string}
*/ */
export enum OuterEnumDefaultValue { export const OuterEnumDefaultValue = {
Placed = 'placed', Placed: 'placed',
Approved = 'approved', Approved: 'approved',
Delivered = 'delivered' Delivered: 'delivered'
} } as const;
export type OuterEnumDefaultValue = typeof OuterEnumDefaultValue[keyof typeof OuterEnumDefaultValue];
/** /**
* *
@ -1043,11 +1036,14 @@ export enum OuterEnumDefaultValue {
* @enum {string} * @enum {string}
*/ */
export enum OuterEnumInteger { export const OuterEnumInteger = {
NUMBER_0 = 0, NUMBER_0: 0,
NUMBER_1 = 1, NUMBER_1: 1,
NUMBER_2 = 2 NUMBER_2: 2
} } as const;
export type OuterEnumInteger = typeof OuterEnumInteger[keyof typeof OuterEnumInteger];
/** /**
* *
@ -1055,11 +1051,14 @@ export enum OuterEnumInteger {
* @enum {string} * @enum {string}
*/ */
export enum OuterEnumIntegerDefaultValue { export const OuterEnumIntegerDefaultValue = {
NUMBER_0 = 0, NUMBER_0: 0,
NUMBER_1 = 1, NUMBER_1: 1,
NUMBER_2 = 2 NUMBER_2: 2
} } as const;
export type OuterEnumIntegerDefaultValue = typeof OuterEnumIntegerDefaultValue[keyof typeof OuterEnumIntegerDefaultValue];
/** /**
* *
@ -1106,15 +1105,13 @@ export interface Pet {
'status'?: PetStatusEnum; 'status'?: PetStatusEnum;
} }
/** export const PetStatusEnum = {
* @export Available: 'available',
* @enum {string} Pending: 'pending',
*/ Sold: 'sold'
export enum PetStatusEnum { } as const;
Available = 'available',
Pending = 'pending', export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum];
Sold = 'sold'
}
/** /**
* *
@ -1353,15 +1350,13 @@ export interface Zebra {
'className': string; 'className': string;
} }
/** export const ZebraTypeEnum = {
* @export Plains: 'plains',
* @enum {string} Mountain: 'mountain',
*/ Grevys: 'grevys'
export enum ZebraTypeEnum { } as const;
Plains = 'plains',
Mountain = 'mountain', export type ZebraTypeEnum = typeof ZebraTypeEnum[keyof typeof ZebraTypeEnum];
Grevys = 'grevys'
}
/** /**

View File

@ -109,15 +109,13 @@ export interface Order {
'complete'?: boolean; 'complete'?: boolean;
} }
/** export const OrderStatusEnum = {
* @export Placed: 'placed',
* @enum {string} Approved: 'approved',
*/ Delivered: 'delivered'
export enum OrderStatusEnum { } as const;
Placed = 'placed',
Approved = 'approved', export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnum];
Delivered = 'delivered'
}
/** /**
* A pet for sale in the pet store * A pet for sale in the pet store
@ -163,15 +161,13 @@ export interface Pet {
'status'?: PetStatusEnum; 'status'?: PetStatusEnum;
} }
/** export const PetStatusEnum = {
* @export Available: 'available',
* @enum {string} Pending: 'pending',
*/ Sold: 'sold'
export enum PetStatusEnum { } as const;
Available = 'available',
Pending = 'pending', export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum];
Sold = 'sold'
}
/** /**
* A tag for a pet * A tag for a pet

View File

@ -113,15 +113,13 @@ export interface Order {
'complete'?: boolean; 'complete'?: boolean;
} }
/** export const OrderStatusEnum = {
* @export Placed: 'placed',
* @enum {string} Approved: 'approved',
*/ Delivered: 'delivered'
export enum OrderStatusEnum { } as const;
Placed = 'placed',
Approved = 'approved', export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnum];
Delivered = 'delivered'
}
/** /**
* A pet for sale in the pet store * A pet for sale in the pet store
@ -167,15 +165,13 @@ export interface Pet {
'status'?: PetStatusEnum; 'status'?: PetStatusEnum;
} }
/** export const PetStatusEnum = {
* @export Available: 'available',
* @enum {string} Pending: 'pending',
*/ Sold: 'sold'
export enum PetStatusEnum { } as const;
Available = 'available',
Pending = 'pending', export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum];
Sold = 'sold'
}
/** /**
* A tag for a pet * A tag for a pet

View File

@ -58,14 +58,12 @@ export interface Order {
'complete'?: boolean; 'complete'?: boolean;
} }
/** export const OrderStatusEnum = {
* @export Placed: 'placed',
* @enum {string} Approved: 'approved',
*/ Delivered: 'delivered'
export enum OrderStatusEnum { } as const;
Placed = 'placed',
Approved = 'approved', export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnum];
Delivered = 'delivered'
}

View File

@ -60,14 +60,12 @@ export interface Pet {
'status'?: PetStatusEnum; 'status'?: PetStatusEnum;
} }
/** export const PetStatusEnum = {
* @export Available: 'available',
* @enum {string} Pending: 'pending',
*/ Sold: 'sold'
export enum PetStatusEnum { } as const;
Available = 'available',
Pending = 'pending', export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum];
Sold = 'sold'
}

View File

@ -109,15 +109,13 @@ export interface Order {
'complete'?: boolean; 'complete'?: boolean;
} }
/** export const OrderStatusEnum = {
* @export Placed: 'placed',
* @enum {string} Approved: 'approved',
*/ Delivered: 'delivered'
export enum OrderStatusEnum { } as const;
Placed = 'placed',
Approved = 'approved', export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnum];
Delivered = 'delivered'
}
/** /**
* A pet for sale in the pet store * A pet for sale in the pet store
@ -163,15 +161,13 @@ export interface Pet {
'status'?: PetStatusEnum; 'status'?: PetStatusEnum;
} }
/** export const PetStatusEnum = {
* @export Available: 'available',
* @enum {string} Pending: 'pending',
*/ Sold: 'sold'
export enum PetStatusEnum { } as const;
Available = 'available',
Pending = 'pending', export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum];
Sold = 'sold'
}
/** /**
* A tag for a pet * A tag for a pet

View File

@ -109,15 +109,13 @@ export interface Order {
'complete'?: boolean; 'complete'?: boolean;
} }
/** export const OrderStatusEnum = {
* @export Placed: 'placed',
* @enum {string} Approved: 'approved',
*/ Delivered: 'delivered'
export enum OrderStatusEnum { } as const;
Placed = 'placed',
Approved = 'approved', export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnum];
Delivered = 'delivered'
}
/** /**
* A pet for sale in the pet store * A pet for sale in the pet store
@ -163,15 +161,13 @@ export interface Pet {
'status'?: PetStatusEnum; 'status'?: PetStatusEnum;
} }
/** export const PetStatusEnum = {
* @export Available: 'available',
* @enum {string} Pending: 'pending',
*/ Sold: 'sold'
export enum PetStatusEnum { } as const;
Available = 'available',
Pending = 'pending', export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum];
Sold = 'sold'
}
/** /**
* A tag for a pet * A tag for a pet

View File

@ -0,0 +1,4 @@
wwwroot/*.js
node_modules
typings
dist

View File

@ -0,0 +1 @@
# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm

View File

@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@ -0,0 +1,8 @@
.gitignore
.npmignore
api.ts
base.ts
common.ts
configuration.ts
git_push.sh
index.ts

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,71 @@
/* tslint:disable */
/* eslint-disable */
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { Configuration } from "./configuration";
// Some imports not used depending on template conditions
// @ts-ignore
import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, "");
/**
*
* @export
*/
export const COLLECTION_FORMATS = {
csv: ",",
ssv: " ",
tsv: "\t",
pipes: "|",
};
/**
*
* @export
* @interface RequestArgs
*/
export interface RequestArgs {
url: string;
options: AxiosRequestConfig;
}
/**
*
* @export
* @class BaseAPI
*/
export class BaseAPI {
protected configuration: Configuration | undefined;
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
if (configuration) {
this.configuration = configuration;
this.basePath = configuration.basePath || this.basePath;
}
}
};
/**
*
* @export
* @class RequiredError
* @extends {Error}
*/
export class RequiredError extends Error {
name: "RequiredError" = "RequiredError";
constructor(public field: string, msg?: string) {
super(msg);
}
}

View File

@ -0,0 +1,138 @@
/* tslint:disable */
/* eslint-disable */
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { Configuration } from "./configuration";
import { RequiredError, RequestArgs } from "./base";
import { AxiosInstance, AxiosResponse } from 'axios';
/**
*
* @export
*/
export const DUMMY_BASE_URL = 'https://example.com'
/**
*
* @throws {RequiredError}
* @export
*/
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
if (paramValue === null || paramValue === undefined) {
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
}
}
/**
*
* @export
*/
export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
if (configuration && configuration.apiKey) {
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
? await configuration.apiKey(keyParamName)
: await configuration.apiKey;
object[keyParamName] = localVarApiKeyValue;
}
}
/**
*
* @export
*/
export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
if (configuration && (configuration.username || configuration.password)) {
object["auth"] = { username: configuration.username, password: configuration.password };
}
}
/**
*
* @export
*/
export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
? await configuration.accessToken()
: await configuration.accessToken;
object["Authorization"] = "Bearer " + accessToken;
}
}
/**
*
* @export
*/
export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? await configuration.accessToken(name, scopes)
: await configuration.accessToken;
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
}
}
/**
*
* @export
*/
export const setSearchParams = function (url: URL, ...objects: any[]) {
const searchParams = new URLSearchParams(url.search);
for (const object of objects) {
for (const key in object) {
if (Array.isArray(object[key])) {
searchParams.delete(key);
for (const item of object[key]) {
searchParams.append(key, item);
}
} else {
searchParams.set(key, object[key]);
}
}
}
url.search = searchParams.toString();
}
/**
*
* @export
*/
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
const nonString = typeof value !== 'string';
const needsSerialization = nonString && configuration && configuration.isJsonMime
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
: nonString;
return needsSerialization
? JSON.stringify(value !== undefined ? value : {})
: (value || "");
}
/**
*
* @export
*/
export const toPathString = function (url: URL) {
return url.pathname + url.search + url.hash
}
/**
*
* @export
*/
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url};
return axios.request<T, R>(axiosRequestArgs);
};
}

View File

@ -0,0 +1,101 @@
/* tslint:disable */
/* eslint-disable */
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export interface ConfigurationParameters {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
username?: string;
password?: string;
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
basePath?: string;
baseOptions?: any;
formDataCtor?: new () => any;
}
export class Configuration {
/**
* parameter for apiKey security
* @param name security name
* @memberof Configuration
*/
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
/**
* parameter for basic security
*
* @type {string}
* @memberof Configuration
*/
username?: string;
/**
* parameter for basic security
*
* @type {string}
* @memberof Configuration
*/
password?: string;
/**
* parameter for oauth2 security
* @param name security name
* @param scopes oauth2 scope
* @memberof Configuration
*/
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
/**
* override base path
*
* @type {string}
* @memberof Configuration
*/
basePath?: string;
/**
* base options for axios calls
*
* @type {any}
* @memberof Configuration
*/
baseOptions?: any;
/**
* The FormData constructor that will be used to create multipart form data
* requests. You can inject this here so that execution environments that
* do not support the FormData class can still run the generated client.
*
* @type {new () => FormData}
*/
formDataCtor?: new () => any;
constructor(param: ConfigurationParameters = {}) {
this.apiKey = param.apiKey;
this.username = param.username;
this.password = param.password;
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.baseOptions = param.baseOptions;
this.formDataCtor = param.formDataCtor;
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
}
}

View File

@ -0,0 +1,57 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
git_host=$4
if [ "$git_host" = "" ]; then
git_host="github.com"
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
fi
if [ "$git_user_id" = "" ]; then
git_user_id="GIT_USER_ID"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi
if [ "$git_repo_id" = "" ]; then
git_repo_id="GIT_REPO_ID"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi
if [ "$release_note" = "" ]; then
release_note="Minor update"
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
fi
# Initialize the local directory as a Git repository
git init
# Adds the files in the local repository and stages them for commit.
git add .
# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'

View File

@ -0,0 +1,18 @@
/* tslint:disable */
/* eslint-disable */
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export * from "./api";
export * from "./configuration";