Skip to content

Commit 280d196

Browse files
committed
- Moved to const definitions for functions
1 parent c6c9d2b commit 280d196

File tree

114 files changed

+286
-266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+286
-266
lines changed

rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const handlebarsPlugin = () => ({
3636
enumerator: true,
3737
escapeComment: true,
3838
escapeDescription: true,
39+
camelCase: true,
3940
},
4041
});
4142
return `export default ${templateSpec};`;

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export type Options = {
4848
* @param request: Path to custom request file
4949
* @param write Write the files to disk (true or false)
5050
*/
51-
export async function generate({
51+
export const generate = async ({
5252
input,
5353
output,
5454
httpClient = HttpClient.FETCH,
@@ -63,7 +63,7 @@ export async function generate({
6363
postfix = 'Service',
6464
request,
6565
write = true,
66-
}: Options): Promise<void> {
66+
}: Options): Promise<void> => {
6767
const openApi = isString(input) ? await getOpenApiSpec(input) : input;
6868
const openApiVersion = getOpenApiVersion(openApi);
6969
const templates = registerHandlebarTemplates({
@@ -119,7 +119,7 @@ export async function generate({
119119
break;
120120
}
121121
}
122-
}
122+
};
123123

124124
export default {
125125
HttpClient,

src/openApi/v2/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import { getServiceVersion } from './parser/getServiceVersion';
1010
* all the models, services and schema's we should output.
1111
* @param openApi The OpenAPI spec that we have loaded from disk.
1212
*/
13-
export function parse(openApi: OpenApi): Client {
13+
export const parse = (openApi: OpenApi): Client => {
1414
const version = getServiceVersion(openApi.info.version);
1515
const server = getServer(openApi);
1616
const models = getModels(openApi);
1717
const services = getServices(openApi);
1818

1919
return { version, server, models, services };
20-
}
20+
};

src/openApi/v2/parser/escapeName.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
export function escapeName(value: string): string {
1+
export const escapeName = (value: string): string => {
22
if (value) {
33
const validName = /^[a-zA-Z_$][\w$]+$/g.test(value);
44
if (!validName) {
55
return `'${value}'`;
66
}
77
}
88
return value;
9-
}
9+
};

src/openApi/v2/parser/extendEnum.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { WithEnumExtension } from '../interfaces/Extensions/WithEnumExtensi
77
* @param enumerators
88
* @param definition
99
*/
10-
export function extendEnum(enumerators: Enum[], definition: WithEnumExtension): Enum[] {
10+
export const extendEnum = (enumerators: Enum[], definition: WithEnumExtension): Enum[] => {
1111
const names = definition['x-enum-varnames'];
1212
const descriptions = definition['x-enum-descriptions'];
1313

@@ -17,4 +17,4 @@ export function extendEnum(enumerators: Enum[], definition: WithEnumExtension):
1717
value: enumerator.value,
1818
type: enumerator.type,
1919
}));
20-
}
20+
};

src/openApi/v2/parser/getEnum.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Enum } from '../../../client/interfaces/Enum';
22
import { isDefined } from '../../../utils/isDefined';
33

4-
export function getEnum(values?: (string | number)[]): Enum[] {
4+
export const getEnum = (values?: (string | number)[]): Enum[] => {
55
if (Array.isArray(values)) {
66
return values
77
.filter((value, index, arr) => {
@@ -30,4 +30,4 @@ export function getEnum(values?: (string | number)[]): Enum[] {
3030
});
3131
}
3232
return [];
33-
}
33+
};

src/openApi/v2/parser/getEnumFromDescription.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Enum } from '../../../client/interfaces/Enum';
33
/**
44
* @deprecated
55
*/
6-
export function getEnumFromDescription(description: string): Enum[] {
6+
export const getEnumFromDescription = (description: string): Enum[] => {
77
// Check if we can find this special format string:
88
// None=0,Something=1,AnotherThing=2
99
if (/^(\w+=[0-9]+)/g.test(description)) {
@@ -36,4 +36,4 @@ export function getEnumFromDescription(description: string): Enum[] {
3636
}
3737

3838
return [];
39-
}
39+
};

src/openApi/v2/parser/getMappedType.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ const TYPE_MAPPINGS = new Map<string, string>([
2424
/**
2525
* Get mapped type for given type to any basic Typescript/Javascript type.
2626
*/
27-
export function getMappedType(type: string, format?: string): string | undefined {
27+
export const getMappedType = (type: string, format?: string): string | undefined => {
2828
if (format === 'binary') {
2929
return 'binary';
3030
}
3131
return TYPE_MAPPINGS.get(type);
32-
}
32+
};

src/openApi/v2/parser/getModel.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import { getModelComposition } from './getModelComposition';
99
import { getModelProperties } from './getModelProperties';
1010
import { getType } from './getType';
1111

12-
export function getModel(
12+
export const getModel = (
1313
openApi: OpenApi,
1414
definition: OpenApiSchema,
1515
isDefinition: boolean = false,
1616
name: string = ''
17-
): Model {
17+
): Model => {
1818
const model: Model = {
1919
name,
2020
export: 'interface',
@@ -162,4 +162,4 @@ export function getModel(
162162
}
163163

164164
return model;
165-
}
165+
};

src/openApi/v2/parser/getModelComposition.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import { getRequiredPropertiesFromComposition } from './getRequiredPropertiesFro
99
// Fix for circular dependency
1010
export type GetModelFn = typeof getModel;
1111

12-
export function getModelComposition(
12+
export const getModelComposition = (
1313
openApi: OpenApi,
1414
definition: OpenApiSchema,
1515
definitions: OpenApiSchema[],
1616
type: 'one-of' | 'any-of' | 'all-of',
1717
getModel: GetModelFn
18-
): ModelComposition {
18+
): ModelComposition => {
1919
const composition: ModelComposition = {
2020
type,
2121
imports: [],
@@ -87,4 +87,4 @@ export function getModelComposition(
8787
}
8888

8989
return composition;
90-
}
90+
};

0 commit comments

Comments
 (0)