Skip to content

Commit 8d1504f

Browse files
committed
chore: updating API serializer
Signed-off-by: Pawel Psztyc <[email protected]>
1 parent f96339d commit 8d1504f

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@api-components/amf-helper-mixin",
33
"description": "A mixin with common functions user by most AMF components to compute AMF values",
4-
"version": "4.5.2",
4+
"version": "4.5.3",
55
"license": "Apache-2.0",
66
"main": "index.js",
77
"module": "index.js",

src/AmfSerializer.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,11 @@ export class AmfSerializer extends AmfHelperMixin(Object) {
294294
const displayName = this._getValue(target, ns.aml.vocabularies.core.displayName);
295295
if (displayName && typeof displayName === 'string') {
296296
result.displayName = displayName;
297+
} else {
298+
const coreName = this._getValue(target, ns.aml.vocabularies.core.name);
299+
if (coreName && typeof coreName === 'string') {
300+
result.displayName = coreName;
301+
}
297302
}
298303
const description = this._getValue(target, ns.aml.vocabularies.core.description);
299304
if (description && typeof description === 'string') {
@@ -834,12 +839,14 @@ export class AmfSerializer extends AmfHelperMixin(Object) {
834839
if (name && typeof name === 'string') {
835840
result.name = name;
836841
}
837-
// if (!namespace.isNullOrEmpty) {
838-
// result.namespace = namespace.value();
839-
// }
840-
// if (!prefix.isNullOrEmpty) {
841-
// result.prefix = prefix.value();
842-
// }
842+
const xmlNs = this._getValue(object, ns.aml.vocabularies.shapes.xmlNamespace);
843+
if (xmlNs && typeof xmlNs === 'string') {
844+
result.namespace = xmlNs;
845+
}
846+
const xmlPrefix = this._getValue(object, ns.aml.vocabularies.shapes.xmlPrefix);
847+
if (xmlPrefix && typeof xmlPrefix === 'string') {
848+
result.prefix = xmlPrefix;
849+
}
843850
return result;
844851
}
845852

@@ -916,7 +923,8 @@ export class AmfSerializer extends AmfHelperMixin(Object) {
916923
if (Array.isArray(value)) {
917924
[value] = value;
918925
}
919-
result.properties[key] = this.unknownDataNode(value);
926+
const name = key.replace(prefix, '').replace(prefixCompact, '');
927+
result.properties[name] = this.unknownDataNode(value);
920928
}
921929
});
922930
return result;
@@ -929,10 +937,10 @@ export class AmfSerializer extends AmfHelperMixin(Object) {
929937
arrayNode(object) {
930938
const result = /** @type ApiArrayNode */ (this.dataNode(object));
931939
result.members = [];
932-
// const { members } = object;
933-
// if (Array.isArray(members) && members.length) {
934-
// result.members = members.map((item) => this.unknownDataNode(item));
935-
// }
940+
const members = /** @type DataNode[] */ (this._computePropertyArray(object, this.ns.w3.rdfSchema.member));
941+
if (Array.isArray(members) && members.length) {
942+
result.members = members.map((item) => this.unknownDataNode(item));
943+
}
936944
return result;
937945
}
938946

src/Namespace.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ interface Shapes {
183183
xmlName: string;
184184
xmlAttribute: string;
185185
xmlWrapped: string;
186+
xmlNamespace: string;
187+
xmlPrefix: string;
186188
readOnly: string;
187189
writeOnly: string;
188190
deprecated: string;

src/Namespace.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ ns.aml.vocabularies.shapes.xmlSerialization = `${shapesKey}xmlSerialization`;
198198
ns.aml.vocabularies.shapes.xmlName = `${shapesKey}xmlName`;
199199
ns.aml.vocabularies.shapes.xmlAttribute = `${shapesKey}xmlAttribute`;
200200
ns.aml.vocabularies.shapes.xmlWrapped = `${shapesKey}xmlWrapped`;
201+
ns.aml.vocabularies.shapes.xmlNamespace = `${shapesKey}xmlNamespace`;
202+
ns.aml.vocabularies.shapes.xmlPrefix = `${shapesKey}xmlPrefix`;
201203
ns.aml.vocabularies.shapes.readOnly = `${shapesKey}readOnly`;
202204
ns.aml.vocabularies.shapes.writeOnly = `${shapesKey}writeOnly`;
203205
ns.aml.vocabularies.shapes.deprecated = `${shapesKey}deprecated`;

test/helper/Namepsace.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ describe('Namespace', () => {
376376
['xmlName', `${key}xmlName`],
377377
['xmlAttribute', `${key}xmlAttribute`],
378378
['xmlWrapped', `${key}xmlWrapped`],
379+
['xmlNamespace', `${key}xmlNamespace`],
380+
['xmlPrefix', `${key}xmlPrefix`],
379381
['readOnly', `${key}readOnly`],
380382
['writeOnly', `${key}writeOnly`],
381383
['deprecated', `${key}deprecated`],

0 commit comments

Comments
 (0)