mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
- Fixed export for isolatedModules
This commit is contained in:
parent
1ef41659c1
commit
cde9e0e9be
@ -11,7 +11,13 @@ export { OpenAPI } from './core/OpenAPI';
|
||||
{{#if models}}
|
||||
|
||||
{{#each models}}
|
||||
export { {{{this}}} } from './models/{{{this}}}';
|
||||
{{#if enum}}
|
||||
export { {{{name}}} } from './models/{{{name}}}';
|
||||
{{else if enums}}
|
||||
export { {{{name}}} } from './models/{{{name}}}';
|
||||
{{else}}
|
||||
export type { {{{name}}} } from './models/{{{name}}}';
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
@ -19,7 +25,7 @@ export { {{{this}}} } from './models/{{{this}}}';
|
||||
{{#if models}}
|
||||
|
||||
{{#each models}}
|
||||
export { ${{{this}}} } from './schemas/${{{this}}}';
|
||||
export { ${{{name}}} } from './schemas/${{{name}}}';
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
@ -27,7 +33,7 @@ export { ${{{this}}} } from './schemas/${{{this}}}';
|
||||
{{#if services}}
|
||||
|
||||
{{#each services}}
|
||||
export { {{{this}}} } from './services/{{{this}}}';
|
||||
export { {{{name}}} } from './services/{{{name}}}';
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
@ -3,8 +3,7 @@ import { getModelNames } from './getModelNames';
|
||||
|
||||
describe('getModelNames', () => {
|
||||
it('should return sorted list', () => {
|
||||
const models: Model[] = [];
|
||||
models.push({
|
||||
const john: Model = {
|
||||
export: 'interface',
|
||||
name: 'John',
|
||||
type: 'John',
|
||||
@ -21,8 +20,8 @@ describe('getModelNames', () => {
|
||||
enum: [],
|
||||
enums: [],
|
||||
properties: [],
|
||||
});
|
||||
models.push({
|
||||
};
|
||||
const jane: Model = {
|
||||
export: 'interface',
|
||||
name: 'Jane',
|
||||
type: 'Jane',
|
||||
@ -39,8 +38,8 @@ describe('getModelNames', () => {
|
||||
enum: [],
|
||||
enums: [],
|
||||
properties: [],
|
||||
});
|
||||
models.push({
|
||||
};
|
||||
const doe: Model = {
|
||||
export: 'interface',
|
||||
name: 'Doe',
|
||||
type: 'Doe',
|
||||
@ -57,7 +56,8 @@ describe('getModelNames', () => {
|
||||
enum: [],
|
||||
enums: [],
|
||||
properties: [],
|
||||
});
|
||||
};
|
||||
const models: Model[] = [john, jane, doe];
|
||||
|
||||
expect(getModelNames([])).toEqual([]);
|
||||
expect(getModelNames(models)).toEqual(['Doe', 'Jane', 'John']);
|
||||
|
||||
@ -3,22 +3,23 @@ import { getServiceNames } from './getServiceNames';
|
||||
|
||||
describe('getServiceNames', () => {
|
||||
it('should return sorted list', () => {
|
||||
const services: Service[] = [];
|
||||
services.push({
|
||||
const john: Service = {
|
||||
name: 'John',
|
||||
operations: [],
|
||||
imports: [],
|
||||
});
|
||||
services.push({
|
||||
};
|
||||
const jane: Service = {
|
||||
name: 'Jane',
|
||||
operations: [],
|
||||
imports: [],
|
||||
});
|
||||
services.push({
|
||||
};
|
||||
const doe: Service = {
|
||||
name: 'Doe',
|
||||
operations: [],
|
||||
imports: [],
|
||||
});
|
||||
};
|
||||
|
||||
const services: Service[] = [john, jane, doe];
|
||||
|
||||
expect(getServiceNames([])).toEqual([]);
|
||||
expect(getServiceNames(services)).toEqual(['Doe', 'Jane', 'John']);
|
||||
|
||||
65
src/utils/sortModelsByName.spec.ts
Normal file
65
src/utils/sortModelsByName.spec.ts
Normal file
@ -0,0 +1,65 @@
|
||||
import { Model } from '../client/interfaces/Model';
|
||||
import { sortModelsByName } from './sortModelsByName';
|
||||
|
||||
describe('sortModelsByName', () => {
|
||||
it('should return sorted list', () => {
|
||||
const john: Model = {
|
||||
export: 'interface',
|
||||
name: 'John',
|
||||
type: 'John',
|
||||
base: 'John',
|
||||
template: null,
|
||||
link: null,
|
||||
description: null,
|
||||
isDefinition: true,
|
||||
isReadOnly: false,
|
||||
isRequired: false,
|
||||
isNullable: false,
|
||||
imports: [],
|
||||
extends: [],
|
||||
enum: [],
|
||||
enums: [],
|
||||
properties: [],
|
||||
};
|
||||
const jane: Model = {
|
||||
export: 'interface',
|
||||
name: 'Jane',
|
||||
type: 'Jane',
|
||||
base: 'Jane',
|
||||
template: null,
|
||||
link: null,
|
||||
description: null,
|
||||
isDefinition: true,
|
||||
isReadOnly: false,
|
||||
isRequired: false,
|
||||
isNullable: false,
|
||||
imports: [],
|
||||
extends: [],
|
||||
enum: [],
|
||||
enums: [],
|
||||
properties: [],
|
||||
};
|
||||
const doe: Model = {
|
||||
export: 'interface',
|
||||
name: 'Doe',
|
||||
type: 'Doe',
|
||||
base: 'Doe',
|
||||
template: null,
|
||||
link: null,
|
||||
description: null,
|
||||
isDefinition: true,
|
||||
isReadOnly: false,
|
||||
isRequired: false,
|
||||
isNullable: false,
|
||||
imports: [],
|
||||
extends: [],
|
||||
enum: [],
|
||||
enums: [],
|
||||
properties: [],
|
||||
};
|
||||
const models: Model[] = [john, jane, doe];
|
||||
|
||||
expect(sortModelsByName([])).toEqual([]);
|
||||
expect(sortModelsByName(models)).toEqual([doe, jane, john]);
|
||||
});
|
||||
});
|
||||
9
src/utils/sortModelsByName.ts
Normal file
9
src/utils/sortModelsByName.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { Model } from '../client/interfaces/Model';
|
||||
|
||||
export function sortModelsByName(models: Model[]): Model[] {
|
||||
return models.sort((a, b) => {
|
||||
const nameA = a.name.toLowerCase();
|
||||
const nameB = b.name.toLowerCase();
|
||||
return nameA.localeCompare(nameB, 'en');
|
||||
});
|
||||
}
|
||||
27
src/utils/sortServicesByName.spec.ts
Normal file
27
src/utils/sortServicesByName.spec.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { Service } from '../client/interfaces/Service';
|
||||
import { sortServicesByName } from './sortServicesByName';
|
||||
|
||||
describe('sortServicesByName', () => {
|
||||
it('should return sorted list', () => {
|
||||
const john: Service = {
|
||||
name: 'John',
|
||||
operations: [],
|
||||
imports: [],
|
||||
};
|
||||
const jane: Service = {
|
||||
name: 'Jane',
|
||||
operations: [],
|
||||
imports: [],
|
||||
};
|
||||
const doe: Service = {
|
||||
name: 'Doe',
|
||||
operations: [],
|
||||
imports: [],
|
||||
};
|
||||
|
||||
const services: Service[] = [john, jane, doe];
|
||||
|
||||
expect(sortServicesByName([])).toEqual([]);
|
||||
expect(sortServicesByName(services)).toEqual([doe, jane, john]);
|
||||
});
|
||||
});
|
||||
9
src/utils/sortServicesByName.ts
Normal file
9
src/utils/sortServicesByName.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { Service } from '../client/interfaces/Service';
|
||||
|
||||
export function sortServicesByName(services: Service[]): Service[] {
|
||||
return services.sort((a, b) => {
|
||||
const nameA = a.name.toLowerCase();
|
||||
const nameB = b.name.toLowerCase();
|
||||
return nameA.localeCompare(nameB, 'en');
|
||||
});
|
||||
}
|
||||
@ -2,9 +2,9 @@ import * as path from 'path';
|
||||
|
||||
import { Client } from '../client/interfaces/Client';
|
||||
import { writeFile } from './fileSystem';
|
||||
import { getModelNames } from './getModelNames';
|
||||
import { getServiceNames } from './getServiceNames';
|
||||
import { Templates } from './registerHandlebarTemplates';
|
||||
import { sortModelsByName } from './sortModelsByName';
|
||||
import { sortServicesByName } from './sortServicesByName';
|
||||
|
||||
/**
|
||||
* Generate the OpenAPI client index file using the Handlebar template and write it to disk.
|
||||
@ -36,8 +36,8 @@ export async function writeClientIndex(
|
||||
exportSchemas,
|
||||
server: client.server,
|
||||
version: client.version,
|
||||
models: getModelNames(client.models),
|
||||
services: getServiceNames(client.services),
|
||||
models: sortModelsByName(client.models),
|
||||
services: sortServicesByName(client.services),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@ -470,47 +470,47 @@ export { ApiError } from './core/ApiError';
|
||||
export { isSuccess } from './core/isSuccess';
|
||||
export { OpenAPI } from './core/OpenAPI';
|
||||
|
||||
export { ArrayWithArray } from './models/ArrayWithArray';
|
||||
export { ArrayWithBooleans } from './models/ArrayWithBooleans';
|
||||
export { ArrayWithNumbers } from './models/ArrayWithNumbers';
|
||||
export { ArrayWithProperties } from './models/ArrayWithProperties';
|
||||
export { ArrayWithReferences } from './models/ArrayWithReferences';
|
||||
export { ArrayWithStrings } from './models/ArrayWithStrings';
|
||||
export { DictionaryWithArray } from './models/DictionaryWithArray';
|
||||
export { DictionaryWithDictionary } from './models/DictionaryWithDictionary';
|
||||
export { DictionaryWithProperties } from './models/DictionaryWithProperties';
|
||||
export { DictionaryWithReference } from './models/DictionaryWithReference';
|
||||
export { DictionaryWithString } from './models/DictionaryWithString';
|
||||
export type { ArrayWithArray } from './models/ArrayWithArray';
|
||||
export type { ArrayWithBooleans } from './models/ArrayWithBooleans';
|
||||
export type { ArrayWithNumbers } from './models/ArrayWithNumbers';
|
||||
export type { ArrayWithProperties } from './models/ArrayWithProperties';
|
||||
export type { ArrayWithReferences } from './models/ArrayWithReferences';
|
||||
export type { ArrayWithStrings } from './models/ArrayWithStrings';
|
||||
export type { DictionaryWithArray } from './models/DictionaryWithArray';
|
||||
export type { DictionaryWithDictionary } from './models/DictionaryWithDictionary';
|
||||
export type { DictionaryWithProperties } from './models/DictionaryWithProperties';
|
||||
export type { DictionaryWithReference } from './models/DictionaryWithReference';
|
||||
export type { DictionaryWithString } from './models/DictionaryWithString';
|
||||
export { EnumFromDescription } from './models/EnumFromDescription';
|
||||
export { EnumWithExtensions } from './models/EnumWithExtensions';
|
||||
export { EnumWithNumbers } from './models/EnumWithNumbers';
|
||||
export { EnumWithStrings } from './models/EnumWithStrings';
|
||||
export { ModelLink } from './models/ModelLink';
|
||||
export { ModelThatExtends } from './models/ModelThatExtends';
|
||||
export { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends';
|
||||
export { ModelWithArray } from './models/ModelWithArray';
|
||||
export { ModelWithBoolean } from './models/ModelWithBoolean';
|
||||
export { ModelWithCircularReference } from './models/ModelWithCircularReference';
|
||||
export { ModelWithDictionary } from './models/ModelWithDictionary';
|
||||
export { ModelWithDuplicateImports } from './models/ModelWithDuplicateImports';
|
||||
export { ModelWithDuplicateProperties } from './models/ModelWithDuplicateProperties';
|
||||
export type { ModelLink } from './models/ModelLink';
|
||||
export type { ModelThatExtends } from './models/ModelThatExtends';
|
||||
export type { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends';
|
||||
export type { ModelWithArray } from './models/ModelWithArray';
|
||||
export type { ModelWithBoolean } from './models/ModelWithBoolean';
|
||||
export type { ModelWithCircularReference } from './models/ModelWithCircularReference';
|
||||
export type { ModelWithDictionary } from './models/ModelWithDictionary';
|
||||
export type { ModelWithDuplicateImports } from './models/ModelWithDuplicateImports';
|
||||
export type { ModelWithDuplicateProperties } from './models/ModelWithDuplicateProperties';
|
||||
export { ModelWithEnum } from './models/ModelWithEnum';
|
||||
export { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription';
|
||||
export { ModelWithInteger } from './models/ModelWithInteger';
|
||||
export { ModelWithLink } from './models/ModelWithLink';
|
||||
export { ModelWithNestedEnums } from './models/ModelWithNestedEnums';
|
||||
export { ModelWithNestedProperties } from './models/ModelWithNestedProperties';
|
||||
export { ModelWithOrderedProperties } from './models/ModelWithOrderedProperties';
|
||||
export { ModelWithPattern } from './models/ModelWithPattern';
|
||||
export { ModelWithProperties } from './models/ModelWithProperties';
|
||||
export { ModelWithReference } from './models/ModelWithReference';
|
||||
export { ModelWithString } from './models/ModelWithString';
|
||||
export { MultilineComment } from './models/MultilineComment';
|
||||
export { SimpleBoolean } from './models/SimpleBoolean';
|
||||
export { SimpleFile } from './models/SimpleFile';
|
||||
export { SimpleInteger } from './models/SimpleInteger';
|
||||
export { SimpleReference } from './models/SimpleReference';
|
||||
export { SimpleString } from './models/SimpleString';
|
||||
export type { ModelWithInteger } from './models/ModelWithInteger';
|
||||
export type { ModelWithLink } from './models/ModelWithLink';
|
||||
export type { ModelWithNestedEnums } from './models/ModelWithNestedEnums';
|
||||
export type { ModelWithNestedProperties } from './models/ModelWithNestedProperties';
|
||||
export type { ModelWithOrderedProperties } from './models/ModelWithOrderedProperties';
|
||||
export type { ModelWithPattern } from './models/ModelWithPattern';
|
||||
export type { ModelWithProperties } from './models/ModelWithProperties';
|
||||
export type { ModelWithReference } from './models/ModelWithReference';
|
||||
export type { ModelWithString } from './models/ModelWithString';
|
||||
export type { MultilineComment } from './models/MultilineComment';
|
||||
export type { SimpleBoolean } from './models/SimpleBoolean';
|
||||
export type { SimpleFile } from './models/SimpleFile';
|
||||
export type { SimpleInteger } from './models/SimpleInteger';
|
||||
export type { SimpleReference } from './models/SimpleReference';
|
||||
export type { SimpleString } from './models/SimpleString';
|
||||
|
||||
export { $ArrayWithArray } from './schemas/$ArrayWithArray';
|
||||
export { $ArrayWithBooleans } from './schemas/$ArrayWithBooleans';
|
||||
@ -2957,49 +2957,49 @@ export { ApiError } from './core/ApiError';
|
||||
export { isSuccess } from './core/isSuccess';
|
||||
export { OpenAPI } from './core/OpenAPI';
|
||||
|
||||
export { ArrayWithArray } from './models/ArrayWithArray';
|
||||
export { ArrayWithBooleans } from './models/ArrayWithBooleans';
|
||||
export { ArrayWithNumbers } from './models/ArrayWithNumbers';
|
||||
export { ArrayWithProperties } from './models/ArrayWithProperties';
|
||||
export { ArrayWithReferences } from './models/ArrayWithReferences';
|
||||
export { ArrayWithStrings } from './models/ArrayWithStrings';
|
||||
export { DictionaryWithArray } from './models/DictionaryWithArray';
|
||||
export { DictionaryWithDictionary } from './models/DictionaryWithDictionary';
|
||||
export { DictionaryWithProperties } from './models/DictionaryWithProperties';
|
||||
export { DictionaryWithReference } from './models/DictionaryWithReference';
|
||||
export { DictionaryWithString } from './models/DictionaryWithString';
|
||||
export type { ArrayWithArray } from './models/ArrayWithArray';
|
||||
export type { ArrayWithBooleans } from './models/ArrayWithBooleans';
|
||||
export type { ArrayWithNumbers } from './models/ArrayWithNumbers';
|
||||
export type { ArrayWithProperties } from './models/ArrayWithProperties';
|
||||
export type { ArrayWithReferences } from './models/ArrayWithReferences';
|
||||
export type { ArrayWithStrings } from './models/ArrayWithStrings';
|
||||
export type { DictionaryWithArray } from './models/DictionaryWithArray';
|
||||
export type { DictionaryWithDictionary } from './models/DictionaryWithDictionary';
|
||||
export type { DictionaryWithProperties } from './models/DictionaryWithProperties';
|
||||
export type { DictionaryWithReference } from './models/DictionaryWithReference';
|
||||
export type { DictionaryWithString } from './models/DictionaryWithString';
|
||||
export { EnumFromDescription } from './models/EnumFromDescription';
|
||||
export { EnumWithExtensions } from './models/EnumWithExtensions';
|
||||
export { EnumWithNumbers } from './models/EnumWithNumbers';
|
||||
export { EnumWithStrings } from './models/EnumWithStrings';
|
||||
export { ModelLink } from './models/ModelLink';
|
||||
export { ModelThatExtends } from './models/ModelThatExtends';
|
||||
export { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends';
|
||||
export { ModelWithAnyOf } from './models/ModelWithAnyOf';
|
||||
export { ModelWithArray } from './models/ModelWithArray';
|
||||
export { ModelWithBoolean } from './models/ModelWithBoolean';
|
||||
export { ModelWithCircularReference } from './models/ModelWithCircularReference';
|
||||
export { ModelWithDictionary } from './models/ModelWithDictionary';
|
||||
export { ModelWithDuplicateImports } from './models/ModelWithDuplicateImports';
|
||||
export { ModelWithDuplicateProperties } from './models/ModelWithDuplicateProperties';
|
||||
export type { ModelLink } from './models/ModelLink';
|
||||
export type { ModelThatExtends } from './models/ModelThatExtends';
|
||||
export type { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends';
|
||||
export type { ModelWithAnyOf } from './models/ModelWithAnyOf';
|
||||
export type { ModelWithArray } from './models/ModelWithArray';
|
||||
export type { ModelWithBoolean } from './models/ModelWithBoolean';
|
||||
export type { ModelWithCircularReference } from './models/ModelWithCircularReference';
|
||||
export type { ModelWithDictionary } from './models/ModelWithDictionary';
|
||||
export type { ModelWithDuplicateImports } from './models/ModelWithDuplicateImports';
|
||||
export type { ModelWithDuplicateProperties } from './models/ModelWithDuplicateProperties';
|
||||
export { ModelWithEnum } from './models/ModelWithEnum';
|
||||
export { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription';
|
||||
export { ModelWithInteger } from './models/ModelWithInteger';
|
||||
export { ModelWithLink } from './models/ModelWithLink';
|
||||
export { ModelWithNestedEnums } from './models/ModelWithNestedEnums';
|
||||
export { ModelWithNestedProperties } from './models/ModelWithNestedProperties';
|
||||
export { ModelWithOneOf } from './models/ModelWithOneOf';
|
||||
export { ModelWithOrderedProperties } from './models/ModelWithOrderedProperties';
|
||||
export { ModelWithPattern } from './models/ModelWithPattern';
|
||||
export { ModelWithProperties } from './models/ModelWithProperties';
|
||||
export { ModelWithReference } from './models/ModelWithReference';
|
||||
export { ModelWithString } from './models/ModelWithString';
|
||||
export { MultilineComment } from './models/MultilineComment';
|
||||
export { SimpleBoolean } from './models/SimpleBoolean';
|
||||
export { SimpleFile } from './models/SimpleFile';
|
||||
export { SimpleInteger } from './models/SimpleInteger';
|
||||
export { SimpleReference } from './models/SimpleReference';
|
||||
export { SimpleString } from './models/SimpleString';
|
||||
export type { ModelWithInteger } from './models/ModelWithInteger';
|
||||
export type { ModelWithLink } from './models/ModelWithLink';
|
||||
export type { ModelWithNestedEnums } from './models/ModelWithNestedEnums';
|
||||
export type { ModelWithNestedProperties } from './models/ModelWithNestedProperties';
|
||||
export type { ModelWithOneOf } from './models/ModelWithOneOf';
|
||||
export type { ModelWithOrderedProperties } from './models/ModelWithOrderedProperties';
|
||||
export type { ModelWithPattern } from './models/ModelWithPattern';
|
||||
export type { ModelWithProperties } from './models/ModelWithProperties';
|
||||
export type { ModelWithReference } from './models/ModelWithReference';
|
||||
export type { ModelWithString } from './models/ModelWithString';
|
||||
export type { MultilineComment } from './models/MultilineComment';
|
||||
export type { SimpleBoolean } from './models/SimpleBoolean';
|
||||
export type { SimpleFile } from './models/SimpleFile';
|
||||
export type { SimpleInteger } from './models/SimpleInteger';
|
||||
export type { SimpleReference } from './models/SimpleReference';
|
||||
export type { SimpleString } from './models/SimpleString';
|
||||
|
||||
export { $ArrayWithArray } from './schemas/$ArrayWithArray';
|
||||
export { $ArrayWithBooleans } from './schemas/$ArrayWithBooleans';
|
||||
|
||||
@ -21,7 +21,8 @@
|
||||
"strictFunctionTypes": true,
|
||||
"removeComments": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"isolatedModules": true
|
||||
},
|
||||
|
||||
"files": [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user