mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
21 lines
743 B
TypeScript
21 lines
743 B
TypeScript
import { getSortedImports } from './getSortedImports';
|
|
import { Model } from '../client/interfaces/Model';
|
|
|
|
export function cleanupModels(models: Model[]): Model[] {
|
|
models.forEach(model => {
|
|
model.imports = getSortedImports(model.imports).filter(name => {
|
|
return model.name !== name;
|
|
});
|
|
model.properties = model.properties
|
|
.filter((property, index, arr) => {
|
|
return arr.findIndex(item => item.name === property.name) === index;
|
|
})
|
|
.sort((a, b) => {
|
|
const nameA = a.name.toLowerCase();
|
|
const nameB = b.name.toLowerCase();
|
|
return nameA.localeCompare(nameB);
|
|
});
|
|
});
|
|
return models;
|
|
}
|