Skip to content

Commit 464364d

Browse files
authored
chore: add lower-level type definitions table to annex (#126)
* chore: refactor EndpointProperty schema * chore: add lower-level annex table
1 parent 7db54af commit 464364d

File tree

4 files changed

+81
-22
lines changed

4 files changed

+81
-22
lines changed

artifacts/buildSrc/src/main/java/org/eclipse/dsp/generation/transformer/HtmlTableTransformer.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class HtmlTableTransformer implements SchemaTypeTransformer<String> {
4040
@NotNull
4141
public String transform(SchemaType schemaType) {
4242
var builder = new StringBuilder(CSS).append("<table class=\"message-table\">");
43-
builder.append(format("<tr><td class=\"message-class\" colspan=\"4\">%s</td></tr>", schemaType.getName()));
43+
builder.append(format("<tr><td class=\"message-class\" colspan=\"4\" id=\"%s-table\">%s</td></tr>", schemaType.getName(), schemaType.getName()));
4444
transformProperties(schemaType.getTransitiveRequiredProperties(), true, builder);
4545
transformProperties(schemaType.getTransitiveOptionalProperties(), false, builder);
4646
return builder.append("</table>").toString();
@@ -100,12 +100,23 @@ private String parseResolvedTypes(SchemaProperty property) {
100100

101101
private @NotNull String getArrayTypeName(SchemaProperty resolvedProperty) {
102102
var itemTypes = resolvedProperty.getItemTypes().stream()
103-
.flatMap(t -> t.getResolvedTypes().stream()).map(this::getTypeName)
103+
.flatMap(t -> t.getResolvedTypes().stream())
104+
.map(e -> {
105+
if (e.isJsonBaseType()) {
106+
return String.format("%s", getTypeName(e));
107+
}
108+
return String.format("<a href=#%s-table>%s</a>", getTypeName(e), getTypeName(e));
109+
})
104110
.collect(joining(", "));
105111
if (itemTypes.isEmpty()) {
106112
itemTypes = resolvedProperty.getResolvedTypes().stream()
107-
.map(SchemaType::getItemType)
108-
.filter(Objects::nonNull)
113+
.filter(e->getTypeName(e)!=null)
114+
.map(e->{
115+
if (e.isJsonBaseType()) {
116+
return String.format("%s", getTypeName(e));
117+
}
118+
return String.format("<a href=#%s-table>%s</a>", getTypeName(e), getTypeName(e));
119+
})
109120
.collect(joining(", "));
110121
if (itemTypes.isEmpty()) {
111122
return "array";

artifacts/src/main/resources/transfer/data-address-schema.json

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,7 @@
2525
"endpointProperties": {
2626
"type": "array",
2727
"items": {
28-
"type": "object",
29-
"properties": {
30-
"@type": {
31-
"type": "string",
32-
"const": "EndpointProperty"
33-
},
34-
"name": {
35-
"type": "string"
36-
},
37-
"value": {
38-
"type": "string"
39-
}
40-
},
41-
"required": [
42-
"@type",
43-
"name",
44-
"value"
45-
]
28+
"$ref": "#/definitions/EndpointProperty"
4629
},
4730
"minItems": 1
4831
}
@@ -52,6 +35,26 @@
5235
"endpointType",
5336
"endpoint"
5437
]
38+
},
39+
"EndpointProperty": {
40+
"type": "object",
41+
"properties": {
42+
"@type": {
43+
"type": "string",
44+
"const": "EndpointProperty"
45+
},
46+
"name": {
47+
"type": "string"
48+
},
49+
"value": {
50+
"type": "string"
51+
}
52+
},
53+
"required": [
54+
"@type",
55+
"name",
56+
"value"
57+
]
5558
}
5659
}
5760
}

index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ <h1 id="title">Dataspace Protocol</h1>
124124

125125
<section id='conformance'></section>
126126

127+
<section id="lower-level-types" class="appendix" data-include="specifications/common/type-definitions.md" data-include-format="markdown">
128+
<h1>Lower-level type definitions</h1>
129+
</section>
130+
127131
<section id="tof" class="appendix">
128132
<h1>Notes</h1>
129133
</section>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Lower Level Type Definitions
2+
3+
<p data-include="message/table/action.html" data-include-format="html">
4+
</p>
5+
6+
7+
<p data-include="message/table/constraint.html" data-include-format="html">
8+
</p>
9+
10+
11+
<p data-include="message/table/dataaddress.html" data-include-format="html">
12+
</p>
13+
14+
<p data-include="message/table/distribution.html" data-include-format="html">
15+
</p>
16+
17+
18+
<p data-include="message/table/duty.html" data-include-format="html">
19+
</p>
20+
21+
22+
<p data-include="message/table/dataservice.html" data-include-format="html">
23+
</p>
24+
25+
26+
<p data-include="message/table/endpointproperty.html" data-include-format="html">
27+
</p>
28+
29+
30+
<p data-include="message/table/messageoffer.html" data-include-format="html">
31+
</p>
32+
33+
34+
<p data-include="message/table/offer.html" data-include-format="html">
35+
</p>
36+
37+
38+
<p data-include="message/table/permission.html" data-include-format="html">
39+
</p>
40+
41+

0 commit comments

Comments
 (0)