diff --git a/APIReference/Service/DataTypeDetail.ts b/APIReference/Service/DataTypeDetail.ts index 65937735f9..209b86c63c 100644 --- a/APIReference/Service/DataTypeDetail.ts +++ b/APIReference/Service/DataTypeDetail.ts @@ -8,6 +8,8 @@ import Dictionary from "Common/Types/Dictionary"; const Resources: Array = ResourceUtil.getResources(); const DataTypes: Array = DataTypeUtil.getDataTypes(); const TypeToDocPath: Dictionary = DataTypeUtil.getTypeToDocPathMap(); +const DataTypesByPath: Dictionary = + DataTypeUtil.getDataTypeDictionaryByPath(); /* * Convert "See TypeName" references in descriptions to HTML links. @@ -63,6 +65,7 @@ interface RelatedType { name: string; path: string; relationship: string; + description?: string; } interface TypeHierarchyItem { @@ -3165,6 +3168,30 @@ export default class ServiceHandler { }, ); + // Enrich related types with descriptions from the DataTypes registry + const enrichedRelatedTypes: Array = ( + detail.relatedTypes || [] + ).map((rt: RelatedType) => { + const dtDoc: DataTypeDocumentation | undefined = DataTypesByPath[rt.path]; + return { + ...rt, + description: rt.description || (dtDoc ? dtDoc.description : undefined), + }; + }); + + // Extract _type wrapper from JSON example + let jsonWrapperType: string = detail.title; + try { + const parsed: Record = JSON.parse( + detail.jsonExample, + ) as Record; + if (parsed._type && typeof parsed._type === "string") { + jsonWrapperType = parsed._type; + } + } catch { + // ignore parse errors + } + const pageData: Dictionary = { title: detail.title, description: linkifyDescription(detail.description), @@ -3172,8 +3199,11 @@ export default class ServiceHandler { properties: linkedProperties, values: linkedValues, jsonExample: detail.jsonExample, - relatedTypes: detail.relatedTypes || [], + relatedTypes: enrichedRelatedTypes, typeHierarchy: detail.typeHierarchy || [], + propertyCount: linkedProperties.length, + valueCount: linkedValues.length, + jsonWrapperType: jsonWrapperType, }; return res.render(`${ViewsPath}/pages/index`, { diff --git a/APIReference/views/main/data-type.ejs b/APIReference/views/main/data-type.ejs index 0e2d90bee9..76e44460f1 100644 --- a/APIReference/views/main/data-type.ejs +++ b/APIReference/views/main/data-type.ejs @@ -21,7 +21,7 @@ <% } %> -
+
@@ -34,33 +34,86 @@

<%- pageData.description %>

+ +
+

At a Glance

+
+
+ Kind + <%= pageData.isEnum ? 'Enum' : 'Data Type' %> +
+ <% if (pageData.isEnum && pageData.valueCount > 0) { %> +
+ Values + <%= pageData.valueCount %> +
+ <% } else if (pageData.propertyCount > 0) { %> +
+ Properties + <%= pageData.propertyCount %> +
+ <% } %> +
+ JSON Format + {"_type": "<%= pageData.jsonWrapperType %>", "value": ...} +
+
+
+ <% if (pageData.isEnum) { %> -

Possible Values

+ + <% if (pageData.values.length >= 4) { %> +
+
+ <% for (var qv = 0; qv < pageData.values.length; qv++) { %> + <%= pageData.values[qv].value %> + <% } %> +
+
+ <% } %> + +

Possible Values

    <% for (var v = 0; v < pageData.values.length; v++) { %> -
  • -
    +
  • +
    +
    Index
    +
    <%= v + 1 %>.
    Value
    <%= pageData.values[v].value %>
    Description
    -
    <%- pageData.values[v].description %>
    +
    <%- pageData.values[v].description %>
  • <% } %>
<% } else if (pageData.properties && pageData.properties.length > 0) { %> -

Properties

+ + <% if (pageData.properties.length >= 4) { %> +
+
+ <% for (var qp = 0; qp < pageData.properties.length; qp++) { %> + <%= pageData.properties[qp].name %> + <% } %> +
+
+ <% } %> + +

Properties

    <% for (var p = 0; p < pageData.properties.length; p++) { %> -
  • -
    -
    Name
    -
    <%= pageData.properties[p].name %>
    -
    Type
    -
    +
  • +
    + <%= pageData.properties[p].name %> + <% if (pageData.properties[p].required) { %> + Required + <% } %> +
    +
    + <% if (pageData.properties[p].typeLinks && pageData.properties[p].typeLinks.length > 0) { %> <% var typeLinks = pageData.properties[p].typeLinks; %> <% for (var tl = 0; tl < typeLinks.length; tl++) { %> @@ -73,45 +126,19 @@ <% } else { %> <%= pageData.properties[p].type %> <% } %> - <% if (pageData.properties[p].required) { %> - Required - <% } %> -
  • -
    Description
    -
    <%- pageData.properties[p].description %>
    -
    + +
+

<%- pageData.properties[p].description %>

<% } %>
<% } %> - - <% if (pageData.relatedTypes && pageData.relatedTypes.length > 0) { %> -

Related Types

-
- <% for (var r = 0; r < pageData.relatedTypes.length; r++) { %> - -
-
- -
-
-
-
<%= pageData.relatedTypes[r].name %>
-
<%= pageData.relatedTypes[r].relationship %>
-
-
- <% } %> -
- <% } %> - -

JSON Example

-
-
- JSON -
-
<%= pageData.jsonExample %>
+ +
+

JSON Example

+ <%- include('../partials/code', { title: "JSON", code: pageData.jsonExample, requestType: "", requestUrl: "" }) %>
<% if (pageData.title === "Permission") { %> @@ -123,5 +150,30 @@
<% } %> + + <% if (pageData.relatedTypes && pageData.relatedTypes.length > 0) { %> + + <% } %> +