@doccov/sdk 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +16 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1870,6 +1870,16 @@ function schemasAreEqual(left, right) {
1870
1870
  };
1871
1871
  return JSON.stringify(normalize(left)) === JSON.stringify(normalize(right));
1872
1872
  }
1873
+ function deduplicateSchemas(schemas) {
1874
+ const result = [];
1875
+ for (const schema of schemas) {
1876
+ const isDuplicate = result.some((existing) => schemasAreEqual(existing, schema));
1877
+ if (!isDuplicate) {
1878
+ result.push(schema);
1879
+ }
1880
+ }
1881
+ return result;
1882
+ }
1873
1883
  function formatTypeReference(type, typeChecker, typeRefs, referencedTypes, visitedAliases) {
1874
1884
  const visited = visitedAliases ?? new Set;
1875
1885
  const aliasSymbol = type.aliasSymbol;
@@ -1929,15 +1939,19 @@ function formatTypeReference(type, typeChecker, typeRefs, referencedTypes, visit
1929
1939
  if (type.isUnion()) {
1930
1940
  const unionType = type;
1931
1941
  const parts = unionType.types.map((t) => formatTypeReference(t, typeChecker, typeRefs, referencedTypes, visited));
1942
+ const uniqueParts = deduplicateSchemas(parts);
1943
+ if (uniqueParts.length === 1) {
1944
+ return uniqueParts[0];
1945
+ }
1932
1946
  const discriminatorProp = findDiscriminatorProperty(unionType.types, typeChecker);
1933
1947
  if (discriminatorProp) {
1934
1948
  return {
1935
- anyOf: parts,
1949
+ anyOf: uniqueParts,
1936
1950
  discriminator: { propertyName: discriminatorProp }
1937
1951
  };
1938
1952
  }
1939
1953
  return {
1940
- anyOf: parts
1954
+ anyOf: uniqueParts
1941
1955
  };
1942
1956
  }
1943
1957
  if (type.isIntersection()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doccov/sdk",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "DocCov SDK - Documentation coverage and drift detection for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",