fix: filter tags override inherited type tags

This commit is contained in:
Wieland Schöbl
2021-09-28 12:49:02 +00:00
parent 61b1fde0ec
commit f0401e1889
41 changed files with 218 additions and 257 deletions

View File

@@ -67,4 +67,17 @@ export const typemap: ElasticsearchTypemap = {
},
};
/**
* If the string is a tag type
*/
export function isTagType(str: string): boolean {
for (const key in typemap) {
if (typemap.hasOwnProperty(key) && typeof typemap[key][str] !== 'undefined') {
return true;
}
}
return false;
}
export const dynamicTypes = ['any', 'unknown'];

View File

@@ -31,7 +31,7 @@ import {
import {fieldmap, filterableMap, filterableTagName} from './config/fieldmap';
import {premaps} from './config/premap';
import {settings} from './config/settings';
import {dynamicTypes, ElasticsearchDataType, typemap} from './config/typemap';
import {dynamicTypes, ElasticsearchDataType, isTagType, typemap} from './config/typemap';
import {AggregationSchema, ESNestedAggregation} from './types/aggregation';
import {
ElasticsearchDynamicTemplate,
@@ -275,7 +275,11 @@ function handleDeclarationReflection(decl: DeclarationReflection,
}
} else if (decl.type instanceof Type) { // if the object is a type, so we are dealing with a PROPERTY
// get inherited tags
const tags = (inheritedTags ?? []).length > 0 ? inheritedTags! : getCommentTags(decl, path, topTypeName);
const tags = (inheritedTags ?? []).length > 0
? (typeof inheritedTags!.find(it => isTagType(it.tagName)) !== 'undefined'
? inheritedTags!
: [...inheritedTags ?? [], ...getCommentTags(decl, path, topTypeName)])
: getCommentTags(decl, path, topTypeName);
return handleType(decl.type, new Map(generics), path, topTypeName, tags);
} else if (decl.kindString === 'Enumeration member') {